mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-22 05:56:15 +02:00
tests/functional/repl: Normalize final prompt
This commit is contained in:
parent
ca2cc26e12
commit
c4ae9bb45b
12 changed files with 13 additions and 24 deletions
|
@ -262,14 +262,23 @@ badExitCode=0
|
|||
|
||||
nixVersion="$(nix eval --impure --raw --expr 'builtins.nixVersion' --extra-experimental-features nix-command)"
|
||||
|
||||
# TODO: write a repl interacter for testing. Papering over the differences between readline / editline and between platforms is a pain.
|
||||
|
||||
# I couldn't get readline and editline to agree on the newline before the prompt,
|
||||
# so let's just force it to be one empty line. Ideally we get the two to agree
|
||||
# or use a simpler interacter for testing.
|
||||
# so let's just force it to be one empty line.
|
||||
stripEmptyLinesBeforePrompt() {
|
||||
# --null-data: treat input as NUL-terminated instead of newline-terminated
|
||||
sed --null-data 's/\n\n*nix-repl>/\n\nnix-repl>/g'
|
||||
}
|
||||
|
||||
# We don't get a final prompt on darwin, so we strip this as well.
|
||||
stripFinalPrompt() {
|
||||
# Strip the final prompt and/or any trailing spaces
|
||||
sed --null-data \
|
||||
-e 's/\(.*[^\n]\)\n\n*nix-repl>[ \n]*$/\1/' \
|
||||
-e 's/[ \n]*$/\n/'
|
||||
}
|
||||
|
||||
runRepl () {
|
||||
|
||||
# That is right, we are also filtering out the testdir _without underscores_.
|
||||
|
@ -285,7 +294,9 @@ runRepl () {
|
|||
_NIX_TEST_REPL_ECHO=1 \
|
||||
nix repl 2>&1 \
|
||||
| stripColors \
|
||||
| tr -d '\0' \
|
||||
| stripEmptyLinesBeforePrompt \
|
||||
| stripFinalPrompt \
|
||||
| sed \
|
||||
-e "s@$testDir@/path/to/tests/functional@g" \
|
||||
-e "s@$testDirNoUnderscores@/path/to/tests/functional@g" \
|
||||
|
|
|
@ -26,5 +26,3 @@ nix-repl> "This won't produce docs; no support for arbitrary values"
|
|||
|
||||
nix-repl> :doc x 2
|
||||
error: value does not have documentation
|
||||
|
||||
nix-repl>
|
||||
|
|
|
@ -12,5 +12,3 @@ Function `documentedFormals`\
|
|||
… defined at /path/to/tests/functional/repl/doc-comments.nix:57:5
|
||||
|
||||
Finds x
|
||||
|
||||
nix-repl>
|
||||
|
|
|
@ -5,5 +5,3 @@ nix-repl> :doc import ./doc-comment-function.nix
|
|||
Function defined at /path/to/tests/functional/repl/doc-comment-function.nix:2:1
|
||||
|
||||
A doc comment for a file that only contains a function
|
||||
|
||||
nix-repl>
|
||||
|
|
|
@ -9,5 +9,3 @@ Function `compact`\
|
|||
… defined at /path/to/tests/functional/repl/doc-comments.nix:18:20
|
||||
|
||||
boom
|
||||
|
||||
nix-repl>
|
||||
|
|
|
@ -108,5 +108,3 @@ error:
|
|||
1| lib.attr.undocumental
|
||||
| ^
|
||||
Did you mean undocumented?
|
||||
|
||||
nix-repl>
|
||||
|
|
|
@ -9,5 +9,3 @@ Function `floatedIn`\
|
|||
… defined at /path/to/tests/functional/repl/doc-comments.nix:16:5
|
||||
|
||||
This also works.
|
||||
|
||||
nix-repl>
|
||||
|
|
|
@ -27,5 +27,3 @@ Function `strictPost`\
|
|||
… defined at /path/to/tests/functional/repl/doc-comments.nix:41:53
|
||||
|
||||
Here's another way to do this
|
||||
|
||||
nix-repl>
|
||||
|
|
|
@ -9,5 +9,3 @@ Function `measurement`\
|
|||
… defined at /path/to/tests/functional/repl/doc-comments.nix:13:17
|
||||
|
||||
👈 precisely this wide 👉
|
||||
|
||||
nix-repl>
|
||||
|
|
|
@ -15,5 +15,3 @@ Perform *arithmetic* multiplication. It's kind of like repeated **addition**, ve
|
|||
multiply 2 3
|
||||
=> 6
|
||||
```
|
||||
|
||||
nix-repl>
|
||||
|
|
|
@ -9,5 +9,3 @@ Function `unambiguous`\
|
|||
… defined at /path/to/tests/functional/repl/doc-comments.nix:24:5
|
||||
|
||||
Very close
|
||||
|
||||
nix-repl>
|
||||
|
|
|
@ -35,5 +35,3 @@ nix-repl> twoDeepList
|
|||
[
|
||||
[ ... ]
|
||||
]
|
||||
|
||||
nix-repl>
|
||||
|
|
Loading…
Reference in a new issue