mirror of
https://github.com/ddworken/hishtory.git
synced 2025-06-25 22:42:04 +02:00
Chdir so that we have a consistent cwd for github actions
This commit is contained in:
parent
189f183d69
commit
0f9e77223e
@ -29,6 +29,8 @@ func skipSlowTests() bool {
|
|||||||
return os.Getenv("FAST") != ""
|
return os.Getenv("FAST") != ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var initialWd string
|
||||||
|
|
||||||
func TestMain(m *testing.M) {
|
func TestMain(m *testing.M) {
|
||||||
defer testutils.RunTestServer()()
|
defer testutils.RunTestServer()()
|
||||||
cmd := exec.Command("go", "build", "-o", "/tmp/client")
|
cmd := exec.Command("go", "build", "-o", "/tmp/client")
|
||||||
@ -38,6 +40,11 @@ func TestMain(m *testing.M) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
panic(fmt.Sprintf("failed to build client: %v", err))
|
panic(fmt.Sprintf("failed to build client: %v", err))
|
||||||
}
|
}
|
||||||
|
cwd, err := os.Getwd()
|
||||||
|
if err != nil {
|
||||||
|
panic(fmt.Sprintf("failed to os.Getwd(): %v", err))
|
||||||
|
}
|
||||||
|
initialWd = cwd
|
||||||
m.Run()
|
m.Run()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1020,6 +1027,7 @@ func testDisplayTable(t *testing.T, tester shellTester) {
|
|||||||
|
|
||||||
// Add a custom column
|
// Add a custom column
|
||||||
tester.RunInteractiveShell(t, `hishtory config-add custom-columns foo "echo aaaaaaaaaaaaa"`)
|
tester.RunInteractiveShell(t, `hishtory config-add custom-columns foo "echo aaaaaaaaaaaaa"`)
|
||||||
|
testutils.Check(t, os.Chdir("/"))
|
||||||
tester.RunInteractiveShell(t, ` hishtory enable`)
|
tester.RunInteractiveShell(t, ` hishtory enable`)
|
||||||
tester.RunInteractiveShell(t, `echo table-1`)
|
tester.RunInteractiveShell(t, `echo table-1`)
|
||||||
tester.RunInteractiveShell(t, `echo table-2`)
|
tester.RunInteractiveShell(t, `echo table-2`)
|
||||||
@ -1734,7 +1742,7 @@ func normalizeHostnames(data string) string {
|
|||||||
|
|
||||||
func compareGoldens(t *testing.T, out, goldenName string) {
|
func compareGoldens(t *testing.T, out, goldenName string) {
|
||||||
out = normalizeHostnames(out)
|
out = normalizeHostnames(out)
|
||||||
goldenPath := path.Join("client/lib/goldens/", goldenName)
|
goldenPath := path.Join(initialWd, "client/lib/goldens/", goldenName)
|
||||||
expected, err := os.ReadFile(goldenPath)
|
expected, err := os.ReadFile(goldenPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if os.IsNotExist(err) {
|
if os.IsNotExist(err) {
|
||||||
@ -1938,7 +1946,10 @@ func testControlR(t *testing.T, tester shellTester, shellName string) {
|
|||||||
if strings.Contains(out, "Search Query") || strings.Contains(out, "─────") || strings.Contains(out, "Exit Code") {
|
if strings.Contains(out, "Search Query") || strings.Contains(out, "─────") || strings.Contains(out, "Exit Code") {
|
||||||
t.Fatalf("hishtory overrode control-r even when this was disabled? out=%#v", out)
|
t.Fatalf("hishtory overrode control-r even when this was disabled? out=%#v", out)
|
||||||
}
|
}
|
||||||
compareGoldens(t, out, "testControlR-"+shellName+"-Disabled")
|
if os.Getenv("GITHUB_ACTION") == "" {
|
||||||
|
// This bit is broken on actions since actions run as a different user
|
||||||
|
compareGoldens(t, out, "testControlR-"+shellName+"-Disabled")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type deviceSet struct {
|
type deviceSet struct {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
Hostname Exit Code Command CWD foo
|
Hostname Exit Code Command CWD foo
|
||||||
ghaction-runner-hostname 0 echo table-2 ~/code/hishtory aaaaaaaaaaaaa
|
ghaction-runner-hostname 0 echo table-2 / aaaaaaaaaaaaa
|
||||||
ghaction-runner-hostname 0 echo table-1 ~/code/hishtory aaaaaaaaaaaaa
|
ghaction-runner-hostname 0 echo table-1 / aaaaaaaaaaaaa
|
||||||
ghaction-runner-hostname 0 hishtory query table ~/code/hishtory
|
ghaction-runner-hostname 0 hishtory query table ~/code/hishtory
|
||||||
localhost 2 while : /tmp/
|
localhost 2 while : /tmp/
|
||||||
do
|
do
|
||||||
|
@ -59,9 +59,9 @@ func DeleteBakFiles(t *testing.T) {
|
|||||||
func BackupAndRestoreWithId(t *testing.T, id string) func() {
|
func BackupAndRestoreWithId(t *testing.T, id string) func() {
|
||||||
ResetFakeHistoryTimestamp()
|
ResetFakeHistoryTimestamp()
|
||||||
homedir, err := os.UserHomeDir()
|
homedir, err := os.UserHomeDir()
|
||||||
if err != nil {
|
Check(t, err)
|
||||||
t.Fatalf("failed to retrieve homedir: %v", err)
|
initialWd, err := os.Getwd()
|
||||||
}
|
Check(t, err)
|
||||||
|
|
||||||
renameFiles := []string{
|
renameFiles := []string{
|
||||||
path.Join(homedir, data.HISHTORY_PATH, data.DB_PATH),
|
path.Join(homedir, data.HISHTORY_PATH, data.DB_PATH),
|
||||||
@ -102,6 +102,7 @@ func BackupAndRestoreWithId(t *testing.T, id string) func() {
|
|||||||
if err != nil && err.Error() != "exit status 1" {
|
if err != nil && err.Error() != "exit status 1" {
|
||||||
t.Fatalf("failed to execute killall hishtory, stdout=%#v: %v", string(stdout), err)
|
t.Fatalf("failed to execute killall hishtory, stdout=%#v: %v", string(stdout), err)
|
||||||
}
|
}
|
||||||
|
checkError(os.Chdir(initialWd))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user