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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
package gtest
import (
"log"
"os"
"path"
"golang.flu0r1ne.net/planr"
)
const GTEST_CMAKE = "CMakeLists.txt"
func safeWd() string{
wd, err := os.Getwd()
if err != nil {
log.Fatalf("Could not get GtestBuildDir %s %v\n", wd, err)
}
return wd
}
type Adapter struct {
dirs planr.DirConfig
}
func (a *Adapter) Config() planr.AdapterConfig {
return planr.AdapterConfig {
Name: "gtest",
ParseConfig: ParseConfig,
ParseDefaultConfig: ParseDefaultConfig,
}
}
func (a *Adapter) Init(dirs planr.DirConfig) {
a.dirs = dirs
}
func (adapter Adapter) Build(tcs []planr.TestCase) {
buildDir := safeWd()
finalizeConfigs(tcs)
exes := createExecutables(tcs)
cmakeFile := path.Join(buildDir, GTEST_CMAKE)
cmakeUnits := cmakeUnits(exes, adapter.dirs)
generateCmakeScript(cmakeFile, cmakeUnits)
planr.RunCmd("cmake", "-S", ".", "-B", ".")
}
func (adapter *Adapter) Evaluate(tcs []planr.TestCase) [] planr.TestResult {
buildDir := safeWd()
finalizeConfigs(tcs)
results := make([]planr.TestResult, 0)
exes := createExecutables(tcs)
for i := range exes {
succeed, buildFailures := exes[i].compile(buildDir)
if ! succeed {
results = append(results, buildFailures...)
continue
}
runtimeResults := exes[i].execute(buildDir)
results = append(results, runtimeResults...)
}
return results
}
func NewAdapter() *Adapter {
return new(Adapter)
}
|