Filter out pipefails in test outputs

This commit is contained in:
David Dworken 2022-11-12 17:27:24 -08:00
parent 480630e918
commit 0abfefa80a
No known key found for this signature in database
5 changed files with 53 additions and 85 deletions

View File

@ -291,12 +291,12 @@ yes | hishtory init `+userSecret)
} }
// And test the export for each shell without anything filtered out // And test the export for each shell without anything filtered out
out = tester.RunInteractiveShell(t, `hishtory export | grep -v 'hishtory init '`) out = tester.RunInteractiveShell(t, `hishtory export -pipefail | grep -v 'hishtory init '`)
compareGoldens(t, out, "testIntegrationWithNewDevice-"+tester.ShellName()) compareGoldens(t, out, "testIntegrationWithNewDevice-"+tester.ShellName())
// And test the table but with a subset of columns that is static // And test the table but with a subset of columns that is static
tester.RunInteractiveShell(t, `hishtory config-set displayed-columns Hostname 'Exit Code' Command`) tester.RunInteractiveShell(t, `hishtory config-set displayed-columns Hostname 'Exit Code' Command`)
out = tester.RunInteractiveShell(t, `hishtory query | grep -v 'hishtory init '`) out = tester.RunInteractiveShell(t, `hishtory query -pipefail | grep -v 'hishtory init '`)
compareGoldens(t, out, "testIntegrationWithNewDevice-table"+tester.ShellName()) compareGoldens(t, out, "testIntegrationWithNewDevice-table"+tester.ShellName())
} }
@ -606,7 +606,7 @@ hishtory disable`)
if strings.Contains(out, "cmd_with_diff_hostname_and_username") { if strings.Contains(out, "cmd_with_diff_hostname_and_username") {
t.Fatalf("hishtory query contains unexpected result, out=%#v", out) t.Fatalf("hishtory query contains unexpected result, out=%#v", out)
} }
out = hishtoryQuery(t, tester, `-echo`) out = hishtoryQuery(t, tester, `-echo -pipefail`)
if strings.Contains(out, "echo") { if strings.Contains(out, "echo") {
t.Fatalf("hishtory query contains unexpected result, out=%#v", out) t.Fatalf("hishtory query contains unexpected result, out=%#v", out)
} }
@ -1545,7 +1545,7 @@ ls /tmp`, randomCmdUuid, randomCmdUuid)
// Redact s // Redact s
out = tester.RunInteractiveShell(t, `hishtory redact --force s`) out = tester.RunInteractiveShell(t, `hishtory redact --force s`)
if out != "Permanently deleting 10 entries\n" { if out != "Permanently deleting 10 entries\n" && out != "Permanently deleting 11 entries\n" {
t.Fatalf("hishtory redact gave unexpected output=%#v", out) t.Fatalf("hishtory redact gave unexpected output=%#v", out)
} }
@ -2263,7 +2263,7 @@ func testMultipleUsers(t *testing.T, tester shellTester) {
// Check that the right commands were recorded for user1 // Check that the right commands were recorded for user1
for i, d := range []device{u1d1, u1d2} { for i, d := range []device{u1d1, u1d2} {
switchToDevice(&devices, d) switchToDevice(&devices, d)
out, err := tester.RunInteractiveShellRelaxed(t, `hishtory export`) out, err := tester.RunInteractiveShellRelaxed(t, `hishtory export -pipefail`)
testutils.Check(t, err) testutils.Check(t, err)
expectedOutput := "echo u1d1\necho u1d2\necho u1d1-b\necho u1d1-c\necho u1d2-b\necho u1d2-c\n" expectedOutput := "echo u1d1\necho u1d2\necho u1d1-b\necho u1d1-c\necho u1d2-b\necho u1d2-c\n"
for j := 0; j < i; j++ { for j := 0; j < i; j++ {

View File

@ -1,6 +1,4 @@
set -emo pipefail
hishtory status hishtory status
set -emo pipefail
hishtory query hishtory query
ls /a ls /a
ls /bar ls /bar
@ -9,30 +7,16 @@ echo foo
echo bar echo bar
hishtory enable hishtory enable
echo thisisrecorded echo thisisrecorded
set -emo pipefail
hishtory query hishtory query
set -emo pipefail
hishtory query foo hishtory query foo
echo hello | grep complex | sed s/h/i/g; echo baz && echo "fo 'o" # mycommand echo hello | grep complex | sed s/h/i/g; echo baz && echo "fo 'o" # mycommand
set -emo pipefail
hishtory query complex hishtory query complex
set -emo pipefail
hishtory query hishtory query
set -emo pipefail
echo mynewcommand echo mynewcommand
set -emo pipefail
hishtory query hishtory query
set -emo pipefail
hishtory query hishtory query
set -emo pipefail
echo mynewercommand echo mynewercommand
set -emo pipefail
hishtory query hishtory query
othercomputer othercomputer
set -emo pipefail
hishtory query hishtory query
set -emo pipefail
hishtory reupload hishtory reupload
set -emo pipefail
hishtory export | grep -v pipefail | grep -v '/tmp/client install'
set -emo pipefail

View File

@ -1,24 +1,24 @@
Hostname Exit Code Command Hostname Exit Code Command
ghaction-runner-hostname 0 set -emo pipefail ghaction-runner-hostname 0 hishtory config-set displayed-columns Hostname 'Exit Code' Command
ghaction-runner-hostname 0 hishtory config-set displayed-columns Hostname 'Exit Code' Command ghaction-runner-hostname 0 hishtory reupload
ghaction-runner-hostname 0 set -emo pipefail ghaction-runner-hostname 0 hishtory query
ghaction-runner-hostname 0 set -emo pipefail localhost 2 othercomputer
ghaction-runner-hostname 0 hishtory export | grep -v pipefail | grep -v '/tmp/client install' ghaction-runner-hostname 0 hishtory query
ghaction-runner-hostname 0 set -emo pipefail ghaction-runner-hostname 0 echo mynewercommand
ghaction-runner-hostname 0 hishtory reupload ghaction-runner-hostname 0 hishtory query
ghaction-runner-hostname 0 set -emo pipefail ghaction-runner-hostname 0 hishtory query
ghaction-runner-hostname 0 hishtory query ghaction-runner-hostname 0 echo mynewcommand
ghaction-runner-hostname 0 set -emo pipefail ghaction-runner-hostname 0 hishtory query
localhost 2 othercomputer ghaction-runner-hostname 0 hishtory query complex
ghaction-runner-hostname 0 hishtory query ghaction-runner-hostname 0 echo hello | grep complex | sed s/h/i/g; echo baz && echo "fo 'o" # mycommand
ghaction-runner-hostname 0 set -emo pipefail ghaction-runner-hostname 0 hishtory query foo
ghaction-runner-hostname 0 echo mynewercommand ghaction-runner-hostname 0 hishtory query
ghaction-runner-hostname 0 set -emo pipefail ghaction-runner-hostname 0 echo thisisrecorded
ghaction-runner-hostname 0 hishtory query ghaction-runner-hostname 0 hishtory enable
ghaction-runner-hostname 0 set -emo pipefail ghaction-runner-hostname 0 echo bar
ghaction-runner-hostname 0 hishtory query ghaction-runner-hostname 0 echo foo
ghaction-runner-hostname 0 set -emo pipefail ghaction-runner-hostname 1 ls /foo
ghaction-runner-hostname 0 echo mynewcommand ghaction-runner-hostname 1 ls /bar
ghaction-runner-hostname 0 set -emo pipefail ghaction-runner-hostname 1 ls /a
ghaction-runner-hostname 0 hishtory query ghaction-runner-hostname 0 hishtory query
ghaction-runner-hostname 0 set -emo pipefail ghaction-runner-hostname 0 hishtory status

View File

@ -1,24 +1,24 @@
Hostname Exit Code Command Hostname Exit Code Command
ghaction-runner-hostname 0 set -eo pipefail ghaction-runner-hostname 0 hishtory config-set displayed-columns Hostname 'Exit Code' Command
ghaction-runner-hostname 0 hishtory config-set displayed-columns Hostname 'Exit Code' Command ghaction-runner-hostname 0 hishtory reupload
ghaction-runner-hostname 0 set -eo pipefail ghaction-runner-hostname 0 hishtory query
ghaction-runner-hostname 0 set -eo pipefail localhost 2 othercomputer
ghaction-runner-hostname 0 hishtory export | grep -v pipefail | grep -v '/tmp/client install' ghaction-runner-hostname 0 hishtory query
ghaction-runner-hostname 0 set -eo pipefail ghaction-runner-hostname 0 echo mynewercommand
ghaction-runner-hostname 0 hishtory reupload ghaction-runner-hostname 0 hishtory query
ghaction-runner-hostname 0 set -eo pipefail ghaction-runner-hostname 0 hishtory query
ghaction-runner-hostname 0 hishtory query ghaction-runner-hostname 0 echo mynewcommand
ghaction-runner-hostname 0 set -eo pipefail ghaction-runner-hostname 0 hishtory query
localhost 2 othercomputer ghaction-runner-hostname 0 hishtory query complex
ghaction-runner-hostname 0 hishtory query ghaction-runner-hostname 0 echo hello | grep complex | sed s/h/i/g; echo baz && echo "fo 'o" # mycommand
ghaction-runner-hostname 0 set -eo pipefail ghaction-runner-hostname 0 hishtory query foo
ghaction-runner-hostname 0 echo mynewercommand ghaction-runner-hostname 0 hishtory query
ghaction-runner-hostname 0 set -eo pipefail ghaction-runner-hostname 0 echo thisisrecorded
ghaction-runner-hostname 0 hishtory query ghaction-runner-hostname 0 hishtory enable
ghaction-runner-hostname 0 set -eo pipefail ghaction-runner-hostname 0 echo bar
ghaction-runner-hostname 0 hishtory query ghaction-runner-hostname 0 echo foo
ghaction-runner-hostname 0 set -eo pipefail ghaction-runner-hostname 1 ls /foo
ghaction-runner-hostname 0 echo mynewcommand ghaction-runner-hostname 1 ls /bar
ghaction-runner-hostname 0 set -eo pipefail ghaction-runner-hostname 1 ls /a
ghaction-runner-hostname 0 hishtory query ghaction-runner-hostname 0 hishtory query
ghaction-runner-hostname 0 set -eo pipefail ghaction-runner-hostname 0 hishtory status

View File

@ -1,6 +1,4 @@
set -eo pipefail
hishtory status hishtory status
set -eo pipefail
hishtory query hishtory query
ls /a ls /a
ls /bar ls /bar
@ -9,30 +7,16 @@ echo foo
echo bar echo bar
hishtory enable hishtory enable
echo thisisrecorded echo thisisrecorded
set -eo pipefail
hishtory query hishtory query
set -eo pipefail
hishtory query foo hishtory query foo
echo hello | grep complex | sed s/h/i/g; echo baz && echo "fo 'o" # mycommand echo hello | grep complex | sed s/h/i/g; echo baz && echo "fo 'o" # mycommand
set -eo pipefail
hishtory query complex hishtory query complex
set -eo pipefail
hishtory query hishtory query
set -eo pipefail
echo mynewcommand echo mynewcommand
set -eo pipefail
hishtory query hishtory query
set -eo pipefail
hishtory query hishtory query
set -eo pipefail
echo mynewercommand echo mynewercommand
set -eo pipefail
hishtory query hishtory query
othercomputer othercomputer
set -eo pipefail
hishtory query hishtory query
set -eo pipefail
hishtory reupload hishtory reupload
set -eo pipefail
hishtory export | grep -v pipefail | grep -v '/tmp/client install'
set -eo pipefail