forked from therecipe/qt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.go
186 lines (147 loc) · 5.73 KB
/
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
package setup
import (
"fmt"
"os"
"os/exec"
"path/filepath"
"runtime"
"strings"
"github.com/dsandor/qt/internal/binding/parser"
"github.com/dsandor/qt/internal/binding/templater"
"github.com/dsandor/qt/internal/cmd"
"github.com/dsandor/qt/internal/cmd/deploy"
"github.com/dsandor/qt/internal/cmd/minimal"
"github.com/dsandor/qt/internal/cmd/moc"
"github.com/dsandor/qt/internal/cmd/rcc"
"github.com/dsandor/qt/internal/utils"
)
func Test(target string, docker, vagrant bool, vagrantsystem string) {
utils.Log.Infof("running: 'qtsetup test %v' [docker=%v] [vagrant=%v]", target, docker, vagrant)
if utils.CI() && target == runtime.GOOS && !(runtime.GOOS == "windows" || utils.QT_STATIC()) && !utils.QT_GEN_GO_WRAPPER() { //TODO: test on windows
utils.Log.Infof("running setup/test %v CI", target)
path := utils.GoQtPkgPath("internal", "cmd", "moc", "test")
moc.Moc(path, target, "", false, false, false, true)
minimal.Minimal(path, target, "", true)
var pattern string
if utils.GOVERSION_NUM() >= 110 {
pattern = "all="
}
cmd := exec.Command("go", "test", "-v", "-tags=minimal", fmt.Sprintf("-ldflags=%v\"-s\"", pattern), "-race")
cmd.Env = append(os.Environ(), []string{"GODEBUG=cgocheck=2", "GO111MODULE=off"}...)
if runtime.GOOS == "linux" {
cmd.Env = append(cmd.Env, "QT_QPA_PLATFORM=offscreen")
}
cmd.Dir = path
utils.RunCmd(cmd, "run \"go test\"")
parser.State.ClassMap = make(map[string]*parser.Class)
rcc.ResourceNames = make(map[string]string)
moc.ResourceNames = make(map[string]string)
}
mode := "test"
var examples map[string][]string
if utils.CI() {
mode = "build"
examples = map[string][]string{
"androidextras": []string{"jni", "notification"},
"canvas3d": []string{"framebuffer", "interaction", "jsonmodels",
"quickitemtexture", "textureandlight",
filepath.Join("threejs", "cellphone"),
filepath.Join("threejs", "oneqt"),
filepath.Join("threejs", "planets"),
},
"charts": []string{"audio", "dynamicspline", "modeldata"},
"common": []string{"qml_demo", "widgets_demo"},
//"grpc": []string{"hello_world","hello_world2"}, //TODO: re-gen protobuf go files
//"gui": []string{"analogclock", "openglwindow", "rasterwindow"},
//"opengl": []string{"2dpainting"},
"qml": []string{"adding", "application",
"custom_scheme", "drawer_nav_x",
filepath.Join("extending", "chapter1-basics"),
filepath.Join("extending", "chapter2-methods"),
filepath.Join("extending", "chapter3-bindings"),
filepath.Join("extending", "chapter4-customPropertyTypes"),
filepath.Join("extending", "components", "test_dir"),
filepath.Join("extending", "components", "test_dir_2"),
filepath.Join("extending", "components", "test_go"),
filepath.Join("extending", "components", "test_module"),
filepath.Join("extending", "components", "test_module_2"),
filepath.Join("extending", "components", "test_qml"),
filepath.Join("extending", "components", "test_qml_go"),
"gallery", "material",
"prop", "prop2" /*"webview"*/},
"qt3d": []string{"audio-visualizer-qml"},
"quick": []string{"bridge", "bridge2", "calc" /*"cookies"*/, "dialog", "dynamic",
"hotreload", "listview", "photoviewer", "sailfish", "tableview", "translate", "view"},
"sailfish": []string{"listview", "listview_variant"},
"sensors": []string{"accelbubble"},
"showcases": []string{"wallet"},
"sql": []string{"masterdetail", "masterdetail_qml", "querymodel"},
"uitools": []string{"calculator", "calculator_manual"},
"virtualkeyboard": []string{"qml", "widgets", "widgets_embedded"},
"webchannel": []string{"chatserver-go" /*"standalone" "webview"*/},
//"webkit": []string{"browser"},
"widgets": []string{"bridge2" /*"dropsite"*/, "graphicsscene", "line_edits", "pixel_editor",
/*"renderer"*/ "share", "systray" /*"table"*/, "textedit",
filepath.Join("treeview", "treeview_dual"), filepath.Join("treeview", "treeview_filelist"),
"video_player" /*"webengine"*/, "xkcd"},
}
} else {
if strings.HasPrefix(target, "sailfish") {
examples = map[string][]string{
"quick": []string{"sailfish"},
"sailfish": []string{"listview", "listview_variant"},
}
} else {
examples = map[string][]string{
"showcases": []string{"wallet"},
"qml": []string{"gallery"},
"quick": []string{"calc"},
"widgets": []string{"textedit"},
}
}
}
if utils.QT_VAGRANT() && target == "ios-simulator" {
mode = "build"
}
for cat, list := range examples {
for _, example := range list {
if target != runtime.GOOS && (example == "textedit" || example == "wallet") {
continue
}
if cat == "virtualkeyboard" && (strings.Contains(target, "ios") || strings.Contains(target, "android")) {
continue
}
if (target == "js" || target == "wasm") &&
(cat == "charts" || cat == "uitools" || cat == "sql" ||
cat == "androidextras" || cat == "qt3d" || cat == "webchannel" ||
strings.HasPrefix(example, "treeview") ||
example == "video_player" || example == "custom_scheme") {
continue
}
if example == "wallet" && target == runtime.GOOS && runtime.GOOS == "windows" {
continue
}
example := filepath.Join(cat, example)
path := filepath.Join(strings.TrimSpace(utils.GoListOptional("{{.Dir}}", "github.com/dsandor/qt/internal/examples", "-find", "get doc dir")), example)
utils.Log.Infof("testing %v", example)
deploy.Deploy(
mode,
target,
path,
docker,
"",
"",
false,
"",
vagrant,
vagrantsystem,
false,
true,
false, //TODO: re-enable once quickcompiler files can be properly cleaned up automatically !strings.HasPrefix(target, "sailfish"),
)
templater.CleanupDepsForCI()
templater.CleanupDepsForCI = func() {}
cmd.CleanupRegisteredImportsForCI()
}
}
}