commit - c690e7b81fb4ca88ebe7970f8f6fa6d30f8438da
commit + 5395451f9420a5190afab8926d91ed814f8408d0
blob - 5683696daa291398786336627041302aeb81e24c
blob + 1ca5191228279b55ba69e8a1fb70cde27f5a2b38
--- exercise
+++ exercise
set counters {total 0 run 0 ok 0 fail 0 error 0}
# handle command line options
- set u {[-q] [-p k=pattern] [path ...]}
+ set u {[-q] [-C dir] [-p k=pattern] [path ...]}
set prog [file tail $::argv0]
- while {[getopt argv {d:p:qs:} opt arg]} {
+ while {[getopt argv {C:d:p:qs:} opt arg]} {
if {$opt eq "?"} {
puts stderr "usage: $prog $u"
exit 1
}
set argc [llength $argv]
+ # change into workdir if requested with -C
+ if {[info exists opts(-C)]} {cd $opts(-C)}
+
set paths [expr {$argc == 0 ? "." : $argv}]
set files [find_files $paths]
blob - 6b78f371dccf9a58e21afaf1d2df6c56e02de7ef
blob + 94fe3054ac1de2ddfbfa65ac7734fb269da87803
--- tests/assert-exercise
+++ tests/assert-exercise
d=`dirname $0`
exe=$d/../exercise
test -z "$tst" && tst=$1.tst
+test -z "$pth" && pth=$tst
out=$1.out
err=$1.err
expout=$1.expout
# execute & compare
shift 3
-$exe "$@" $tst 1>$out 2>$err
+$exe "$@" $pth 1>$out 2>$err
test "$?" = "127" && exit 127
diff -u $experr $err >&2 && \
diff -u $expout $out >&2
blob - /dev/null
blob + 5e3466d53e264631da66f0799bb4d41be4958c5a (mode 755)
--- /dev/null
+++ tests/flag-C.t
+#!/bin/sh
+
+set -e
+
+wd=$0.wd
+trap "rmdir $wd" EXIT
+mkdir $wd
+
+d=`dirname $0`
+$d/assert-exercise $wd/foo \
+ "total 1 run 1 ok 1 fail 0 error 0\n" \
+ '' \
+ <<EOF
+#!/bin/sh
+ # (sanity check base case)
+ # found as $wd/foo.tst
+ # called as $wd/foo.tst from outside $wd
+ exit 0
+EOF
+$d/assert-exercise $wd/foo \
+ "total 1 run 1 ok 0 fail 0 error 1\n" \
+ "$wd/foo.tst: no such file or directory\nerror $wd/foo.tst\n\n" \
+ -C $wd <<EOF
+#!/bin/sh
+ # not found as $wd/foo.tst from within $wd
+ exit 0
+EOF
+pth=foo.tst $d/assert-exercise $wd/foo \
+ "total 1 run 1 ok 1 fail 0 error 0\n" \
+ '' \
+ -C $wd <<EOF
+#!/bin/sh
+ # found as foo.tst
+ # called as foo.tst from within $wd
+ test -f foo.tst
+EOF