forked from mandoway/seru
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain_test.go
More file actions
47 lines (41 loc) · 1.05 KB
/
main_test.go
File metadata and controls
47 lines (41 loc) · 1.05 KB
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
package main
import (
"os"
"path"
"path/filepath"
"testing"
"github.com/mandoway/seru/reduction"
"github.com/mandoway/seru/reduction/context"
)
func TestReduction(t *testing.T) {
if testing.Short() {
t.Skip("skipping test in short mode.")
}
aCtx := context.NewAlgorithmConfig(false, 0, nil)
dir := path.Join("test", "instances", "error", "issue_2246", "v1")
ctx, err := context.NewRunContext("cue", path.Join(dir, "in.cue"), path.Join(dir, "test.sh"), "", *aCtx)
if err != nil {
t.Fatal(err)
}
err = reduction.RunMainReductionLoop(ctx, false)
if err != nil {
t.Fatal(err)
}
reducedFile := ctx.BestResult().InputPath
if _, err := os.Stat(reducedFile); err == nil {
matches, err := filepath.Glob(context.RunContextFolderPrefix + "*")
t.Logf("Files successfully created, deleting %d matches...", len(matches))
if err != nil {
return
}
for _, match := range matches {
t.Logf("Deleting %s", match)
err := os.RemoveAll(match)
if err != nil {
return
}
}
} else {
t.Errorf("File does not exist, %s", reducedFile)
}
}