From 12c2e08ae2695618b6ed92c5223b35cb6556bdb4 Mon Sep 17 00:00:00 2001 From: Junji Hashimoto Date: Fri, 29 Sep 2023 05:18:32 +0900 Subject: [PATCH] Add CI for error-message-lines --- .github/workflows/ci.yaml | 2 ++ inline-c-cpp/test-error-message-line-numbers.sh | 11 +++++++++++ inline-c-cpp/test/tests.hs | 14 +++++++------- 3 files changed, 20 insertions(+), 7 deletions(-) create mode 100755 inline-c-cpp/test-error-message-line-numbers.sh diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index c321cf2..3f03e30 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -45,6 +45,8 @@ jobs: run: | if [ ${{ matrix.os }} == "ubuntu-latest" ] ; then stack test --stack-yaml stack-${{ matrix.stackage }}.yaml --flag inline-c:gsl-example --flag inline-c-cpp:std-vector-example + ./inline-c-cpp/test-error-message-line-numbers.sh --stack-yaml stack-${{ matrix.stackage }}.yaml else stack test --stack-yaml stack-${{ matrix.stackage }}.yaml --flag inline-c-cpp:std-vector-example + ./inline-c-cpp/test-error-message-line-numbers.sh --stack-yaml stack-${{ matrix.stackage }}.yaml fi diff --git a/inline-c-cpp/test-error-message-line-numbers.sh b/inline-c-cpp/test-error-message-line-numbers.sh new file mode 100755 index 0000000..6752f9b --- /dev/null +++ b/inline-c-cpp/test-error-message-line-numbers.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash +set -x +sed -i -e 's/.*uncomment this line.*//g' inline-c-cpp/test/tests.hs +stack test $@ inline-c-cpp >& error-log +cat error-log +grep -n 'Test this line' inline-c-cpp/test/tests.hs | awk -F ':' '{print $1}' > exp +cat exp +grep 'tests.hs:[0-9]*:.*error' error-log | awk -F ':' '{print $2}' > out +cat out +set -xe +diff exp out diff --git a/inline-c-cpp/test/tests.hs b/inline-c-cpp/test/tests.hs index 5d56351..1474f7f 100644 --- a/inline-c-cpp/test/tests.hs +++ b/inline-c-cpp/test/tests.hs @@ -295,22 +295,22 @@ main = Hspec.hspec $ do result `shouldBeRight` 0xDEADBEEF - {- Manual test cases for testing lineDirective and splitTypedC + {- Manual test cases for testing lineDirective and splitTypedC -- For CI, uncomment this line. Hspec.it "error reporting test case" $ do - result <- try $ [C.throwBlock| int { 0 = 0; }|] + result <- try $ [C.throwBlock| int { 0 = 0; /* Test this line. */}|] result `shouldBeRight` 0xDEADBEEF Hspec.it "error reporting test case" $ do result <- try $ [C.throwBlock| int - { 1 = 1; } + { 1 = 1; /* Test this line. */} |] result `shouldBeRight` 0xDEADBEEF Hspec.it "error reporting test case" $ do result <- try $ [C.throwBlock| int { - 2 = 2; + 2 = 2; /* Test this line. */ } |] result `shouldBeRight` 0xDEADBEEF @@ -319,7 +319,7 @@ main = Hspec.hspec $ do result <- try $ [C.throwBlock| int { - 3 = 3; + 3 = 3; /* Test this line. */ } |] result `shouldBeRight` 0xDEADBEEF @@ -329,11 +329,11 @@ main = Hspec.hspec $ do int { - 4 = 4; + 4 = 4; /* Test this line. */ } |] result `shouldBeRight` 0xDEADBEEF - -- -} + -- For CI, uncomment this line. -} Hspec.describe "Macros" $ do Hspec.it "generated std::vector instances work correctly" $ do