From 9d5620c17058b2761a89084430277725295b611e Mon Sep 17 00:00:00 2001 From: Fabian Homborg Date: Tue, 25 Jun 2019 20:47:28 +0200 Subject: [PATCH] Port most of the invocation tests to littlecheck This is a bit weird sometimes, e.g. to test the return status (that fish actually *returns $status*), we use a #RUN line with %fish invoking %fish, so we can use the substitution. Still much nicer. The missing scripts are those that rely on config. --- tests/checks/command-1.fish | 2 ++ tests/checks/command-2.fish | 3 +++ tests/checks/command-vars-persist.fish | 2 ++ tests/checks/features-nocaret1.fish | 2 ++ tests/checks/features-nocaret2.fish | 2 ++ tests/checks/features-nocaret3.fish | 2 ++ tests/checks/features-nocaret4.fish | 2 ++ tests/checks/features-qmark2.fish | 2 ++ tests/checks/features-string-backslashes-off.fish | 2 ++ tests/checks/features-string-backslashes.fish | 2 ++ tests/checks/init-command-2.fish | 3 +++ tests/checks/init-command-mix-ordering.fish | 3 +++ tests/checks/init-command-mix.fish | 3 +++ tests/checks/init-command.fish | 2 ++ tests/checks/interactive.fish | 3 +++ tests/checks/invocation.fish | 2 ++ tests/checks/login-interactive.fish | 3 +++ tests/checks/login.fish | 3 +++ tests/checks/no-login-no-interactive.fish | 4 ++++ tests/checks/rc-returned.fish | 2 ++ tests/checks/version.fish | 2 ++ 21 files changed, 51 insertions(+) create mode 100644 tests/checks/command-1.fish create mode 100644 tests/checks/command-2.fish create mode 100644 tests/checks/command-vars-persist.fish create mode 100644 tests/checks/features-nocaret1.fish create mode 100644 tests/checks/features-nocaret2.fish create mode 100644 tests/checks/features-nocaret3.fish create mode 100644 tests/checks/features-nocaret4.fish create mode 100644 tests/checks/features-qmark2.fish create mode 100644 tests/checks/features-string-backslashes-off.fish create mode 100644 tests/checks/features-string-backslashes.fish create mode 100644 tests/checks/init-command-2.fish create mode 100644 tests/checks/init-command-mix-ordering.fish create mode 100644 tests/checks/init-command-mix.fish create mode 100644 tests/checks/init-command.fish create mode 100644 tests/checks/interactive.fish create mode 100644 tests/checks/invocation.fish create mode 100644 tests/checks/login-interactive.fish create mode 100644 tests/checks/login.fish create mode 100644 tests/checks/no-login-no-interactive.fish create mode 100644 tests/checks/rc-returned.fish create mode 100644 tests/checks/version.fish diff --git a/tests/checks/command-1.fish b/tests/checks/command-1.fish new file mode 100644 index 000000000..d8ca460e5 --- /dev/null +++ b/tests/checks/command-1.fish @@ -0,0 +1,2 @@ +#RUN: %fish -c "echo 1.2.3.4." +# CHECK: 1.2.3.4. diff --git a/tests/checks/command-2.fish b/tests/checks/command-2.fish new file mode 100644 index 000000000..c0b4ef83d --- /dev/null +++ b/tests/checks/command-2.fish @@ -0,0 +1,3 @@ +#RUN: %fish -c "echo 1.2.3.4." -c "echo 5.6.7.8." +# CHECK: 1.2.3.4. +# CHECK: 5.6.7.8. diff --git a/tests/checks/command-vars-persist.fish b/tests/checks/command-vars-persist.fish new file mode 100644 index 000000000..c3670dd84 --- /dev/null +++ b/tests/checks/command-vars-persist.fish @@ -0,0 +1,2 @@ +#RUN: %fish -c 'set foo bar' -c 'echo $foo' +# CHECK: bar diff --git a/tests/checks/features-nocaret1.fish b/tests/checks/features-nocaret1.fish new file mode 100644 index 000000000..a7230e594 --- /dev/null +++ b/tests/checks/features-nocaret1.fish @@ -0,0 +1,2 @@ +#RUN: %fish --features 'no-stderr-nocaret' -c 'status test-feature stderr-nocaret; echo nocaret: $status' +# CHECK: nocaret: 1 diff --git a/tests/checks/features-nocaret2.fish b/tests/checks/features-nocaret2.fish new file mode 100644 index 000000000..7aa21462b --- /dev/null +++ b/tests/checks/features-nocaret2.fish @@ -0,0 +1,2 @@ +#RUN: %fish --features 'stderr-nocaret' -c 'status test-feature stderr-nocaret; echo nocaret: $status' +# CHECK: nocaret: 0 diff --git a/tests/checks/features-nocaret3.fish b/tests/checks/features-nocaret3.fish new file mode 100644 index 000000000..4f353d2b6 --- /dev/null +++ b/tests/checks/features-nocaret3.fish @@ -0,0 +1,2 @@ +#RUN: %fish --features 'no-stderr-nocaret' -c 'echo -n careton:; echo ^/dev/null' +# CHECK: careton: diff --git a/tests/checks/features-nocaret4.fish b/tests/checks/features-nocaret4.fish new file mode 100644 index 000000000..1f538cdb5 --- /dev/null +++ b/tests/checks/features-nocaret4.fish @@ -0,0 +1,2 @@ +#RUN: %fish --features ' stderr-nocaret' -c 'echo -n "caretoff: "; echo ^/dev/null' +# CHECK: caretoff: ^/dev/null diff --git a/tests/checks/features-qmark2.fish b/tests/checks/features-qmark2.fish new file mode 100644 index 000000000..36dd56528 --- /dev/null +++ b/tests/checks/features-qmark2.fish @@ -0,0 +1,2 @@ +#RUN: %fish --features 'qmark-noglob' -C 'string match --quiet "??" ab ; echo "qmarkoff: $status"' +# CHECK: qmarkoff: 1 diff --git a/tests/checks/features-string-backslashes-off.fish b/tests/checks/features-string-backslashes-off.fish new file mode 100644 index 000000000..06593c9da --- /dev/null +++ b/tests/checks/features-string-backslashes-off.fish @@ -0,0 +1,2 @@ +#RUN: %fish --features 'no-string-replace-fewer-backslashes' -C 'string replace -ra "\\\\" "\\\\\\\\" -- "a\b\c"' +# CHECK: a\b\c diff --git a/tests/checks/features-string-backslashes.fish b/tests/checks/features-string-backslashes.fish new file mode 100644 index 000000000..c73e1c0e6 --- /dev/null +++ b/tests/checks/features-string-backslashes.fish @@ -0,0 +1,2 @@ +#RUN: %fish --features 'string-replace-fewer-backslashes' -C 'string replace -ra "\\\\" "\\\\\\\\" -- "a\b\c"' +# CHECK: a\\b\\c diff --git a/tests/checks/init-command-2.fish b/tests/checks/init-command-2.fish new file mode 100644 index 000000000..0e603deb2 --- /dev/null +++ b/tests/checks/init-command-2.fish @@ -0,0 +1,3 @@ +#RUN: %fish -C 'echo init-command' -C 'echo 2nd init-command' +# CHECK: init-command +# CHECK: 2nd init-command diff --git a/tests/checks/init-command-mix-ordering.fish b/tests/checks/init-command-mix-ordering.fish new file mode 100644 index 000000000..8c54be6e6 --- /dev/null +++ b/tests/checks/init-command-mix-ordering.fish @@ -0,0 +1,3 @@ +#RUN: %fish -c 'echo command' -C 'echo init-command' +# CHECK: init-command +# CHECK: command diff --git a/tests/checks/init-command-mix.fish b/tests/checks/init-command-mix.fish new file mode 100644 index 000000000..a8cd076bf --- /dev/null +++ b/tests/checks/init-command-mix.fish @@ -0,0 +1,3 @@ +#RUN: %fish -C 'echo init-command' -c 'echo command' +# CHECK: init-command +# CHECK: command diff --git a/tests/checks/init-command.fish b/tests/checks/init-command.fish new file mode 100644 index 000000000..0a7875e1a --- /dev/null +++ b/tests/checks/init-command.fish @@ -0,0 +1,2 @@ +#RUN: %fish -C 'echo init-command' +# CHECK: init-command diff --git a/tests/checks/interactive.fish b/tests/checks/interactive.fish new file mode 100644 index 000000000..27bef3c20 --- /dev/null +++ b/tests/checks/interactive.fish @@ -0,0 +1,3 @@ +#RUN: %fish -c 'if status --is-login ; echo login shell ; else ; echo not login shell ; end; if status --is-interactive ; echo interactive ; else ; echo not interactive ; end' -i +# CHECK: not login shell +# CHECK: interactive diff --git a/tests/checks/invocation.fish b/tests/checks/invocation.fish new file mode 100644 index 000000000..d8ca460e5 --- /dev/null +++ b/tests/checks/invocation.fish @@ -0,0 +1,2 @@ +#RUN: %fish -c "echo 1.2.3.4." +# CHECK: 1.2.3.4. diff --git a/tests/checks/login-interactive.fish b/tests/checks/login-interactive.fish new file mode 100644 index 000000000..055725a3c --- /dev/null +++ b/tests/checks/login-interactive.fish @@ -0,0 +1,3 @@ +#RUN: %fish -c 'if status --is-login ; echo login shell ; else ; echo not login shell ; end; if status --is-interactive ; echo interactive ; else ; echo not interactive ; end' -l -i +# CHECK: login shell +# CHECK: interactive diff --git a/tests/checks/login.fish b/tests/checks/login.fish new file mode 100644 index 000000000..b9965d866 --- /dev/null +++ b/tests/checks/login.fish @@ -0,0 +1,3 @@ +#RUN: %fish -c 'if status --is-login ; echo login shell ; else ; echo not login shell ; end; if status --is-interactive ; echo interactive ; else ; echo not interactive ; end' -l +# CHECK: login shell +# CHECK: not interactive diff --git a/tests/checks/no-login-no-interactive.fish b/tests/checks/no-login-no-interactive.fish new file mode 100644 index 000000000..dd369e599 --- /dev/null +++ b/tests/checks/no-login-no-interactive.fish @@ -0,0 +1,4 @@ +#RUN: %fish -c 'if status --is-login ; echo login shell ; else ; echo not login shell ; end; if status --is-interactive ; echo interactive ; else ; echo not interactive ; end' + +# CHECK: not login shell +# CHECK: not interactive diff --git a/tests/checks/rc-returned.fish b/tests/checks/rc-returned.fish new file mode 100644 index 000000000..240e28ea1 --- /dev/null +++ b/tests/checks/rc-returned.fish @@ -0,0 +1,2 @@ +#RUN: %fish -c '%fish -c false; echo RC: $status' +# CHECK: RC: 1 diff --git a/tests/checks/version.fish b/tests/checks/version.fish new file mode 100644 index 000000000..2c9424dec --- /dev/null +++ b/tests/checks/version.fish @@ -0,0 +1,2 @@ +#RUN: %fish -v +# CHECK: fish, version {{[-.ga-f0-9]*(irty)?}}