From df44dc54a2021229070b2271e876675496fd125d Mon Sep 17 00:00:00 2001 From: Avery Pennarun Date: Tue, 4 Dec 2018 00:07:23 -0500 Subject: [PATCH] jwack: _cheatfds error when run from toplevel make -j. Also added a new unit test to confirm that 'make' behaviour works as expected, with and without parallelism. --- jwack.py | 5 +++-- minimal/do | 3 ++- t/203-make/.gitignore | 2 ++ t/203-make/Makefile | 8 ++++++++ t/203-make/all.do | 20 ++++++++++++++++++++ t/203-make/clean.do | 1 + t/203-make/default.out.do | 1 + t/203-make/whichmake.do | 16 ++++++++++++++++ t/203-make/wipe-redo.sh | 13 +++++++++++++ t/203-make/x.do | 1 + t/203-make/y.do | 1 + 11 files changed, 68 insertions(+), 3 deletions(-) create mode 100644 t/203-make/.gitignore create mode 100644 t/203-make/Makefile create mode 100644 t/203-make/all.do create mode 100644 t/203-make/clean.do create mode 100644 t/203-make/default.out.do create mode 100644 t/203-make/whichmake.do create mode 100644 t/203-make/wipe-redo.sh create mode 100644 t/203-make/x.do create mode 100644 t/203-make/y.do diff --git a/jwack.py b/jwack.py index 9d5cc6a..8e7852f 100644 --- a/jwack.py +++ b/jwack.py @@ -235,6 +235,9 @@ def setup(maxjobs): if a <= 0 or b <= 0: raise ValueError('invalid REDO_CHEATFDS: %r' % cheats) _cheatfds = (a, b) + else: + _cheatfds = _make_pipe(102) + os.putenv('REDO_CHEATFDS', '%d,%d' % (_cheatfds[0], _cheatfds[1])) if not _tokenfds: # need to start a new server @@ -247,8 +250,6 @@ def setup(maxjobs): (os.getenv('MAKEFLAGS', ''), _tokenfds[0], _tokenfds[1], _tokenfds[0], _tokenfds[1])) - _cheatfds = _make_pipe(102) - os.putenv('REDO_CHEATFDS', '%d,%d' % (_cheatfds[0], _cheatfds[1])) def _wait(want_token, max_delay): diff --git a/minimal/do b/minimal/do index e603cfb..0d9a5ef 100755 --- a/minimal/do +++ b/minimal/do @@ -54,12 +54,13 @@ if [ -z "$DO_BUILT" ]; then export _do_opt_verbose= export _do_opt_clean= fi -while getopts 'dxvch?' _opt; do +while getopts 'dxvcj:h?' _opt; do case $_opt in d) _do_opt_debug=1 ;; x) _do_opt_exec=x ;; v) _do_opt_verbose=v ;; c) _do_opt_clean=1 ;; + j) ;; # silently ignore, for compat with real redo \?|h|*) printf "%s" "$USAGE" >&2 exit 99 ;; diff --git a/t/203-make/.gitignore b/t/203-make/.gitignore new file mode 100644 index 0000000..038beb4 --- /dev/null +++ b/t/203-make/.gitignore @@ -0,0 +1,2 @@ +*.out +whichmake diff --git a/t/203-make/Makefile b/t/203-make/Makefile new file mode 100644 index 0000000..8a5665a --- /dev/null +++ b/t/203-make/Makefile @@ -0,0 +1,8 @@ +default: + +x: + +redo x1.out x2.out + +y: + +redo x + +redo y1.out y2.out diff --git a/t/203-make/all.do b/t/203-make/all.do new file mode 100644 index 0000000..3b2c06f --- /dev/null +++ b/t/203-make/all.do @@ -0,0 +1,20 @@ +exec >&2 +redo-ifchange whichmake + +run() { + rm -f *.out + ./whichmake y + + rm -f *.out + ./whichmake -j10 y + + rm -f *.out + redo y + + rm -f *.out + redo -j10 y +} + +run +. ./wipe-redo.sh +run diff --git a/t/203-make/clean.do b/t/203-make/clean.do new file mode 100644 index 0000000..bac26b4 --- /dev/null +++ b/t/203-make/clean.do @@ -0,0 +1 @@ +rm -f *~ .*~ *.out whichmake diff --git a/t/203-make/default.out.do b/t/203-make/default.out.do new file mode 100644 index 0000000..7694ba5 --- /dev/null +++ b/t/203-make/default.out.do @@ -0,0 +1 @@ +echo $1 >$3 diff --git a/t/203-make/whichmake.do b/t/203-make/whichmake.do new file mode 100644 index 0000000..2fb86da --- /dev/null +++ b/t/203-make/whichmake.do @@ -0,0 +1,16 @@ +if type gmake >/dev/null 2>/dev/null; then + make=gmake +elif type make >/dev/null 2>/dev/null; then + make=make +else + # No make installed? That's okay, this test + # isn't *that* important. + make=: +fi + +cat >$3 <<-EOF + #!/bin/sh + $make "\$@" +EOF +chmod a+x $3 + diff --git a/t/203-make/wipe-redo.sh b/t/203-make/wipe-redo.sh new file mode 100644 index 0000000..017205e --- /dev/null +++ b/t/203-make/wipe-redo.sh @@ -0,0 +1,13 @@ +vars=$( + env | { + IFS="=" + while read key value; do + if [ "$key" != "${key#REDO}" ] || + [ "$key" != "${key#MAKE}" ]; then + echo "$key" + fi + done + } +) +echo "Wiping vars:" $vars >&2 +unset $vars diff --git a/t/203-make/x.do b/t/203-make/x.do new file mode 100644 index 0000000..afbac79 --- /dev/null +++ b/t/203-make/x.do @@ -0,0 +1 @@ +./whichmake x >&2 diff --git a/t/203-make/y.do b/t/203-make/y.do new file mode 100644 index 0000000..ba85670 --- /dev/null +++ b/t/203-make/y.do @@ -0,0 +1 @@ +./whichmake y >&2