Skip to content

Commit

Permalink
recwatch: Fix watching newly created files on macOS
Browse files Browse the repository at this point in the history
Fixes: #33
  • Loading branch information
Johan Bloemberg authored and purpleidea committed Feb 22, 2018
1 parent 318fe4a commit 9544ab2
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 36 deletions.
5 changes: 2 additions & 3 deletions docs/quick-start-guide.md
Expand Up @@ -134,9 +134,8 @@ discouraged either). Meaning it might work but in the case it doesn't you would
have to provide your own patches to fix problems (the project maintainer and
community are glad to assist where needed).

There are currently some issues that make `mgmt` less suitable to run for
provisioning macOS (eg: [https://github.com/purpleidea/mgmt/issues/33](https://github.com/purpleidea/mgmt/issues/33)).
But as a client to provision remote servers it should run fine.
There are currently some issues that make `mgmt` less suitable to run for provisioning
macOS. But as a client to provision remote servers it should run fine.

Since the primary supported systems are Linux and these are the environments
tested for it is wise to run these suites during macOS development as well. To
Expand Down
2 changes: 1 addition & 1 deletion misc/make-deps.sh
Expand Up @@ -47,7 +47,7 @@ if [ ! -z "$APT" ]; then
fi

if [ ! -z "$BREW" ]; then
# coreutils contains gtimeout
# coreutils contains gtimeout, gstat, etc
$BREW install libvirt augeas coreutils || true
fi

Expand Down
4 changes: 2 additions & 2 deletions recwatch/recwatch.go
Expand Up @@ -159,8 +159,8 @@ func (obj *RecWatcher) Watch() error {
if obj.Flags.Debug {
log.Printf("watcher.Add(%s): Error: %v", current, err)
}

if err == syscall.ENOENT {
// ENOENT for linux, etc and IsNotExist for macOS
if err == syscall.ENOENT || os.IsNotExist(err) {
index-- // usually not found, move up one dir
index = int(math.Max(1, float64(index)))
continue
Expand Down
12 changes: 4 additions & 8 deletions test/shell/file-mode.sh
@@ -1,13 +1,9 @@
#!/bin/bash -e

if [[ $(uname) == "Darwin" ]] ; then
# https://github.com/purpleidea/mgmt/issues/33
echo "This test is broken on macOS, skipping!"
exit
fi

set -x

. ../util.sh

# run till completion
$timeout --kill-after=60s 55s "$MGMT" run --yaml file-mode.yaml --converged-timeout=5 --no-watch --tmp-prefix &
pid=$!
Expand All @@ -19,7 +15,7 @@ ls -l /tmp/mgmt
test -e /tmp/mgmt/f1
test -e /tmp/mgmt/f2
test -e /tmp/mgmt/f3
test $(stat -c%a /tmp/mgmt/f2) = 741
test $(stat -c%a /tmp/mgmt/f3) = 614
test $($STAT -c%a /tmp/mgmt/f2) = 741
test $($STAT -c%a /tmp/mgmt/f3) = 614

exit $e
6 changes: 0 additions & 6 deletions test/shell/file-move.sh
@@ -1,11 +1,5 @@
#!/bin/bash -e

if [[ $(uname) == "Darwin" ]] ; then
# https://github.com/purpleidea/mgmt/issues/33
echo "This test is broken on macOS, skipping!"
exit
fi

mkdir -p /tmp/mgmt/
rm /tmp/mgmt/f1 || true

Expand Down
5 changes: 1 addition & 4 deletions test/shell/load0.sh
@@ -1,6 +1,6 @@
#!/bin/bash -e

if env | grep -q -e '^TRAVIS=true$' && [[ $(uname) == "Darwin" ]]; then
if env | grep -q -e '^TRAVIS=true$'; then
# loadavg glibc calls don't seem to work properly on osx OS in travis
echo "Travis and Jenkins give wonky results here, skipping test!"
exit
Expand All @@ -18,9 +18,6 @@ regex="load average: [0-9]\,[0-9]{3,}, [0-9]\,[0-9]{3,}, [0-9]\,[0-9]{3,}"

tmpdir="$($mktemp --tmpdir -d tmp.XXX)"

# macOS workaround https://github.com/purpleidea/mgmt/issues/33
touch "$tmpdir/loadavg"

cat > "$tmpdir/load0.mcl" <<EOF
\$theload = load()
Expand Down
6 changes: 0 additions & 6 deletions test/shell/prometheus-3.sh
@@ -1,11 +1,5 @@
#!/bin/bash -e

if [[ $(uname) == "Darwin" ]] ; then
# https://github.com/purpleidea/mgmt/issues/33
echo "This test is broken on macOS, skipping!"
exit
fi

# run a graph, with prometheus support
$timeout --kill-after=60s 55s "$MGMT" run --tmp-prefix --no-pgp --prometheus --yaml prometheus-3.yaml &
pid=$!
Expand Down
6 changes: 0 additions & 6 deletions test/shell/prometheus-4.sh
@@ -1,11 +1,5 @@
#!/bin/bash -xe

if [[ $(uname) == "Darwin" ]] ; then
# https://github.com/purpleidea/mgmt/issues/33
echo "This test is broken on macOS, skipping!"
exit
fi

# run a graph, with prometheus support
$timeout --kill-after=60s 55s "$MGMT" run --tmp-prefix --no-pgp --prometheus --yaml prometheus-4.yaml &
pid=$!
Expand Down
2 changes: 2 additions & 0 deletions test/util.sh
Expand Up @@ -11,9 +11,11 @@ export MGMT="$ROOT/mgmt"
if [[ $(uname) == "Darwin" ]] ; then
export timeout="gtimeout"
export mktemp="gmktemp"
export STAT="gstat"
else
export timeout="timeout"
export mktemp="mktemp"
export STAT="stat"
fi

fail_test()
Expand Down

0 comments on commit 9544ab2

Please sign in to comment.