aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2019-09-15 17:11:37 -0500
committerRob Landley <rob@landley.net>2019-09-15 17:11:37 -0500
commit766b0689d7028b5e1dc83e2c62f0da0aa7fa80d5 (patch)
treea06918c31c0c93842abad660b0ef506c9d851fa7
parent0e00010064a39c1f915d894ccc1fa7a8086c0a8b (diff)
downloadtoybox-766b0689d7028b5e1dc83e2c62f0da0aa7fa80d5.tar.gz
Move mktemp.test comments into test descriptions.
-rwxr-xr-xtests/mktemp.test59
1 files changed, 20 insertions, 39 deletions
diff --git a/tests/mktemp.test b/tests/mktemp.test
index 1e0aa9d8..9715be5d 100755
--- a/tests/mktemp.test
+++ b/tests/mktemp.test
@@ -4,42 +4,23 @@
#testing "name" "command" "result" "infile" "stdin"
-# mktemp by default should use tmp.XXXXXXXXXX as the template,
-# and $TMPDIR as the directory.
-testing "default" "TMPDIR=. mktemp | grep -q '^./tmp\...........$' && echo yes" "yes\n" "" ""
-
-# Test that -d creates a directory and the default is a file.
-testing "dir" "test -d `TMPDIR=. mktemp -d` && echo yes" "yes\n" "" ""
-testing "file" "test -f `TMPDIR=. mktemp` && echo yes" "yes\n" "" ""
-
-# mktemp with a template should *not* use $TMPDIR.
-testing "TEMPLATE" "TMPDIR=/t mktemp -u hello.XXXXXXXX | grep -q '^hello\.........$' && echo yes" "yes\n" "" ""
-
-# mktemp with a template that includes a '/' should ignore $TMPDIR
-testing "/ TEMPLATE" "TMPDIR=/t mktemp -u /x/hello.XXXXXXXX | grep -q '^/x/hello\.........$' && echo yes" "yes\n" "" ""
-# ...and setting DIR is an error.
-testing "/ TEMPLATE -p DIR" "TMPDIR=/t mktemp -p DIR -u /x/hello.XXXXXXXX 2>/dev/null || echo error" "error\n" "" ""
-
-# mktemp with -t and a template should use $TMPDIR.
-testing "-t TEMPLATE" "TMPDIR=/t mktemp -u -t hello.XXXXXXXX | grep -q '^/t/hello\.........$' && echo yes" "yes\n" "" ""
-
-# mktemp with -t and a template should use $TMPDIR ... or /tmp if no $TMPDIR.
-testing "-t TEMPLATE but no TMPDIR" "TMPDIR= mktemp -u -t hello.XXXXXXXX | grep -q '^/tmp/hello\.........$' && echo yes" "yes\n" "" ""
-
-# mktemp with -p DIR and a template should use DIR.
-testing "-p DIR TEMPLATE" "TMPDIR=/t mktemp -u -p DIR hello.XXXXXXXX | grep -q '^DIR/hello\.........$' && echo yes" "yes\n" "" ""
-
-# mktemp -p DIR and -t: -t wins.
-testing "-p DIR -t TEMPLATE" "TMPDIR=/t mktemp -u -p DIR -t hello.XXXXXXXX | grep -q '^/t/hello\.........$' && echo yes" "yes\n" "" ""
-
-# mktemp -p DIR and -t but no $TMPDIR: DIR wins.
-testing "-p DIR -t TEMPLATE but no TMPDIR" "TMPDIR= mktemp -u -p DIR -t hello.XXXXXXXX | grep -q '^DIR/hello\.........$' && echo yes" "yes\n" "" ""
-
-# mktemp -u doesn't need to be able to write to the directory.
-testing "-u" "mktemp -u -p /proc | grep -q '^/proc/tmp\...........$' && echo yes" "yes\n" "" ""
-
-# mktemp needs at least XX in the template.
-testing "bad template" "mktemp -u helloX 2>/dev/null || echo error" "error\n" "" ""
-
-# mktemp -q shouldn't print the path.
-testing "-q" "mktemp -p /proc -q || echo only-failure" "only-failure\n" "" ""
+testing "default template uses \$TMPDIR" "TMPDIR=. mktemp | grep -q '^./tmp\...........$' && echo yes" "yes\n" "" ""
+testing "default creates file" "test -f `TMPDIR=. mktemp` && echo yes" "yes\n" \
+ "" ""
+testing "-d creates dir" "test -d `TMPDIR=. mktemp -d` && echo yes" "yes\n" \
+ "" ""
+testing "TEMPLATE does not use \$TMPDIR" "TMPDIR=/t mktemp -u hello.XXXXXXXX | grep -q '^hello\.........$' && echo yes" "yes\n" "" ""
+testing "/ in TEMPLATE works but ignores \$TMPDIR" "TMPDIR=/t mktemp -u /x/hello.XXXXXXXX | grep -q '^/x/hello\.........$' && echo yes" "yes\n" "" ""
+testing "/ in TEMPLATE with -p DIR is error" "TMPDIR=/t mktemp -p DIR -u /x/hello.XXXXXXXX 2>/dev/null || echo error" "error\n" "" ""
+testing "-t TEMPLATE uses \$TMPDIR" "TMPDIR=/t mktemp -u -t hello.XXXXXXXX | grep -q '^/t/hello\.........$' && echo yes" "yes\n" "" ""
+testing "-t and TEMPLATE but no \$TMPDIR uses /tmp" "TMPDIR= mktemp -u -t hello.XXXXXXXX | grep -q '^/tmp/hello\.........$' && echo yes" "yes\n" "" ""
+testing "-p DIR and TEMPLATE should use DIR" "TMPDIR=/t mktemp -u -p DIR hello.XXXXXXXX | grep -q '^DIR/hello\.........$' && echo yes" "yes\n" "" ""
+testing "-p DIR and -t: -t wins" "TMPDIR=/t mktemp -u -p DIR -t hello.XXXXXXXX | grep -q '^/t/hello\.........$' && echo yes" "yes\n" "" ""
+testing "-p DIR -t TEMPLATE but no \$TMPDIR (DIR wins)" "TMPDIR= mktemp -u -p DIR -t hello.XXXXXXXX | grep -q '^DIR/hello\.........$' && echo yes" "yes\n" "" ""
+testing "-u doesn't need to be able to write to dir" \
+ "mktemp -u -p /proc | grep -q '^/proc/tmp\...........$' && echo yes" "yes\n" \
+ "" ""
+testing "needs at least XX in template" \
+ "mktemp -u helloX 2>/dev/null || echo error" "error\n" "" ""
+testing "-q shouldn't print path" \
+ "mktemp -p /proc -q || echo only-failure" "only-failure\n" "" ""