-
Notifications
You must be signed in to change notification settings - Fork 0
/
loaderEngine_test_test.go
64 lines (49 loc) · 1.14 KB
/
loaderEngine_test_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package langd
import (
"path/filepath"
"runtime"
"testing"
"github.com/spf13/afero"
)
func Test_Loader_Load_Tests(t *testing.T) {
srcBar := `package bar
var BarVal int = 0`
srcBarTest := `package bar
import "../foo"
func Test_Bar() {
BarVal = foo.FooVal
}
`
srcFoo := `package foo
var FooVal int = 1`
rootPath, overlayFs := createOverlay(map[string]string{
filepath.Join("bar", "bar.go"): srcBar,
filepath.Join("bar", "bar_test.go"): srcBarTest,
filepath.Join("foo", "foo.go"): srcFoo,
})
barPath := filepath.Join(rootPath, "bar")
le := NewLoaderEngine()
defer le.Close()
l := NewLoader(le, "darwin", "x86", runtime.GOROOT(), func(l *Loader) {
l.fs = afero.NewCopyOnWriteFs(l.fs, overlayFs)
})
err := l.LoadDirectory(barPath)
if err != nil {
t.Fatalf("(1) Error while loading: %s", err.Error())
}
l.Wait()
errCount := 0
fn := func(file string, errs []FileError) {
if errCount == 0 {
t.Errorf("Loading error in %s:\n", file)
}
for k, err := range errs {
t.Errorf("\t%d: %s\n", k, err.Message)
}
errCount++
}
l.Errors(fn)
if errCount != 0 {
t.Fatalf("Found %d errors", errCount)
}
}