summaryrefslogtreecommitdiff
path: root/tests/factor/run.sh
diff options
context:
space:
mode:
authorBernhard Voelker <mail@bernhard-voelker.de>2012-10-27 13:24:18 +0200
committerJim Meyering <jim@meyering.net>2012-10-27 17:39:17 +0200
commit1cace4a832fe57a45d87b0579607c4d236cce457 (patch)
tree59813a1fa54f590e51fda3c1cb5f90733c98a2f5 /tests/factor/run.sh
parent48536bfe8f7fe1d41d8ca71dc51c0550adb3b89a (diff)
downloadcoreutils-1cace4a832fe57a45d87b0579607c4d236cce457.tar.xz
tests: shorten factor's inordinately-long test file names
Besides what the subject says, this commit moves the test data for the factor tests from tests/local.mk into the directory tests/factor/ where it belongs. * tests/local.mk (EXTRA_DIST): Add new tests/factor/create-test.sh. (p,q,t1,t2) Factor out the factor-related magic numbers. (factor_tests): Rename the test names to t{00..36}.sh. Factor out the triples of test data. ($(factor_tests)): Add dependency to new tests/factor/create-factor.sh. Call that script to generate the test scripts. * tests/factor/run.sh: Turn this script into a template, and therefore remove it's executable permission bit. Add template variables START, END and CKSUM, replacing the code to split the test data from the test script's file name. Use the new template variables in the call to seq and for creating the exp file. * tests/factor/create-test.sh: Add new script to create the test scripts from the template tests/factor/run.sh. Use test data and magic numbers factored out from the above files. Let the script also change the __TEMPLATE__ line in run.sh to make clear that the test scripts are generated. * cfg.mk (sc_tests_list_consistency): Exempt the new test. (exclude_file_name_regexp--sc_prohibit_test_backticks): Likewise. Improved-by: Stefano Lattarini Improved by: Jim Meyering
Diffstat (limited to 'tests/factor/run.sh')
-rw-r--r--[-rwxr-xr-x]tests/factor/run.sh22
1 files changed, 12 insertions, 10 deletions
diff --git a/tests/factor/run.sh b/tests/factor/run.sh
index 6ff24c370..33ec8cd69 100755..100644
--- a/tests/factor/run.sh
+++ b/tests/factor/run.sh
@@ -1,11 +1,14 @@
#!/bin/sh
+
+# === THIS IS A __TEMPLATE__ ===
+
# Test the factor rewrite.
-# Expect to be invoked via a file whose basename matches
-# /^(\d+)\-(\d+)\-([\da-f]{40})\.sh$/
# The test is to run this command
-# seq $1 $2 | factor | shasum -c --status <(echo $3 -)
+# seq $START $END | factor | shasum -c --status <(echo $CKSUM -)
# I.e., to ensure that the factorizations of integers $1..$2
# match what we expect.
+#
+# See: tests/factor/create-test.sh
# Copyright (C) 2012 Free Software Foundation, Inc.
@@ -16,15 +19,14 @@ very_expensive_
print_ver_ factor seq
-# Remove the ".sh" suffix:
-t=${ME_%.sh}
+# Template variables.
+START=__START__
+ END=__END__
+CKSUM=__CKSUM__
-# Make IFS include "-", so that a simple "set" will separate the args:
-IFS=-$IFS
-set $t
-echo "$3 -" > exp
+echo "$CKSUM -" > exp
f=1
-seq $1 $2 | factor | shasum -c --status exp && f=0
+seq $START $END | factor | shasum -c --status exp && f=0
Exit $f