mirror of
https://github.com/ddworken/hishtory.git
synced 2025-01-22 22:28:51 +01:00
Improve table matching for tests and attempt to fix the tests that fail only on github actions
This commit is contained in:
parent
5b1c9140b3
commit
d4302501eb
1
.github/workflows/go-test.yml
vendored
1
.github/workflows/go-test.yml
vendored
@ -25,4 +25,5 @@ jobs:
|
||||
run: |
|
||||
sudo apt-get update || true
|
||||
sudo apt-get install -y zsh || true
|
||||
export HISTFILE=~/.zsh_history
|
||||
make test
|
||||
|
@ -317,12 +317,20 @@ echo thisisrecorded`)
|
||||
datetimeMatcher := `[a-zA-Z]{3}\s\d{2}\s\d{4}\s[0-9:]+\s[A-Z]{3}`
|
||||
runtimeMatcher := `[0-9.ms]+`
|
||||
exitCodeMatcher := `0`
|
||||
cmdMatcher := `echo thisisrecorded`
|
||||
match, err := regexp.MatchString(hostnameMatcher+tableDividerMatcher+pathMatcher+tableDividerMatcher+datetimeMatcher+tableDividerMatcher+runtimeMatcher+tableDividerMatcher+exitCodeMatcher+tableDividerMatcher+cmdMatcher+tableDividerMatcher+`\n`, out)
|
||||
pipefailMatcher := `set -em?o pipefail`
|
||||
line1Matcher := `Hostname` + tableDividerMatcher + `CWD` + tableDividerMatcher + `Timestamp` + tableDividerMatcher + `Runtime` + tableDividerMatcher + `Exit Code` + tableDividerMatcher + `Command` + tableDividerMatcher + `\n`
|
||||
line2Matcher := hostnameMatcher + tableDividerMatcher + pathMatcher + tableDividerMatcher + datetimeMatcher + tableDividerMatcher + runtimeMatcher + tableDividerMatcher + exitCodeMatcher + tableDividerMatcher + pipefailMatcher + tableDividerMatcher + `\n`
|
||||
line3Matcher := hostnameMatcher + tableDividerMatcher + pathMatcher + tableDividerMatcher + datetimeMatcher + tableDividerMatcher + runtimeMatcher + tableDividerMatcher + exitCodeMatcher + tableDividerMatcher + `echo thisisrecorded` + tableDividerMatcher + `\n`
|
||||
match, err := regexp.MatchString(line3Matcher, out)
|
||||
shared.Check(t, err)
|
||||
if !match {
|
||||
t.Fatalf("output is missing the row for `echo thisisrecorded`: %v", out)
|
||||
}
|
||||
match, err = regexp.MatchString(line1Matcher+line2Matcher+line3Matcher, out)
|
||||
shared.Check(t, err)
|
||||
if !match {
|
||||
t.Fatalf("output doesn't match the expected table: %v", out)
|
||||
}
|
||||
|
||||
// Test querying for a specific command
|
||||
out = hishtoryQuery(t, tester, "foo")
|
||||
|
Loading…
Reference in New Issue
Block a user