Skip to content

Commit

Permalink
tests: adds test case for list of commands (#56)
Browse files Browse the repository at this point in the history
  • Loading branch information
cristianoliveira committed May 22, 2023
1 parent 0598ad2 commit 234d7cc
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tests/integration/runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ PATH=$PATH:tests/integration
$TEST_DIR/funzzy --version
$TEST_DIR/funzzy --help

## if path received as argument, run only that test
if [ -n "$1" ]; then
echo "Running only $1"
bash "$1" && echo "result: passed" || exit 1
echo "----------------------------"
exit 0
fi

for spec in $TEST_DIR/specs/*; do
echo "Running $spec"
bash "$spec" && echo "result: passed" || exit 1
Expand Down
48 changes: 48 additions & 0 deletions tests/integration/specs/multiple-commands-same-task-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/usr/bin/env bash
source "$HELPERS"

test "it a list of commands for the same task (on init)"

echo "
- name: run complex command
run: ['echo first', 'echo second', 'echo complex | sed s/complex/third/g']
change: \"$WORKDIR/**\"
run_on_init: true
" > $WORKDIR/.oninit.yaml

funzzy --config $WORKDIR/.oninit.yaml > $WORKDIR/output.txt &
FUNZZY_PID=$!

assert_file_contains "$WORKDIR/output.txt" "running: echo first"
assert_file_contains "$WORKDIR/output.txt" "running: echo second"
assert_file_contains "$WORKDIR/output.txt" "running: echo complex"
assert_file_contains "$WORKDIR/output.txt" "third"
assert_file_contains "$WORKDIR/output.txt" "Watching..."

cleanup

if [ -n "$CI" ]; then
echo "Skipping test for CI"
exit 0
fi

test "it a list of commands for the same task (on change)"

echo "
- name: run complex command
run: ['echo 100', 'echo 200', 'echo 4000 | sed s/4000/3333/g']
change: \"$WORKDIR/**\"
" > $WORKDIR/.oninit.yaml

funzzy --config $WORKDIR/.oninit.yaml > $WORKDIR/output.txt &
FUNZZY_PID=$!

assert_file_contains "$WORKDIR/output.txt" "Watching..."
echo "test" >> $WORKDIR/test.txt
sh -c "vi +%s/test/foo/g +wq $WORKDIR/test.txt -u NONE"
assert_file_contains "$WORKDIR/output.txt" "running: echo 100"
assert_file_contains "$WORKDIR/output.txt" "running: echo 200"
assert_file_contains "$WORKDIR/output.txt" "running: echo 4000"
assert_file_contains "$WORKDIR/output.txt" "3333"

cleanup

0 comments on commit 234d7cc

Please sign in to comment.