@@ -12,8 +12,13 @@ import (
12
12
"text/template"
13
13
)
14
14
15
+ const (
16
+ testGOOS = "linux"
17
+ testGOARCH = "amd64"
18
+ )
19
+
15
20
// The environment to pass to `go` commands when they are invoked.
16
- var commandEnv = []string {"GOPATH=/does-not-exist" , "GO111MODULE=off" }
21
+ var commandEnv = []string {"GOPATH=/does-not-exist" , "GO111MODULE=off" , "GOOS=" + testGOOS , "GOARCH=" + testGOARCH }
17
22
18
23
var markdownTemplate = template .Must (template .New ("markdown" ).Parse (`
19
24
---
@@ -24,11 +29,13 @@ The following table shows all Go standard library packages and whether they can
24
29
25
30
Note that the fact they can be imported, does not mean that all functions and types in the program can be used. For example, sometimes using some functions or types of the package will still trigger compiler errors.
26
31
32
+ Test results are for {{.goos}}/{{.goarch}}.
33
+
27
34
Package | Importable | Passes tests
28
- --- | --- | --- |{{ range .}}
35
+ --- | --- | --- |{{ range .pkgs }}
29
36
{{.Path}} | {{if .CanBeCompiled}} <span style="color: green">✔</span> yes {{else}} [<span style="color: red">✗</span> no](#{{.Link}}) {{end}} | {{if .PassesTests}} <span style="color: green">✔</span> yes {{else if .CanBeCompiled}} [<span style="color: red">✗</span> no](#{{.Link}}) {{else}} <span style="color: gray">✗</span> no {{end}} | {{ end }}
30
37
31
- {{range .}}
38
+ {{range .pkgs }}
32
39
{{if not .PassesTests }}
33
40
## {{.Path}}
34
41
@@ -234,7 +241,11 @@ func checkPackages(goroot string) error {
234
241
}
235
242
236
243
// Print the output to stdout.
237
- return markdownTemplate .Execute (os .Stdout , pkgMap )
244
+ return markdownTemplate .Execute (os .Stdout , map [string ]interface {}{
245
+ "pkgs" : pkgMap ,
246
+ "goos" : testGOOS ,
247
+ "goarch" : testGOARCH ,
248
+ })
238
249
}
239
250
240
251
func (pkg * Package ) runTest () (result testResult ) {
@@ -252,6 +263,7 @@ func (pkg *Package) runTest() (result testResult) {
252
263
253
264
// Run the compile test.
254
265
cmd := exec .Command ("tinygo" , "build" , "-o" , temporaryExecutableFile , temporaryGoFile )
266
+ cmd .Env = append (cmd .Environ (), "GOOS=" + testGOOS , "GOARCH=" + testGOARCH )
255
267
buf := new (bytes.Buffer )
256
268
cmd .Stdout = buf
257
269
cmd .Stderr = buf
@@ -261,6 +273,7 @@ func (pkg *Package) runTest() (result testResult) {
261
273
// Run the actual test.
262
274
if result .compiles {
263
275
cmd := exec .Command ("tinygo" , "test" , pkg .Path )
276
+ cmd .Env = append (cmd .Environ (), "GOOS=" + testGOOS , "GOARCH=" + testGOARCH )
264
277
buf := new (bytes.Buffer )
265
278
cmd .Stdout = buf
266
279
cmd .Stderr = buf
0 commit comments