-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor tests to make them non-flakey and pass on actions
This required adding the ability to have hishtory run synchronously to avoid reconditions. I also added additional waiting code. Also a whole bunch of new tests and disabled gorm's default logger which also caued flakeyness
- Loading branch information
Showing
9 changed files
with
316 additions
and
63 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
forcetest: | ||
go clean -testcache | ||
HISHTORY_TEST=1 go test -p 1 ./... | ||
test: | ||
HISHTORY_TEST=1 go test -p 1 ./... | ||
|
||
|
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
Large diffs are not rendered by default.
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 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,29 @@ | ||
# This script should be sourced inside of .bashrc to integrate bash with hishtory | ||
# This is the same as config.sh, except it doesn't run the save process in the background. This is crucial to making tests reproducible. | ||
|
||
# Implementation of PreCommand and PostCommand based on https://jichu4n.com/posts/debug-trap-and-prompt_command-in-bash/ | ||
function PreCommand() { | ||
if [ -z "$HISHTORY_AT_PROMPT" ]; then | ||
return | ||
fi | ||
unset HISHTORY_AT_PROMPT | ||
|
||
# Run before every command | ||
HISHTORY_START_TIME=`date +%s%N` | ||
} | ||
trap "PreCommand" DEBUG | ||
|
||
HISHTORY_FIRST_PROMPT=1 | ||
function PostCommand() { | ||
EXIT_CODE=$? | ||
HISHTORY_AT_PROMPT=1 | ||
|
||
if [ -n "$HISHTORY_FIRST_PROMPT" ]; then | ||
unset HISHTORY_FIRST_PROMPT | ||
return | ||
fi | ||
|
||
# Run after every prompt | ||
hishtory saveHistoryEntry $EXIT_CODE "`history 1`" $HISHTORY_START_TIME | ||
} | ||
PROMPT_COMMAND="PostCommand" |
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
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