Add todo, extra debugging output for failing mac test, and a check on resp.StatusCode

This commit is contained in:
David Dworken 2022-04-18 21:28:41 -07:00
parent 97f5368954
commit 1cc36fa0ef
2 changed files with 7 additions and 1 deletions

View File

@ -680,7 +680,7 @@ echo hello2
tester.RunInteractiveShell(t, " echo hidden")
out := hishtoryQuery(t, tester, "-pipefail")
if strings.Count(out, "\n") != 3 {
t.Fatalf("hishtory query has the wrong number of lines=%d, out=%#v", strings.Count(out, "\n"), out)
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"))
}
if strings.Count(out, "echo hello") != 2 {
t.Fatalf("hishtory query has the wrong number of commands=%d, out=%#v", strings.Count(out, "echo mycommand"), out)
@ -702,6 +702,8 @@ echo hello2
}
}
// TODO: Timestamps for bash on macos appear to be currently broken, debug this. Example: https://github.com/ddworken/hishtory/runs/6059464342?check_suite_focus=true
func getPidofCommand() string {
if runtime.GOOS == "darwin" {
// MacOS doesn't have pidof by default

View File

@ -552,6 +552,9 @@ func downloadFile(filename, url string) error {
return fmt.Errorf("failed to download file at %s to %s: %v", url, filename, err)
}
defer resp.Body.Close()
if resp.StatusCode != 200 {
return fmt.Errorf("failed to download file at %s due to resp_code=%d", url, resp.StatusCode)
}
out, err := os.Create(filename)
if err != nil {
@ -560,6 +563,7 @@ func downloadFile(filename, url string) error {
defer out.Close()
_, err = io.Copy(out, resp.Body)
return err
}