(t *testing.T, tester shellTester)
| 733 | } |
| 734 | |
| 735 | func testExcludeHiddenCommand(t *testing.T, tester shellTester) { |
| 736 | // Set up |
| 737 | defer testutils.BackupAndRestore(t)() |
| 738 | installHishtory(t, tester, "") |
| 739 | |
| 740 | tester.RunInteractiveShell(t, `echo hello1 |
| 741 | echo hidden |
| 742 | echo hello2 |
| 743 | echo hidden`) |
| 744 | tester.RunInteractiveShell(t, " echo hidden") |
| 745 | out := hishtoryQuery(t, tester, "-pipefail") |
| 746 | if strings.Count(out, "\n") != 3 { |
| 747 | t.Fatalf("hishtory query has the wrong number of lines=%d, out=%#v, bash hishtory file=%#v", strings.Count(out, "\n"), out, tester.RunInteractiveShell(t, "cat ~/.bash_history")) |
| 748 | } |
| 749 | if strings.Count(out, "echo hello") != 2 { |
| 750 | t.Fatalf("hishtory query has the wrong number of commands=%d, out=%#v", strings.Count(out, "echo mycommand"), out) |
| 751 | } |
| 752 | if strings.Count(out, "echo hello1") != 1 { |
| 753 | t.Fatalf("hishtory query has the wrong number of commands=%d, out=%#v", strings.Count(out, "echo mycommand"), out) |
| 754 | } |
| 755 | if strings.Count(out, "echo hello2") != 1 { |
| 756 | t.Fatalf("hishtory query has the wrong number of commands=%d, out=%#v", strings.Count(out, "echo mycommand"), out) |
| 757 | } |
| 758 | require.NotContains(t, out, "hidden") |
| 759 | |
| 760 | out = tester.RunInteractiveShell(t, "hishtory export | grep -v pipefail | grep -v '/tmp/client install'") |
| 761 | expectedOutput := "echo hello1\necho hello2\n" |
| 762 | if out != expectedOutput { |
| 763 | t.Fatalf("hishtory export has unexpected output=%#v", out) |
| 764 | } |
| 765 | } |
| 766 | |
| 767 | func waitForBackgroundSavesToComplete(t testing.TB) { |
| 768 | lastOut := "" |
no test coverage detected