From 301324b9b3b0a4255d5372cc0ba1a42a3b070fa1 Mon Sep 17 00:00:00 2001 From: "G. Allais" Date: Wed, 10 Feb 2021 21:10:27 +0000 Subject: [PATCH] [ fix #1043 ] throw error if compileExpr failed (#1052) Also adding a CI target testing the gambit backend. --- .github/workflows/ci-macos-combined.yml | 90 +++++++++++++++++++++++++ .github/workflows/ci-macos.yml | 36 ---------- src/Compiler/Scheme/Gambit.idr | 9 ++- tests/Main.idr | 6 -- tests/gambit/bitops001/expected | 2 - tests/gambit/bitops001/input | 2 - tests/gambit/bitops001/run | 7 +- 7 files changed, 99 insertions(+), 53 deletions(-) create mode 100644 .github/workflows/ci-macos-combined.yml delete mode 100644 .github/workflows/ci-macos.yml delete mode 100644 tests/gambit/bitops001/input mode change 100644 => 100755 tests/gambit/bitops001/run diff --git a/.github/workflows/ci-macos-combined.yml b/.github/workflows/ci-macos-combined.yml new file mode 100644 index 000000000..54d55cfdb --- /dev/null +++ b/.github/workflows/ci-macos-combined.yml @@ -0,0 +1,90 @@ +name: macOS Combined Chez +on: + push: + branches: + - '*' + tags: + - '*' + pull_request: + branches: + - master + +env: + SCHEME: chez + IDRIS2_TESTS_CG: chez + ACTIONS_ALLOW_UNSECURE_COMMANDS: true + +jobs: + + # Building the executable + + build-bootstrap-chez: + runs-on: macos-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Install build dependencies + run: | + brew install chezscheme + brew install coreutils + echo "::add-path::$HOME/.idris2/bin" + - name: Build Idris 2 from bootstrap + run: make bootstrap && make install + shell: bash + - name: Artifact Bootstrapped Idris2 + uses: actions/upload-artifact@v2 + with: + name: installed-bootstrapped-idris2-chez + path: ~/.idris2/ + + # self hosting and testing + + self-host-chez: + needs: build-bootstrap-chez + runs-on: macos-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Download Idris2 Artifact + uses: actions/download-artifact@v2 + with: + name: installed-bootstrapped-idris2-chez + path: ~/.idris2/ + - name: Install build dependencies + run: | + brew install chezscheme + brew install coreutils + echo "::add-path::$HOME/.idris2/bin" + chmod +x $HOME/.idris2/bin/idris2 $HOME/.idris2/bin/idris2_app/* + - name: Build self-hosted + run: make all && make install + shell: bash + - name: Test self-hosted + run: make test INTERACTIVE='' + shell: bash + + # this gambit test is really slow so se run it separately + + test-gambit: + needs: build-bootstrap-chez + runs-on: macos-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Download Idris2 Artifact + uses: actions/download-artifact@v2 + with: + name: installed-bootstrapped-idris2-chez + path: ~/.idris2/ + - name: Install build dependencies + run: | + brew install chezscheme + brew install coreutils + brew install gambit-scheme + CURRENTDIR=$(find /usr/local/Cellar/gambit-scheme -type l -name current) + echo "::add-path::${CURRENTDIR}/bin" + echo "::add-path::$HOME/.idris2/bin" + chmod +x $HOME/.idris2/bin/idris2 $HOME/.idris2/bin/idris2_app/* + - name: Test gambit + run: cd tests/gambit/bitops001/ && ./run idris2 + shell: bash diff --git a/.github/workflows/ci-macos.yml b/.github/workflows/ci-macos.yml deleted file mode 100644 index 964ec61df..000000000 --- a/.github/workflows/ci-macos.yml +++ /dev/null @@ -1,36 +0,0 @@ -name: macOS Chez -on: - push: - branches: - - '*' - tags: - - '*' - pull_request: - branches: - - master - -env: - SCHEME: chez - IDRIS2_TESTS_CG: chez - ACTIONS_ALLOW_UNSECURE_COMMANDS: true - -jobs: - build: - runs-on: macos-latest - steps: - - name: Checkout - uses: actions/checkout@v2 - - name: Install build dependencies - run: | - brew install chezscheme - brew install coreutils - echo "::add-path::$HOME/.idris2/bin" - - name: Build Idris 2 from bootstrap - run: make bootstrap && make install && make clean - shell: bash - - name: Build self-hosted - run: make all && make install - shell: bash - - name: Test self-hosted - run: make test INTERACTIVE='' - shell: bash diff --git a/src/Compiler/Scheme/Gambit.idr b/src/Compiler/Scheme/Gambit.idr index e31488382..034a340f0 100644 --- a/src/Compiler/Scheme/Gambit.idr +++ b/src/Compiler/Scheme/Gambit.idr @@ -412,11 +412,10 @@ compileExpr c tmpDir outputDir tm outfile executeExpr : Ref Ctxt Defs -> (tmpDir : String) -> ClosedTerm -> Core () executeExpr c tmpDir tm - = do outn <- compileExpr c tmpDir tmpDir tm "_tmpgambit" - case outn of - -- TODO: on windows, should add exe extension - Just outn => map (const ()) $ coreLift $ system outn - Nothing => pure () + = do Just sh <- compileExpr c tmpDir tmpDir tm "_tmpgambit" + | Nothing => throw (InternalError "compileExpr returned Nothing") + coreLift $ system sh -- TODO: on windows, should add exe extension + pure () export codegenGambit : Codegen diff --git a/tests/Main.idr b/tests/Main.idr index 1d7fa836b..dbe011336 100644 --- a/tests/Main.idr +++ b/tests/Main.idr @@ -189,11 +189,6 @@ racketTests = MkTestPool [Racket] , "futures001" ] -gambitTests : TestPool -gambitTests = MkTestPool [Gambit] - [ "bitops001" - ] - nodeTests : TestPool nodeTests = MkTestPool [Node] [ "node001", "node002", "node003", "node004", "node005", "node006" @@ -241,7 +236,6 @@ main = runner , testPaths "chez" chezTests , testPaths "refc" refcTests , testPaths "racket" racketTests - , testPaths "gambit" gambitTests , testPaths "node" nodeTests , testPaths "templates" templateTests ] where diff --git a/tests/gambit/bitops001/expected b/tests/gambit/bitops001/expected index 3718c9493..be8344e5b 100644 --- a/tests/gambit/bitops001/expected +++ b/tests/gambit/bitops001/expected @@ -35,5 +35,3 @@ [4294967284, 11, 10, 9, 15, 0] [2147483636, 11, 10, 9, 15, 0] [-2147483638, -11, -12, -9, -15, -2, 2147483637, 10, 11, 9, 0] -1/1: Building BitOps (BitOps.idr) -Main> Main> Bye for now! diff --git a/tests/gambit/bitops001/input b/tests/gambit/bitops001/input deleted file mode 100644 index fc5992c29..000000000 --- a/tests/gambit/bitops001/input +++ /dev/null @@ -1,2 +0,0 @@ -:exec main -:q diff --git a/tests/gambit/bitops001/run b/tests/gambit/bitops001/run old mode 100644 new mode 100755 index b158daa95..821e6b297 --- a/tests/gambit/bitops001/run +++ b/tests/gambit/bitops001/run @@ -1,3 +1,6 @@ -$1 --cg gambit --no-banner --no-color --console-width 0 BitOps.idr < input - +$1 --cg gambit --exec main BitOps.idr > output rm -rf build + +# We finish with cmp so that the test fails if the comparison fails +diff expected output +cmp expected output