-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Scripts for the UI tests now have assert_* functions, so they can verify the expected results from the commands in the script itself, instead of comparing their output with the *.output files.
- Loading branch information
Showing
16 changed files
with
137 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#! bash | ||
# | ||
# assert functions to be used in *.sh tests. | ||
|
||
ASSERT_OUTPUT() { | ||
local cmd="$1" | ||
local expected="${2:-}"; | ||
|
||
# Read expected output from std if there is only one argument. | ||
if [ $# -eq 1 ] | ||
then | ||
while read -sr | ||
do | ||
if [ -n "$expected" ] | ||
then | ||
expected+=$'\n' | ||
fi | ||
|
||
expected+="$REPLY" | ||
done | ||
fi | ||
|
||
local output=$(eval "$cmd" 2>&1) | ||
|
||
if [ "$output" != "$expected" ] | ||
then | ||
printf 'assertion failed: invalid output for "%s"\n' "$cmd" | ||
printf ' expected: %q\n' "$expected" | ||
printf ' output: %q\n' "$output" | ||
|
||
exit 1 | ||
fi | ||
|
||
return 0 | ||
} | ||
|
||
ASSERT_FAILS() { | ||
if eval "$*" | ||
then | ||
printf 'assertion failed: "%s" should fail\n' "$*" | ||
exit 1 | ||
fi | ||
|
||
return 0 | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,17 @@ | ||
# bash | ||
# Test to change builtin configuration. | ||
|
||
load_builtin | ||
|
||
timehistory -L 5000 -F '%n\t%P\t%C' | ||
timehistory -C | ||
|
||
ASSERT_OUTPUT \ | ||
"timehistory -C" \ | ||
$'-L 5000 -F \'%n\\\\t%P\\\\t%C\'' | ||
|
||
timehistory -F '> %C' | ||
|
||
command expr 1 + 2 | ||
timehistory | ||
ASSERT_OUTPUT \ | ||
"timehistory" \ | ||
"> expr 1 '+' 2" |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
# Test for the clear history option. | ||
|
||
load_builtin | ||
|
||
/bin/true | ||
timehistory -f '%C' | ||
test -n "$(timehistory)" | ||
|
||
echo . | ||
timehistory -R | ||
timehistory | ||
echo . | ||
test -z "$(timehistory)" |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,22 @@ | ||
# Test to use the shell session after a panic in the builtin. | ||
|
||
load_builtin | ||
|
||
type timehistory | ||
|
||
/bin/true | ||
timehistory -f '- %n' | ||
ASSERT_OUTPUT \ | ||
"timehistory -f '- %n'" \ | ||
"- 1" | ||
|
||
# Force a panic. | ||
timehistory -P &> /dev/null | ||
timehistory | ||
ASSERT_FAILS timehistory -P | ||
ASSERT_FAILS timehistory | ||
|
||
/bin/echo 2 | ||
enable -d timehistory | ||
type timehistory | ||
ASSERT_FAILS type timehistory | ||
|
||
/bin/echo 3 | ||
ASSERT_OUTPUT \ | ||
"/bin/echo 3" \ | ||
"3" |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,20 @@ | ||
# Test to use the shell session after removing the builtin. | ||
|
||
load_builtin | ||
|
||
/bin/echo 1 | ||
timehistory -f '- %n' | ||
ASSERT_OUTPUT \ | ||
"timehistory -f '- %n'" \ | ||
"- 1" | ||
|
||
enable -d timehistory | ||
/bin/echo 2 | ||
|
||
ASSERT_FAILS timehistory | ||
|
||
load_builtin | ||
/bin/echo 3 | ||
timehistory -f '- %n' | ||
|
||
ASSERT_OUTPUT \ | ||
"timehistory -f '> %n'" \ | ||
"> 1" |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,18 @@ | ||
# Test to print a single entry from the history. | ||
|
||
load_builtin | ||
|
||
/bin/true 1 | ||
/bin/true 2 | ||
/bin/true 3 | ||
|
||
timehistory -f '%n %C' 2 | ||
timehistory -f '%n %C' +1 | ||
ASSERT_OUTPUT \ | ||
"timehistory -f '%n %C' 2" \ | ||
"2 /bin/true 2" | ||
|
||
ASSERT_OUTPUT \ | ||
"timehistory -f '%n %C' +1" \ | ||
"3 /bin/true 3" | ||
|
||
timehistory x || : | ||
( timehistory x 2>&1 || : ) \ | ||
| grep 'timehistory: invalid digit found in string' |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters