Skip to content

Commit 6881485

Browse files
committed
ci: add a simple test that the invocations actually pass
It is embarrassing that none of the tests caught the option parsing failure merged in the last patch. Let's add at least a simple script that calls the compiled binary. We can always add something more elaborate later.
1 parent 281ad29 commit 6881485

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ jobs:
4747
run: make program CARGOFLAGS="--verbose"
4848
- name: Run tests
4949
run: make check CARGOFLAGS="--verbose"
50+
- name: Check program invocation
51+
run: tests/test-invocations.sh target/release/zram-generator
5052

5153
rustfmt:
5254
name: rustfmt

tests/test-invocations.sh

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# SPDX-License-Identifier: MIT
2+
set -e
3+
4+
program=${1:?}
5+
6+
dir=$(mktemp -d 'zram-test.XXXXXX')
7+
trap 'rm -r $dir' EXIT
8+
9+
set -x
10+
11+
$program --help
12+
$program --version
13+
14+
# This should pass
15+
mkdir $dir/{a,b,c}
16+
$program $dir/{a,b,c}
17+
18+
# Those should fail with option parsing error (2)
19+
set +e
20+
$program dir1 dir2 dir3 dir4
21+
ret=$?
22+
set -e
23+
test $ret -eq 2
24+
25+
set +e
26+
$program dir1 --setup-device
27+
ret=$?
28+
set -e
29+
test $ret -eq 2
30+
31+
# Those should fail because the device doesn't exist (1)
32+
set +e
33+
$program --setup-device /no/such/file/or/directory
34+
ret=$?
35+
set -e
36+
test $ret -eq 1
37+
38+
set +e
39+
$program --reset-device /no/such/file/or/directory
40+
ret=$?
41+
set -e
42+
test $ret -eq 1

0 commit comments

Comments
 (0)