Skip to content

Commit

Permalink
github ci: also, only execute if binary compiled; some exit code tuning
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanmjacobs committed Sep 17, 2023
1 parent 31156a6 commit f171c8d
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 14 deletions.
16 changes: 16 additions & 0 deletions .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 }}
6 changes: 0 additions & 6 deletions .travis.yml

This file was deleted.

13 changes: 9 additions & 4 deletions c
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions tests/shell/test.sh
Expand Up @@ -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"
Expand All @@ -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=$?
Expand Down
5 changes: 5 additions & 0 deletions tests/test.sh
Expand Up @@ -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
Expand Down

0 comments on commit f171c8d

Please sign in to comment.