From 9462aacc5cf04efff7a34b1e440df064690f7f84 Mon Sep 17 00:00:00 2001 From: Fabian Homborg Date: Wed, 26 Jun 2019 21:00:54 +0200 Subject: [PATCH] Port abbr test to littlecheck --- tests/abbr.err | 52 ------------------------- tests/abbr.in | 71 ---------------------------------- tests/abbr.out | 55 -------------------------- tests/checks/abbr.fish | 87 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 87 insertions(+), 178 deletions(-) delete mode 100644 tests/abbr.err delete mode 100644 tests/abbr.in delete mode 100644 tests/abbr.out create mode 100644 tests/checks/abbr.fish diff --git a/tests/abbr.err b/tests/abbr.err deleted file mode 100644 index 9b8a4b9d1..000000000 --- a/tests/abbr.err +++ /dev/null @@ -1,52 +0,0 @@ - -#################### -# Test basic add and list of __abbr1 - -#################### -# Erasing one that doesn't exist should do nothing -abbr --erase: No abbreviation named NOT_AN_ABBR - -#################### -# Adding existing __abbr1 should be idempotent - -#################### -# Replacing __abbr1 definition - -#################### -# __abbr1 -s and --show tests - -#################### -# Test erasing __abbr1 - -#################### -# Ensure we escape special characters on output - -#################### -# Ensure we handle leading dashes in abbreviation names properly - -#################### -# Test that an abbr word containing spaces is rejected -abbr --add: Abbreviation 'a b c' cannot have spaces in the word - -#################### -# Test renaming - -#################### -# Test renaming a nonexistent abbreviation -abbr --rename: No abbreviation named __abbr6 - -#################### -# Test renaming to a abbreviation with spaces -abbr --rename: Abbreviation 'g h i' cannot have spaces in the word - -#################### -# Test renaming without arguments -abbr --rename: Requires exactly two arguments - -#################### -# Test renaming with too many arguments -abbr --rename: Requires exactly two arguments - -#################### -# Test renaming to existing abbreviation -abbr --rename: Abbreviation __abbr12 already exists, cannot rename __abbr11 diff --git a/tests/abbr.in b/tests/abbr.in deleted file mode 100644 index 42fb83c94..000000000 --- a/tests/abbr.in +++ /dev/null @@ -1,71 +0,0 @@ -logmsg Test basic add and list of __abbr1 -abbr __abbr1 alpha beta gamma -abbr | grep __abbr1 - -logmsg Erasing one that doesn\'t exist should do nothing -abbr --erase NOT_AN_ABBR -abbr | grep __abbr1 - -logmsg Adding existing __abbr1 should be idempotent -abbr __abbr1 alpha beta gamma -abbr | grep __abbr1 - -logmsg Replacing __abbr1 definition -abbr __abbr1 delta -abbr | grep __abbr1 - -logmsg __abbr1 -s and --show tests -abbr -s | grep __abbr1 -abbr --show | grep __abbr1 - -logmsg Test erasing __abbr1 -abbr -e __abbr1 -abbr | grep __abbr1 - -logmsg Ensure we escape special characters on output -abbr '~__abbr2' '$xyz' -abbr | grep __abbr2 -abbr -e '~__abbr2' - -logmsg Ensure we handle leading dashes in abbreviation names properly -abbr -- '--__abbr3' 'xyz' -abbr | grep __abbr3 -abbr -e -- '--__abbr3' - -logmsg Test that an abbr word containing spaces is rejected -abbr "a b c" "d e f" -abbr | grep 'a b c' - -logmsg Test renaming -abbr __abbr4 omega -abbr | grep __abbr5 -abbr -r __abbr4 __abbr5 -abbr | grep __abbr5 -abbr -e __abbr5 -abbr | grep __abbr4 - -logmsg Test renaming a nonexistent abbreviation -abbr -r __abbr6 __abbr - -logmsg Test renaming to a abbreviation with spaces -abbr __abbr4 omega -abbr -r __abbr4 "g h i" -abbr -e __abbr4 - -logmsg Test renaming without arguments -abbr __abbr7 omega -abbr -r __abbr7 - -logmsg Test renaming with too many arguments -abbr __abbr8 omega -abbr -r __abbr8 __abbr9 __abbr10 -abbr | grep __abbr8 -abbr | grep __abbr9 -abbr | grep __abbr10 - -logmsg Test renaming to existing abbreviation -abbr __abbr11 omega11 -abbr __abbr12 omega12 -abbr -r __abbr11 __abbr12 - -exit 0 # the last `abbr` command is expected to fail -- don't let that cause a test failure diff --git a/tests/abbr.out b/tests/abbr.out deleted file mode 100644 index c468b15f6..000000000 --- a/tests/abbr.out +++ /dev/null @@ -1,55 +0,0 @@ - -#################### -# Test basic add and list of __abbr1 -abbr -a -U -- __abbr1 'alpha beta gamma' - -#################### -# Erasing one that doesn't exist should do nothing -abbr -a -U -- __abbr1 'alpha beta gamma' - -#################### -# Adding existing __abbr1 should be idempotent -abbr -a -U -- __abbr1 'alpha beta gamma' - -#################### -# Replacing __abbr1 definition -abbr -a -U -- __abbr1 delta - -#################### -# __abbr1 -s and --show tests -abbr -a -U -- __abbr1 delta -abbr -a -U -- __abbr1 delta - -#################### -# Test erasing __abbr1 - -#################### -# Ensure we escape special characters on output -abbr -a -U -- '~__abbr2' '$xyz' - -#################### -# Ensure we handle leading dashes in abbreviation names properly -abbr -a -U -- --__abbr3 xyz - -#################### -# Test that an abbr word containing spaces is rejected - -#################### -# Test renaming -abbr -a -U -- __abbr5 omega - -#################### -# Test renaming a nonexistent abbreviation - -#################### -# Test renaming to a abbreviation with spaces - -#################### -# Test renaming without arguments - -#################### -# Test renaming with too many arguments -abbr -a -U -- __abbr8 omega - -#################### -# Test renaming to existing abbreviation diff --git a/tests/checks/abbr.fish b/tests/checks/abbr.fish new file mode 100644 index 000000000..dd8eaddd3 --- /dev/null +++ b/tests/checks/abbr.fish @@ -0,0 +1,87 @@ +#RUN: %fish %s +# Test basic add and list of __abbr1 +abbr __abbr1 alpha beta gamma +abbr | grep __abbr1 +# CHECK: abbr -a -U -- __abbr1 'alpha beta gamma' + +# Erasing one that doesn\'t exist should do nothing +abbr --erase NOT_AN_ABBR +abbr | grep __abbr1 +# CHECK: abbr -a -U -- __abbr1 'alpha beta gamma' +# CHECKERR: abbr --erase: No abbreviation named NOT_AN_ABBR + +# Adding existing __abbr1 should be idempotent +abbr __abbr1 alpha beta gamma +abbr | grep __abbr1 +# CHECK: abbr -a -U -- __abbr1 'alpha beta gamma' + +# Replacing __abbr1 definition +abbr __abbr1 delta +abbr | grep __abbr1 +# CHECK: abbr -a -U -- __abbr1 delta + +# __abbr1 -s and --show tests +abbr -s | grep __abbr1 +abbr --show | grep __abbr1 +# CHECK: abbr -a -U -- __abbr1 delta +# CHECK: abbr -a -U -- __abbr1 delta + +# Test erasing __abbr1 +abbr -e __abbr1 +abbr | grep __abbr1 + +# Ensure we escape special characters on output +abbr '~__abbr2' '$xyz' +abbr | grep __abbr2 +# CHECK: abbr -a -U -- '~__abbr2' '$xyz' +abbr -e '~__abbr2' + +# Ensure we handle leading dashes in abbreviation names properly +abbr -- '--__abbr3' 'xyz' +abbr | grep __abbr3 +# CHECK: abbr -a -U -- --__abbr3 xyz +abbr -e -- '--__abbr3' + +# Test that an abbr word containing spaces is rejected +abbr "a b c" "d e f" +abbr | grep 'a b c' +# CHECKERR: abbr --add: Abbreviation 'a b c' cannot have spaces in the word + +# Test renaming +abbr __abbr4 omega +abbr | grep __abbr5 +abbr -r __abbr4 __abbr5 +abbr | grep __abbr5 +# CHECK: abbr -a -U -- __abbr5 omega +abbr -e __abbr5 +abbr | grep __abbr4 + +# Test renaming a nonexistent abbreviation +abbr -r __abbr6 __abbr +# CHECKERR: abbr --rename: No abbreviation named __abbr6 + +# Test renaming to a abbreviation with spaces +abbr __abbr4 omega +abbr -r __abbr4 "g h i" +# CHECKERR: abbr --rename: Abbreviation 'g h i' cannot have spaces in the word +abbr -e __abbr4 + +# Test renaming without arguments +abbr __abbr7 omega +abbr -r __abbr7 +# CHECKERR: abbr --rename: Requires exactly two arguments + +# Test renaming with too many arguments +abbr __abbr8 omega +abbr -r __abbr8 __abbr9 __abbr10 +# CHECKERR: abbr --rename: Requires exactly two arguments +abbr | grep __abbr8 +abbr | grep __abbr9 +abbr | grep __abbr10 +# CHECK: abbr -a -U -- __abbr8 omega + +# Test renaming to existing abbreviation +abbr __abbr11 omega11 +abbr __abbr12 omega12 +abbr -r __abbr11 __abbr12 +# CHECKERR: abbr --rename: Abbreviation __abbr12 already exists, cannot rename __abbr11