aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Unterwurzacher2021-06-26 19:12:52 +0200
committerJakob Unterwurzacher2021-06-26 19:13:24 +0200
commitad3eeaedc5a9042682f236f43dd939b2e620d07c (patch)
tree2b0f99d8ed27e303679e6562fb67c94bb53dd34f
parent446c3d7e931747cd833ae6211a3742cb9d02578b (diff)
tests, maxlen.bash: speed up TestMaxlen using QUICK=1
From >6 to <1 second.
-rwxr-xr-xcontrib/maxlen.bash37
-rw-r--r--tests/defaults/main_test.go5
2 files changed, 25 insertions, 17 deletions
diff --git a/contrib/maxlen.bash b/contrib/maxlen.bash
index 14d40da..99ffb1f 100755
--- a/contrib/maxlen.bash
+++ b/contrib/maxlen.bash
@@ -32,25 +32,36 @@ while true ; do
echo "error: file $PWD/$NEXT already exists"
exit 1
fi
- touch $NEXT 2> /dev/null || break
+ echo -n 2> /dev/null > $NEXT || break
rm $NEXT
NAME="$NEXT"
done
echo "${#NAME}"
-echo -n " Maximum dirname length: "
-# Add one character at a time until we hit an error
-NAME=""
-while true ; do
- NEXT="${NAME}x"
- mkdir $NEXT 2> /dev/null || break
- rmdir $NEXT
- NAME="$NEXT"
-done
-MAX_DIRNAME=${#NAME}
-echo "${#NAME}"
+# Set to 0 if undefined
+: ${QUICK:=0}
+
+if [[ $QUICK -ne 1 ]]; then
+ echo -n " Maximum dirname length: "
+ # Add one character at a time until we hit an error
+ NAME=""
+ while true ; do
+ NEXT="${NAME}x"
+ mkdir $NEXT 2> /dev/null || break
+ rmdir $NEXT
+ NAME="$NEXT"
+ done
+ MAX_DIRNAME=${#NAME}
+ echo "${#NAME}"
+fi
+
+if [[ $QUICK -eq 1 ]]; then
+ CHARS_TODO=100
+else
+ CHARS_TODO="1 10 100 $MAX_DIRNAME"
+fi
-for CHARS_PER_SUBDIR in 1 10 100 $MAX_DIRNAME ; do
+for CHARS_PER_SUBDIR in $CHARS_TODO ; do
echo -n " Maximum path length with $(printf %3d $CHARS_PER_SUBDIR) chars per subdir: "
if [[ $INTERACTIVE -eq 1 ]] ; then
echo -n " "
diff --git a/tests/defaults/main_test.go b/tests/defaults/main_test.go
index 4e5ffea..b356f41 100644
--- a/tests/defaults/main_test.go
+++ b/tests/defaults/main_test.go
@@ -380,6 +380,7 @@ func TestMaxlen(t *testing.T) {
t.Fatal(err)
}
cmd := exec.Command("../../contrib/maxlen.bash", workDir)
+ cmd.Env = []string{"QUICK=1"}
out, err := cmd.CombinedOutput()
if err != nil {
t.Log(string(out))
@@ -387,11 +388,7 @@ func TestMaxlen(t *testing.T) {
}
want := `
Maximum filename length: 255
- Maximum dirname length: 255
- Maximum path length with 1 chars per subdir: 4095
- Maximum path length with 10 chars per subdir: 4095
Maximum path length with 100 chars per subdir: 4095
- Maximum path length with 255 chars per subdir: 4095
`
if !strings.HasSuffix(string(out), want) {
t.Errorf("wrong output: %s", string(out))