diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..fc8c8de --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,16 @@ +name: CI +run-name: continuous integration +on: [push] +jobs: + test: + strategy: + matrix: + os: [ubuntu-20.04, ubuntu-22.04, ubuntu-latest] + cc: [gcc, clang] + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v3 + - run: ./tests/test.sh + shell: bash + env: + CC: ${{ matrix.cc }} diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 35f979c..0000000 --- a/.travis.yml +++ /dev/null @@ -1,6 +0,0 @@ -language: c -compiler: - - gcc - - clang - - gfortran -script: (cd tests; ./test.sh) diff --git a/c b/c index 3980e21..3621cb9 100755 --- a/c +++ b/c @@ -34,7 +34,7 @@ cleanup() { # Handle --help, -h, and zero args [[ "$1" == "--help" || "$1" == "-h" ]] && { help_msg 1; exit 0; } -[[ "$#" -lt 1 ]] && { help_msg 2; exit 1; } +[[ "$#" -lt 1 ]] && { help_msg 2; exit 2; } # ensure our $CC and $CXX variables are set [[ -z "$CC" ]] && CC=cc @@ -155,9 +155,14 @@ binname="$tmproot/$id.bin" run() { trap cleanup SIGINT - shift - (exec -a "$fname" "$binname" "$@") - ret=$? + if [ -x "$binname" ]; then + shift + (exec -a "$fname" "$binname" "$@") + ret=$? + else + echo + ret=4 + fi trap - SIGINT cleanup diff --git a/tests/shell/test.sh b/tests/shell/test.sh index 0c56460..c544df1 100644 --- a/tests/shell/test.sh +++ b/tests/shell/test.sh @@ -12,19 +12,19 @@ line=$(eval "C_CACHE_SIZE=-10 $c" 2>&1); ret=$? fline="$(echo "$line" | head -n1)" assert "\$C_CACHE_SIZE=-10"\ "'$fline' =~ warning:\\ \\\$C_CACHE_SIZE\\ should\\ be\\ a\\ positive\\ integer.*" -assert "return" "$ret -eq 1" +assert "return" "$ret -eq 2" # cache=0 line=$(eval "C_CACHE_SIZE=0 $c" 2>&1); ret=$? fline="$(echo "$line" | head -n1)" assert "\$C_CACHE_SIZE=0" "'$fline' =~ Usage:.*" -assert "return" "$ret -eq 1" +assert "return" "$ret -eq 2" # cache=10 line=$(eval "C_CACHE_SIZE=10 $c" 2>&1); ret=$? fline="$(echo "$line" | head -n1)" assert "\$C_CACHE_SIZE=10" "'$fline' =~ Usage:.*" -assert "return" "$ret -eq 1" +assert "return" "$ret -eq 2" ## Shell - help flags header2 "Shell - help flags" @@ -33,7 +33,7 @@ header2 "Shell - help flags" line=$(eval "$c" 2>&1); ret=$? fline="$(echo "$line" | head -n1)" assert "c" "'$fline' =~ Usage:.*" -assert "return" "$ret -eq 1" +assert "return" "$ret -eq 2" # gives usage with --help line=$(eval "$c --help" 2>&1); ret=$? diff --git a/tests/test.sh b/tests/test.sh index 3972959..3711835 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -6,6 +6,11 @@ cd "$(dirname "$BASH_SOURCE")" # Load helpers source "./test_helpers.sh" +[ -n "$CC" ] && "$CC" --version +[ -n "$CXX" ] && "$CXX" --version +[ -n "$FC" ] && "$FC" --version +$c --version + # Run tests source ./argument_and_link_test/test.sh source ./complex_arguments/test.sh