Merge branch 'bugfix-109-spaces'

notifyignore
Dave Musicant (home machine) 1 year ago
commit 29fc305f02

@ -22,7 +22,7 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: 0
@ -59,9 +59,10 @@ jobs:
timeout-minutes: 5
steps:
- name: Setup node
uses: actions/setup-node@v3
- name: Setup BATS
# Even though this says 1.2.0,it's actually using 1.2.1
uses: mig4/setup-bats@v1.2.0
run: sudo npm install -g bats
- name: Install gitwatch dependencies
shell: bash
@ -79,7 +80,10 @@ jobs:
fi
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v3
# - name: Setup upterm session
# uses: lhotari/action-upterm@v1
- name: Run tests
shell: bash
@ -87,3 +91,8 @@ jobs:
git config --global user.email "test@email.com"
git config --global user.name "test user"
bats -rt tests
#bats -rt othertests
echo "Finished running tests"
- name: Test step
run: echo "Now at test step"

@ -0,0 +1,36 @@
#!/usr/bin/env bats
# This inserts customs setup and teardown because of spaces in the file name
load startup-shutdown-spaces
function spaces_in_target_dir { #@test
# Start up gitwatch with logging, see if works
"${BATS_TEST_DIRNAME}"/../gitwatch.sh -l 10 "$testdir/local/rem with spaces" 3>&- &
echo "Testdir: $testdir" >&3
GITWATCH_PID=$!
# Keeps kill message from printing to screen
disown
# Create a file, verify that it hasn't been added yet, then commit
cd "rem with spaces"
# According to inotify documentation, a race condition results if you write
# to directory too soon after it has been created; hence, a short wait.
sleep 1
echo "line1" >> file1.txt
# Wait a bit for inotify to figure out the file has changed, and do its add,
# and commit
sleep "$WAITTIME"
# Make a new change
echo "line2" >> file1.txt
sleep "$WAITTIME"
# Check commit log that the diff is in there
run git log -1 --oneline
[[ $output == *"file1.txt"* ]]
}

@ -0,0 +1,41 @@
# This inserts customs setup and teardown because of spaces in the file name
setup() {
# Time to wait for gitwatch to respond
# shellcheck disable=SC2034
WAITTIME=4
# Set up directory structure and initialize remote
testdir=$(mktemp -d "/tmp/temp space.XXXXX")
# shellcheck disable=SC2164
cd "$testdir"
mkdir remote
# shellcheck disable=SC2164
cd remote
git init -q --bare
# shellcheck disable=SC2103
cd ..
# shellcheck disable=SC2164
mkdir local
# shellcheck disable=SC2164
cd local
git clone -q ../remote "rem with spaces"
}
teardown() {
echo '# Teardown started' >&3
# Remove testing directories
# shellcheck disable=SC2164
cd /tmp
# Kill background process
kill -9 %1
fg
# Also make sure to kill fswatch if on Mac
killall fswatch
# Make sure gitwatch script gets killed if script stopped background
# Must kill the entire tree of processes generated
pkill -15 -P "$GITWATCH_PID"
echo '# Teardown complete' >&3
}

@ -20,13 +20,20 @@ setup() {
}
teardown() {
echo '# Teardown started' >&3
# Remove testing directories
# shellcheck disable=SC2164
cd /tmp
# rm -rf $testdir
# Kill background process
kill -9 %1
fg
# Also make sure to kill fswatch if on Mac
killall fswatch
# Make sure gitwatch script gets killed if script stopped background
# Must kill the entire tree of processes generated
pkill -15 -P "$GITWATCH_PID"
echo '# Teardown complete' >&3
}

Loading…
Cancel
Save