aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJade Lovelace <lix@jade.fyi>2024-08-09 23:25:20 -0700
committerJade Lovelace <lix@jade.fyi>2024-08-10 16:11:58 -0700
commitb15d5cc6ee566127a634fcad74fef7e251f17878 (patch)
tree8729edeb00fd7b7734925c1676c8b327f1628157 /tests
parent0c7619535112e19232384e15e82ffa6a5af7569d (diff)
nix: remove explosions if you have a window size less than four
Turns out strings do not like being resized to -4. This was discovered while messing with the tests to remove unbuffer and trying stdbuf instead. Turns out that was not the right approach. This basically rewrites the handling of this case to be much more correct, and fixes a bug where with small window sizes where it would ALSO truncate the attr names in addition to the optional descriptions. Change-Id: Ifd1beeaffdb47cbb5f4a462b183fcb6c0ff6c524
Diffstat (limited to 'tests')
-rw-r--r--tests/functional/flakes/show.sh19
1 files changed, 16 insertions, 3 deletions
diff --git a/tests/functional/flakes/show.sh b/tests/functional/flakes/show.sh
index 857c77ae1..3461597ee 100644
--- a/tests/functional/flakes/show.sh
+++ b/tests/functional/flakes/show.sh
@@ -107,10 +107,23 @@ EOF
runinpty sh -c '
stty rows 20 cols 100
- nix flake show > show-output.txt
-'
+ TERM=xterm-256color NOCOLOR=1 nix flake show
+' > show-output.txt
+
test "$(awk -F '[:] ' '/aNoDescription/{print $NF}' ./show-output.txt)" = "package 'simple'"
test "$(awk -F '[:] ' '/bOneLineDescription/{print $NF}' ./show-output.txt)" = "package 'simple' - 'one line'"
test "$(awk -F '[:] ' '/cMultiLineDescription/{print $NF}' ./show-output.txt)" = "package 'simple' - 'line one'"
-test "$(awk -F '[:] ' '/dLongDescription/{print $NF}' ./show-output.txt)" = "package 'simple' - 'abcdefghijklmnopqrs...'"
+test "$(awk -F '[:] ' '/dLongDescription/{print $NF}' ./show-output.txt)" = "package 'simple' - 'abcdefghijklmnopqrstu…'"
+test "$(awk -F '[:] ' '/eEmptyDescription/{print $NF}' ./show-output.txt)" = "package 'simple'"
+
+# validate that having a broken window size does not cause anything to explode
+# and that descriptions are just not printed if there is no space at all
+runinpty sh -c '
+ stty rows 0 cols 0
+ TERM=xterm-256color NOCOLOR=1 nix flake show
+' > show-output.txt
+test "$(awk -F '[:] ' '/aNoDescription/{print $NF}' ./show-output.txt)" = "package 'simple'"
+test "$(awk -F '[:] ' '/bOneLineDescription/{print $NF}' ./show-output.txt)" = "package 'simple'"
+test "$(awk -F '[:] ' '/cMultiLineDescription/{print $NF}' ./show-output.txt)" = "package 'simple'"
+test "$(awk -F '[:] ' '/dLongDescription/{print $NF}' ./show-output.txt)" = "package 'simple'"
test "$(awk -F '[:] ' '/eEmptyDescription/{print $NF}' ./show-output.txt)" = "package 'simple'"