mirror of https://github.com/databricks/cli.git
tests: Improve reporting in case of FS errors (#2216)
## Changes If there are unreadable files in a directory, raise an error but continue with further diagnostics, because the answer is in the script output. ## Tests Manually - I'm working on some tests that create unreadable files, the report is much better with this change.
This commit is contained in:
parent
798189eb96
commit
1f63aa0912
|
@ -232,8 +232,7 @@ func runTest(t *testing.T, dir, coverDir string, repls testdiff.ReplacementsCont
|
|||
}
|
||||
|
||||
// Make sure there are not unaccounted for new files
|
||||
files, err := ListDir(t, tmpDir)
|
||||
require.NoError(t, err)
|
||||
files := ListDir(t, tmpDir)
|
||||
for _, relPath := range files {
|
||||
if _, ok := inputs[relPath]; ok {
|
||||
continue
|
||||
|
@ -450,11 +449,15 @@ func CopyDir(src, dst string, inputs, outputs map[string]bool) error {
|
|||
})
|
||||
}
|
||||
|
||||
func ListDir(t *testing.T, src string) ([]string, error) {
|
||||
func ListDir(t *testing.T, src string) []string {
|
||||
var files []string
|
||||
err := filepath.Walk(src, func(path string, info os.FileInfo, err error) error {
|
||||
if err != nil {
|
||||
return err
|
||||
// Do not FailNow here.
|
||||
// The output comparison is happening after this call which includes output.txt which
|
||||
// includes errors printed by commands which include explanation why a given file cannot be read.
|
||||
t.Errorf("Error when listing %s: path=%s: %s", src, path, err)
|
||||
return nil
|
||||
}
|
||||
|
||||
if info.IsDir() {
|
||||
|
@ -469,5 +472,8 @@ func ListDir(t *testing.T, src string) ([]string, error) {
|
|||
files = append(files, relPath)
|
||||
return nil
|
||||
})
|
||||
return files, err
|
||||
if err != nil {
|
||||
t.Errorf("Failed to list %s: %s", src, err)
|
||||
}
|
||||
return files
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue