Compare commits
2 commits
a169ebd579
...
3dc0ad8ccf
Author | SHA1 | Date | |
---|---|---|---|
|
3dc0ad8ccf | ||
bef0389ce6 |
3 changed files with 71 additions and 26 deletions
44
.forgejo/workflows/push-next.yml
Normal file
44
.forgejo/workflows/push-next.yml
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
name: Rust
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: ["next"]
|
||||||
|
pull_request:
|
||||||
|
branches: ["main"]
|
||||||
|
|
||||||
|
env:
|
||||||
|
CARGO_TERM_COLOR: always
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: docker
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Format
|
||||||
|
uses: https://git.kemitix.net/kemitix/rust@v0.3.1
|
||||||
|
with:
|
||||||
|
args: fmt --all -- --check
|
||||||
|
|
||||||
|
# - name: Machete
|
||||||
|
# uses: https://github.com/bnjbvr/cargo-machete@v0.6.2
|
||||||
|
|
||||||
|
- name: Clippy
|
||||||
|
uses: https://git.kemitix.net/kemitix/rust@v0.3.1
|
||||||
|
with:
|
||||||
|
args: clippy
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
uses: https://git.kemitix.net/kemitix/rust@v0.3.1
|
||||||
|
with:
|
||||||
|
args: build
|
||||||
|
|
||||||
|
- name: Test
|
||||||
|
uses: https://git.kemitix.net/kemitix/rust@v0.3.1
|
||||||
|
with:
|
||||||
|
args: test --no-fail-fast
|
||||||
|
|
||||||
|
- name: Integration
|
||||||
|
run: ./test.sh
|
|
@ -1,5 +1,5 @@
|
||||||
variables:
|
variables:
|
||||||
- &rust_image "docker.io/rust:1.79.0"
|
- &rust_image "docker.io/rust:1.80.0"
|
||||||
- &slow_check_paths
|
- &slow_check_paths
|
||||||
- path:
|
- path:
|
||||||
# rust source code
|
# rust source code
|
||||||
|
|
51
test.sh
51
test.sh
|
@ -5,37 +5,38 @@ set -e
|
||||||
echo "PWD: $PWD"
|
echo "PWD: $PWD"
|
||||||
ls -l
|
ls -l
|
||||||
ls -l target
|
ls -l target
|
||||||
SKIP="./target/skip"
|
SKIP="./target/debug/skip"
|
||||||
DIFF="diff -u --color"
|
DIFF="diff -u --color"
|
||||||
|
|
||||||
if test ! -x $SKIP ; then
|
if test ! -x $SKIP; then
|
||||||
echo "File missing: $SKIP - try 'cargo build'"
|
echo "File missing: $SKIP - try 'cargo build'"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "> skip a line when reading from stdin"
|
echo "> skip a line when reading from stdin"
|
||||||
INPUT=$(cat<<EOF
|
INPUT=$(
|
||||||
|
cat <<EOF
|
||||||
line 1
|
line 1
|
||||||
line 2
|
line 2
|
||||||
EOF
|
EOF
|
||||||
)
|
)
|
||||||
echo "line 2" > test.expect
|
echo "line 2" >test.expect
|
||||||
echo "$INPUT" | $SKIP 1 > test.out
|
echo "$INPUT" | $SKIP 1 >test.out
|
||||||
$DIFF test.expect test.out
|
$DIFF test.expect test.out
|
||||||
rm test.expect test.out
|
rm test.expect test.out
|
||||||
|
|
||||||
echo "> skip a line when reading from a file"
|
echo "> skip a line when reading from a file"
|
||||||
cat<<EOF > test.in
|
cat <<EOF >test.in
|
||||||
line 1
|
line 1
|
||||||
line 2
|
line 2
|
||||||
EOF
|
EOF
|
||||||
echo "line 2" > test.expect
|
echo "line 2" >test.expect
|
||||||
$SKIP 1 test.in > test.out
|
$SKIP 1 test.in >test.out
|
||||||
$DIFF test.expect test.out
|
$DIFF test.expect test.out
|
||||||
rm test.expect test.out
|
rm test.expect test.out
|
||||||
|
|
||||||
echo "> skip until 2 matching lines seen"
|
echo "> skip until 2 matching lines seen"
|
||||||
cat<<EOF > test.in
|
cat <<EOF >test.in
|
||||||
alpha
|
alpha
|
||||||
beta
|
beta
|
||||||
alpha
|
alpha
|
||||||
|
@ -43,17 +44,17 @@ alpha
|
||||||
gamma
|
gamma
|
||||||
alpha
|
alpha
|
||||||
EOF
|
EOF
|
||||||
cat<<EOF > test.expect
|
cat <<EOF >test.expect
|
||||||
alpha
|
alpha
|
||||||
gamma
|
gamma
|
||||||
alpha
|
alpha
|
||||||
EOF
|
EOF
|
||||||
$SKIP 2 test.in --line alpha > test.out
|
$SKIP 2 test.in --line alpha >test.out
|
||||||
$DIFF test.expect test.out
|
$DIFF test.expect test.out
|
||||||
rm test.in test.expect test.out
|
rm test.in test.expect test.out
|
||||||
|
|
||||||
echo "> skip lines until 2 tokens seen"
|
echo "> skip lines until 2 tokens seen"
|
||||||
cat<<EOF > test.in
|
cat <<EOF >test.in
|
||||||
Lorem ipsum dolor sit amet,
|
Lorem ipsum dolor sit amet,
|
||||||
consectetur adipiscing elit,
|
consectetur adipiscing elit,
|
||||||
sed do eiusmod tempor incididunt
|
sed do eiusmod tempor incididunt
|
||||||
|
@ -63,18 +64,18 @@ quis nostrud exercitation ullamco
|
||||||
laboris nisi ut aliquip ex ea
|
laboris nisi ut aliquip ex ea
|
||||||
commodo consequat.
|
commodo consequat.
|
||||||
EOF
|
EOF
|
||||||
cat<<EOF > test.expect
|
cat <<EOF >test.expect
|
||||||
Ut enim ad minim veniam,
|
Ut enim ad minim veniam,
|
||||||
quis nostrud exercitation ullamco
|
quis nostrud exercitation ullamco
|
||||||
laboris nisi ut aliquip ex ea
|
laboris nisi ut aliquip ex ea
|
||||||
commodo consequat.
|
commodo consequat.
|
||||||
EOF
|
EOF
|
||||||
$SKIP 2 test.in --token dolor > test.out
|
$SKIP 2 test.in --token dolor >test.out
|
||||||
$DIFF test.expect test.out
|
$DIFF test.expect test.out
|
||||||
rm test.in test.expect test.out
|
rm test.in test.expect test.out
|
||||||
|
|
||||||
echo "> handle unknown parameter with simple error message"
|
echo "> handle unknown parameter with simple error message"
|
||||||
cat<<EOF > test.expect.err
|
cat <<EOF >test.expect.err
|
||||||
error: unexpected argument '--foo' found
|
error: unexpected argument '--foo' found
|
||||||
|
|
||||||
tip: to pass '--foo' as a value, use '-- --foo'
|
tip: to pass '--foo' as a value, use '-- --foo'
|
||||||
|
@ -83,17 +84,17 @@ Usage: skip [OPTIONS] <LINES> [FILE]
|
||||||
|
|
||||||
For more information, try '--help'.
|
For more information, try '--help'.
|
||||||
EOF
|
EOF
|
||||||
cat<<EOF > test.expect
|
cat <<EOF >test.expect
|
||||||
EOF
|
EOF
|
||||||
touch test.out test.err
|
touch test.out test.err
|
||||||
$SKIP --foo > test.out 2> test.err || true
|
$SKIP --foo >test.out 2>test.err || true
|
||||||
$DIFF test.expect test.out
|
$DIFF test.expect test.out
|
||||||
$DIFF test.expect.err test.err
|
$DIFF test.expect.err test.err
|
||||||
rm test.expect test.out
|
rm test.expect test.out
|
||||||
rm test.expect.err test.err
|
rm test.expect.err test.err
|
||||||
|
|
||||||
echo "> handle ignore-extra when token is missing"
|
echo "> handle ignore-extra when token is missing"
|
||||||
cat<<EOF > test.expect.err
|
cat <<EOF >test.expect.err
|
||||||
error: the following required arguments were not provided:
|
error: the following required arguments were not provided:
|
||||||
--token <TOKEN>
|
--token <TOKEN>
|
||||||
<LINES>
|
<LINES>
|
||||||
|
@ -102,17 +103,17 @@ Usage: skip --ignore-extras --token <TOKEN> <LINES> [FILE]
|
||||||
|
|
||||||
For more information, try '--help'.
|
For more information, try '--help'.
|
||||||
EOF
|
EOF
|
||||||
cat<<EOF > test.expect
|
cat <<EOF >test.expect
|
||||||
EOF
|
EOF
|
||||||
touch test.out test.err
|
touch test.out test.err
|
||||||
$SKIP --ignore-extras > test.out 2> test.err || true
|
$SKIP --ignore-extras >test.out 2>test.err || true
|
||||||
$DIFF test.expect test.out
|
$DIFF test.expect test.out
|
||||||
$DIFF test.expect.err test.err
|
$DIFF test.expect.err test.err
|
||||||
rm test.expect test.out
|
rm test.expect test.out
|
||||||
rm test.expect.err test.err
|
rm test.expect.err test.err
|
||||||
|
|
||||||
echo "> skip lines until 4 tokens seen - ignored extra tokens on same line"
|
echo "> skip lines until 4 tokens seen - ignored extra tokens on same line"
|
||||||
cat<<EOF > test.in
|
cat <<EOF >test.in
|
||||||
Lorem ipsum dolor sit amet,
|
Lorem ipsum dolor sit amet,
|
||||||
consectetur adipiscing elit,
|
consectetur adipiscing elit,
|
||||||
sed do eiusmod tempor incididunt
|
sed do eiusmod tempor incididunt
|
||||||
|
@ -122,12 +123,12 @@ quis nostrud exercitation ullamco
|
||||||
laboris nisi ut aliquip ex ea
|
laboris nisi ut aliquip ex ea
|
||||||
commodo consequat.
|
commodo consequat.
|
||||||
EOF
|
EOF
|
||||||
cat<<EOF > test.expect
|
cat <<EOF >test.expect
|
||||||
quis nostrud exercitation ullamco
|
quis nostrud exercitation ullamco
|
||||||
laboris nisi ut aliquip ex ea
|
laboris nisi ut aliquip ex ea
|
||||||
commodo consequat.
|
commodo consequat.
|
||||||
EOF
|
EOF
|
||||||
$SKIP 4 test.in --token m --ignore-extras > test.out
|
$SKIP 4 test.in --token m --ignore-extras >test.out
|
||||||
$DIFF test.expect test.out
|
$DIFF test.expect test.out
|
||||||
rm test.in test.expect test.out
|
rm test.in test.expect test.out
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue