lang, util: Tests that depend on the fs should be sorted
This ensures they're deterministic on any file system.
This commit is contained in:
@@ -546,11 +546,16 @@ func TestAstFunc1(t *testing.T) {
|
||||
t.Errorf("FAIL: could not read through tests directory: %+v", err)
|
||||
return
|
||||
}
|
||||
sorted := []string{}
|
||||
for _, f := range files {
|
||||
if !f.IsDir() {
|
||||
continue
|
||||
}
|
||||
graphFile := f.Name() + ".graph" // expected graph file
|
||||
sorted = append(sorted, f.Name())
|
||||
}
|
||||
sort.Strings(sorted)
|
||||
for _, f := range sorted {
|
||||
graphFile := f + ".graph" // expected graph file
|
||||
graphFileFull := dir + graphFile
|
||||
info, err := os.Stat(graphFileFull)
|
||||
if err != nil || info.IsDir() {
|
||||
@@ -574,12 +579,12 @@ func TestAstFunc1(t *testing.T) {
|
||||
|
||||
// add automatic test case
|
||||
testCases = append(testCases, test{
|
||||
name: fmt.Sprintf("dir: %s", f.Name()),
|
||||
path: f.Name() + "/",
|
||||
name: fmt.Sprintf("dir: %s", f),
|
||||
path: f + "/",
|
||||
fail: errStr != "",
|
||||
expstr: str,
|
||||
})
|
||||
//t.Logf("adding: %s", f.Name() + "/")
|
||||
//t.Logf("adding: %s", f + "/")
|
||||
}
|
||||
|
||||
names := []string{}
|
||||
|
||||
@@ -23,6 +23,7 @@ import (
|
||||
"bytes"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"sort"
|
||||
"testing"
|
||||
|
||||
"github.com/spf13/afero"
|
||||
@@ -129,11 +130,16 @@ func TestCopyDiskToFs1(t *testing.T) {
|
||||
t.Errorf("could not read through tests directory: %+v", err)
|
||||
return
|
||||
}
|
||||
sorted := []string{}
|
||||
for _, f := range files {
|
||||
if !f.IsDir() {
|
||||
continue
|
||||
}
|
||||
treeFile := f.Name() + ".tree" // expected tree file
|
||||
sorted = append(sorted, f.Name())
|
||||
}
|
||||
sort.Strings(sorted)
|
||||
for _, f := range sorted {
|
||||
treeFile := f + ".tree" // expected tree file
|
||||
treeFileFull := dir + treeFile
|
||||
info, err := os.Stat(treeFileFull)
|
||||
if err != nil || info.IsDir() {
|
||||
@@ -153,7 +159,7 @@ func TestCopyDiskToFs1(t *testing.T) {
|
||||
afs := &afero.Afero{Fs: mmFs} // wrap so that we're implementing ioutil
|
||||
fs := &Fs{afs}
|
||||
|
||||
if err := CopyDiskToFs(fs, dir+f.Name()+"/", "/", false); err != nil {
|
||||
if err := CopyDiskToFs(fs, dir+f+"/", "/", false); err != nil {
|
||||
t.Errorf("copying to fs failed: %+v", err)
|
||||
return
|
||||
}
|
||||
@@ -185,11 +191,16 @@ func TestCopyDiskContentsToFs1(t *testing.T) {
|
||||
t.Errorf("could not read through tests directory: %+v", err)
|
||||
return
|
||||
}
|
||||
sorted := []string{}
|
||||
for _, f := range files {
|
||||
if !f.IsDir() {
|
||||
continue
|
||||
}
|
||||
treeFile := f.Name() + ".tree" // expected tree file
|
||||
sorted = append(sorted, f.Name())
|
||||
}
|
||||
sort.Strings(sorted)
|
||||
for _, f := range sorted {
|
||||
treeFile := f + ".tree" // expected tree file
|
||||
treeFileFull := dir + treeFile
|
||||
info, err := os.Stat(treeFileFull)
|
||||
if err != nil || info.IsDir() {
|
||||
@@ -209,7 +220,7 @@ func TestCopyDiskContentsToFs1(t *testing.T) {
|
||||
afs := &afero.Afero{Fs: mmFs} // wrap so that we're implementing ioutil
|
||||
fs := &Fs{afs}
|
||||
|
||||
if err := CopyDiskContentsToFs(fs, dir+f.Name()+"/", "/", false); err != nil {
|
||||
if err := CopyDiskContentsToFs(fs, dir+f+"/", "/", false); err != nil {
|
||||
t.Errorf("copying to fs failed: %+v", err)
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user