diff --git a/make.sh b/make.sh index 06478c7c..1aa270ed 100755 --- a/make.sh +++ b/make.sh @@ -43,14 +43,13 @@ clean () install_it () { - echo "Installing 'tre' to '$BINDIR'…" - sudo cp tre $BINDIR sudo mkdir -p /usr/local/lib/tre echo "Installing SBCL image to '/usr/local/lib/tre/image'…" - sudo cp -v image /usr/local/lib/tre + sudo cp -v image /usr/local/lib/tre/ echo "Installing environment to '/usr/local/lib/tre/environment/'…" - sudo cp -rv environment modules /usr/local/lib/tre - echo "Done." + sudo cp -rv environment modules /usr/local/lib/tre/ + echo "Installing 'tre' to '$BINDIR'…" + sudo cp tre $BINDIR } case $1 in @@ -78,28 +77,28 @@ boot) phptests) echo "PHP target tests…" - $TRE tests/php.lisp + echo "(compile-tests *php-transpiler*)" | $TRE tests/toplevel.lisp php compiled/test.php | tee log-phptests.lisp cmp tests/php.correct-output log-phptests.lisp || (diff tests/php.correct-output log-phptests.lisp; exit 1) for i in compiled/unit*.php; do php $i; done ;; jstests) - echo "JavaScript target tests…" - $TRE tests/js.lisp + echo "JS target tests…" + echo "(compile-tests *js-transpiler*)" | $TRE tests/toplevel.lisp node compiled/test.js | tee log-jstests.lisp - #chromium-browser compiled/test.html & + #$BROWSER compiled/test.html cmp tests/js.correct-output log-jstests.lisp || (diff tests/js.correct-output log-jstests.lisp; exit 1) for i in compiled/unit*.js; do node $i; done - echo "JavaScript target tests passed in node.js." + echo "JS target tests passed in node.js." ;; updatetests) - $TRE tests/php.lisp - $TRE tests/js.lisp + echo "(compile-tests *php-transpiler*)" | $TRE tests/toplevel.lisp + echo "(compile-tests *js-transpiler*)" | $TRE tests/toplevel.lisp echo "Updating PHP target test data…" php compiled/test.php >tests/php.correct-output - echo "Updating JavaScript target test data (node.js only)…" + echo "Updating JS target test data (node.js only)…" node compiled/test.js >tests/js.correct-output || node compiled/test.js >tests/js.correct-output ;; diff --git a/tests/js.lisp b/tests/js.lisp deleted file mode 100644 index 112799c8..00000000 --- a/tests/js.lisp +++ /dev/null @@ -1,26 +0,0 @@ -(unix-sh-mkdir "compiled" :parents t) - -(make-project "tré JavaScript target test" - (list "environment/stage3/type.lisp" - (. 'tests (make-environment-tests)) - (. 'toplevel '((environment-tests)))) - :transpiler (copy-transpiler *js-transpiler*) - :emitter [(make-html-script "compiled/test.html" _) - (put-file "compiled/test.js" _)]) - -(make-project "JavaScript test unit 1" - `("tests/unit-1.lisp") - :transpiler (copy-transpiler *js-transpiler*) - :emitter [put-file "compiled/unit-1.js" _]) - -(make-project "JavaScript test unit 2" - `("tests/unit-2-getter.lisp") - :transpiler (copy-transpiler *js-transpiler*) - :emitter [put-file "compiled/unit-2-getter.js" _]) - -(make-project "JavaScript test unit 2" - `("tests/unit-3-base64.lisp") - :transpiler (copy-transpiler *js-transpiler*) - :emitter [put-file "compiled/unit-3-base64.js" _]) - -(quit) diff --git a/tests/php.lisp b/tests/php.lisp deleted file mode 100644 index a87743ed..00000000 --- a/tests/php.lisp +++ /dev/null @@ -1,25 +0,0 @@ -(unix-sh-mkdir "compiled" :parents t) - -(make-project "PHP target test" - (list "environment/stage3/type.lisp" - (. 'tests (make-environment-tests)) - (. 'toplevel '((environment-tests)))) - :transpiler (copy-transpiler *php-transpiler*) - :emitter [put-file "compiled/test.php" _]) - -(make-project "PHP test unit 1" - `("tests/unit-1.lisp") - :transpiler (copy-transpiler *php-transpiler*) - :emitter [put-file "compiled/unit-1.php" _]) - -(make-project "PHP test unit 2" - `("tests/unit-2-getter.lisp") - :transpiler (copy-transpiler *php-transpiler*) - :emitter [put-file "compiled/unit-2-getter.php" _]) - -(make-project "PHP test unit 3" - `("tests/unit-3-base64.lisp") - :transpiler (copy-transpiler *php-transpiler*) - :emitter [put-file "compiled/unit-3-base64.php" _]) - -(quit) diff --git a/tests/toplevel.lisp b/tests/toplevel.lisp new file mode 100644 index 00000000..295750a7 --- /dev/null +++ b/tests/toplevel.lisp @@ -0,0 +1,27 @@ +(fn compile-env-tests (tr) + (make-project (format nil "~A environment test" (transpiler-name tr)) + (list "environment/stage3/type.lisp" + (. 'tests (make-environment-tests)) + (. 'toplevel '((environment-tests)))) + :transpiler (copy-transpiler tr) + :emitter [put-file (format nil "compiled/test.~A" (transpiler-file-postfix tr)) _])) + +(fn compile-unit-tests (tr lst) + (do ((n 1 (++ n)) + (i lst .i)) + ((not i)) + (!= i. + (make-project (format nil "Unit ~A: ~A" n .!.) + (format nil "tests/unit-~A-~A.lisp" n !.) + :transpiler (copy-transpiler tr) + :emitter [put-file (format nil "compiled/unit-~A-~A.~A" n !. (transpiler-file-postfix tr)) _])))) + +(fn compile-tests (tr) + (unix-sh-mkdir "compiled" :parents t) + (compile-env-tests tr) + (compile-unit-tests tr + '(("smoke-test" "Smoke test") + ("getter" "Something with getters") + ("base64" "BASE64-ENCODE, BASE64-DECODE") + ))) +; ("slot-value" "SLOT-VALUE as function")))) diff --git a/tests/unit-1.lisp b/tests/unit-1-smoke-test.lisp similarity index 100% rename from tests/unit-1.lisp rename to tests/unit-1-smoke-test.lisp