Skip to content

Commit

Permalink
Add CI for error-message-lines
Browse files Browse the repository at this point in the history
  • Loading branch information
junjihashimoto committed Sep 28, 2023
1 parent eb1573a commit 12c2e08
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
11 changes: 11 additions & 0 deletions inline-c-cpp/test-error-message-line-numbers.sh
Original file line number Diff line number Diff line change
@@ -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
14 changes: 7 additions & 7 deletions inline-c-cpp/test/tests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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. */}|]

Check failure on line 301 in inline-c-cpp/test/tests.hs

View workflow job for this annotation

GitHub Actions / ubuntu-latest-stack-nightly

error: lvalue required as left operand of assignment

Check failure on line 301 in inline-c-cpp/test/tests.hs

View workflow job for this annotation

GitHub Actions / ubuntu-latest-stack-lts-20

error: lvalue required as left operand of assignment

Check failure on line 301 in inline-c-cpp/test/tests.hs

View workflow job for this annotation

GitHub Actions / ubuntu-latest-stack-lts-21

error: lvalue required as left operand of assignment

Check failure on line 301 in inline-c-cpp/test/tests.hs

View workflow job for this annotation

GitHub Actions / macos-latest-stack-lts-20

|

Check failure on line 301 in inline-c-cpp/test/tests.hs

View workflow job for this annotation

GitHub Actions / macos-latest-stack-lts-21

|

Check failure on line 301 in inline-c-cpp/test/tests.hs

View workflow job for this annotation

GitHub Actions / macos-latest-stack-nightly

|
result `shouldBeRight` 0xDEADBEEF
Hspec.it "error reporting test case" $ do
result <- try $ [C.throwBlock| int
{ 1 = 1; }
{ 1 = 1; /* Test this line. */}

Check failure on line 306 in inline-c-cpp/test/tests.hs

View workflow job for this annotation

GitHub Actions / ubuntu-latest-stack-nightly

error: lvalue required as left operand of assignment

Check failure on line 306 in inline-c-cpp/test/tests.hs

View workflow job for this annotation

GitHub Actions / ubuntu-latest-stack-lts-20

error: lvalue required as left operand of assignment

Check failure on line 306 in inline-c-cpp/test/tests.hs

View workflow job for this annotation

GitHub Actions / ubuntu-latest-stack-lts-21

error: lvalue required as left operand of assignment

Check failure on line 306 in inline-c-cpp/test/tests.hs

View workflow job for this annotation

GitHub Actions / macos-latest-stack-lts-20

error: expression is not assignable

Check failure on line 306 in inline-c-cpp/test/tests.hs

View workflow job for this annotation

GitHub Actions / macos-latest-stack-lts-21

error: expression is not assignable

Check failure on line 306 in inline-c-cpp/test/tests.hs

View workflow job for this annotation

GitHub Actions / macos-latest-stack-nightly

error: expression is not assignable
|]
result `shouldBeRight` 0xDEADBEEF

Check failure on line 308 in inline-c-cpp/test/tests.hs

View workflow job for this annotation

GitHub Actions / ubuntu-latest-stack-nightly

error: control reaches end of non-void function [-Werror=return-type]

Check failure on line 308 in inline-c-cpp/test/tests.hs

View workflow job for this annotation

GitHub Actions / ubuntu-latest-stack-lts-20

error: control reaches end of non-void function [-Werror=return-type]

Check failure on line 308 in inline-c-cpp/test/tests.hs

View workflow job for this annotation

GitHub Actions / ubuntu-latest-stack-lts-21

error: control reaches end of non-void function [-Werror=return-type]
Hspec.it "error reporting test case" $ do
result <- try $ [C.throwBlock| int
{

Check failure on line 312 in inline-c-cpp/test/tests.hs

View workflow job for this annotation

GitHub Actions / ubuntu-latest-stack-nightly

error: control reaches end of non-void function [-Werror=return-type]

Check failure on line 312 in inline-c-cpp/test/tests.hs

View workflow job for this annotation

GitHub Actions / ubuntu-latest-stack-lts-20

error: control reaches end of non-void function [-Werror=return-type]

Check failure on line 312 in inline-c-cpp/test/tests.hs

View workflow job for this annotation

GitHub Actions / ubuntu-latest-stack-lts-21

error: control reaches end of non-void function [-Werror=return-type]
2 = 2;
2 = 2; /* Test this line. */

Check failure on line 313 in inline-c-cpp/test/tests.hs

View workflow job for this annotation

GitHub Actions / ubuntu-latest-stack-nightly

error: lvalue required as left operand of assignment

Check failure on line 313 in inline-c-cpp/test/tests.hs

View workflow job for this annotation

GitHub Actions / ubuntu-latest-stack-lts-20

error: lvalue required as left operand of assignment

Check failure on line 313 in inline-c-cpp/test/tests.hs

View workflow job for this annotation

GitHub Actions / ubuntu-latest-stack-lts-21

error: lvalue required as left operand of assignment

Check failure on line 313 in inline-c-cpp/test/tests.hs

View workflow job for this annotation

GitHub Actions / macos-latest-stack-lts-20

error: expression is not assignable

Check failure on line 313 in inline-c-cpp/test/tests.hs

View workflow job for this annotation

GitHub Actions / macos-latest-stack-lts-21

error: expression is not assignable

Check failure on line 313 in inline-c-cpp/test/tests.hs

View workflow job for this annotation

GitHub Actions / macos-latest-stack-nightly

error: expression is not assignable
}
|]
result `shouldBeRight` 0xDEADBEEF
Expand All @@ -319,7 +319,7 @@ main = Hspec.hspec $ do
result <- try $ [C.throwBlock|
int
{
3 = 3;
3 = 3; /* Test this line. */

Check failure on line 322 in inline-c-cpp/test/tests.hs

View workflow job for this annotation

GitHub Actions / ubuntu-latest-stack-nightly

error: lvalue required as left operand of assignment

Check failure on line 322 in inline-c-cpp/test/tests.hs

View workflow job for this annotation

GitHub Actions / ubuntu-latest-stack-lts-20

error: lvalue required as left operand of assignment

Check failure on line 322 in inline-c-cpp/test/tests.hs

View workflow job for this annotation

GitHub Actions / ubuntu-latest-stack-lts-21

error: lvalue required as left operand of assignment

Check failure on line 322 in inline-c-cpp/test/tests.hs

View workflow job for this annotation

GitHub Actions / macos-latest-stack-lts-20

error: expression is not assignable

Check failure on line 322 in inline-c-cpp/test/tests.hs

View workflow job for this annotation

GitHub Actions / macos-latest-stack-lts-21

error: expression is not assignable

Check failure on line 322 in inline-c-cpp/test/tests.hs

View workflow job for this annotation

GitHub Actions / macos-latest-stack-nightly

error: expression is not assignable
}
|]
result `shouldBeRight` 0xDEADBEEF
Expand All @@ -329,11 +329,11 @@ main = Hspec.hspec $ do
int
{
4 = 4;
4 = 4; /* Test this line. */

Check failure on line 332 in inline-c-cpp/test/tests.hs

View workflow job for this annotation

GitHub Actions / ubuntu-latest-stack-nightly

error: lvalue required as left operand of assignment

Check failure on line 332 in inline-c-cpp/test/tests.hs

View workflow job for this annotation

GitHub Actions / ubuntu-latest-stack-lts-20

error: lvalue required as left operand of assignment

Check failure on line 332 in inline-c-cpp/test/tests.hs

View workflow job for this annotation

GitHub Actions / ubuntu-latest-stack-lts-21

error: lvalue required as left operand of assignment

Check failure on line 332 in inline-c-cpp/test/tests.hs

View workflow job for this annotation

GitHub Actions / macos-latest-stack-lts-20

error: expression is not assignable

Check failure on line 332 in inline-c-cpp/test/tests.hs

View workflow job for this annotation

GitHub Actions / macos-latest-stack-lts-21

error: expression is not assignable

Check failure on line 332 in inline-c-cpp/test/tests.hs

View workflow job for this annotation

GitHub Actions / macos-latest-stack-nightly

error: expression is not assignable
}
|]
result `shouldBeRight` 0xDEADBEEF

Check failure on line 335 in inline-c-cpp/test/tests.hs

View workflow job for this annotation

GitHub Actions / ubuntu-latest-stack-nightly

error: control reaches end of non-void function [-Werror=return-type]

Check failure on line 335 in inline-c-cpp/test/tests.hs

View workflow job for this annotation

GitHub Actions / ubuntu-latest-stack-lts-20

error: control reaches end of non-void function [-Werror=return-type]

Check failure on line 335 in inline-c-cpp/test/tests.hs

View workflow job for this annotation

GitHub Actions / ubuntu-latest-stack-lts-21

error: control reaches end of non-void function [-Werror=return-type]
-- -}
-- For CI, uncomment this line. -}

Hspec.describe "Macros" $ do
Hspec.it "generated std::vector instances work correctly" $ do
Expand Down

0 comments on commit 12c2e08

Please sign in to comment.