Skip to content

Commit

Permalink
test: adds a set of tests for different triggers
Browse files Browse the repository at this point in the history
  • Loading branch information
cristianoliveira committed Jun 12, 2023
1 parent 5de6cb1 commit a28351a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 16 deletions.
6 changes: 0 additions & 6 deletions src/cli/watch_non_block.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
extern crate notify;

use std::sync::mpsc::channel;
use std::sync::mpsc::TryRecvError;

use self::notify::{DebouncedEvent, RecommendedWatcher, RecursiveMode, Watcher};
use std::time::Duration;

use cli::Command;
use stdout;
use watcher;
Expand Down
24 changes: 14 additions & 10 deletions tests/integration/specs/watch-command-test.sh
Original file line number Diff line number Diff line change
@@ -1,29 +1,33 @@
#!/usr/bin/env bash
source "$HELPERS"

# skip if in CI
if [ -n "$CI" ]; then
echo "skipping watch-command-test.sh in CI no trigger is possible"
exit 0
fi

test "it watches the configured rules"

echo "
- name: run simple command
run: echo 'test1'
change: \"$WORKDIR/**\"
- name: run different command
run: echo '__placeholder__' | sed s/placeholder/second_commmand/g
change: \"$WORKDIR/**\"
" > $WORKDIR/.onwatch.yaml

touch $WORKDIR/test.txt
touch $WORKDIR/output.txt
# $TEST_DIR/funzzy --config $WORKDIR/.onwatch.yaml &
$TEST_DIR/funzzy watch --config $WORKDIR/.onwatch.yaml >> $WORKDIR/output.txt &
"$TEST_DIR"/funzzy watch \
--config "$WORKDIR"/.onwatch.yaml >> "$WORKDIR"/output.txt &
FUNZZY_PID=$!

echo "test" >> $WORKDIR/test.txt
wait_for_file "$WORKDIR/output.txt"
sh -c "vi +%s/test/foo/g +wq $WORKDIR/test.txt -u NONE"
assert_file_contains "$WORKDIR/output.txt" "echo 'test1'"

echo "some content" > "$WORKDIR"/test.txt

touch "$WORKDIR"/test.txt
assert_file_occurrencies "$WORKDIR/output.txt" "__second_commmand__" 1

touch "$WORKDIR"/test.txt
assert_file_occurrencies "$WORKDIR/output.txt" "__second_commmand__" 2

cleanup

0 comments on commit a28351a

Please sign in to comment.