@@ -37,7 +37,6 @@ import (
37
37
"sort"
38
38
"strconv"
39
39
"strings"
40
- "sync"
41
40
"time"
42
41
"unicode"
43
42
@@ -193,15 +192,11 @@ type failReason struct {
193
192
// -----------------------------------------------------------------------------
194
193
195
194
var (
196
- // GOPHERJS: Doesn't support `allCodegen` or `force`.
197
195
verbose = flag .Bool ("v" , false , "verbose. if set, parallelism is set to 1." )
198
- keep = flag .Bool ("k" , false , "keep. keep temporary directory." )
199
196
numParallel = flag .Int ("n" , runtime .NumCPU (), "number of parallel tests to run" )
200
197
summary = flag .Bool ("summary" , false , "show summary of results" )
201
198
showSkips = flag .Bool ("show_skips" , false , "show skipped tests" )
202
- runSkips = flag .Bool ("run_skips" , false , "run skipped tests (ignore skip and build tags)" )
203
- linkshared = flag .Bool ("linkshared" , false , "" )
204
- showKnownFails = flag .Bool ("show_known_fails" , false , "show full error output of known fails" ) // GOPHERJS: Added
199
+ showKnownFails = flag .Bool ("show_known_fails" , false , "show full error output of known fails" )
205
200
updateErrors = flag .Bool ("update_errors" , false , "update error messages in test file based on compiler output" )
206
201
runoutputLimit = flag .Int ("l" , defaultRunOutputLimit (), "number of parallel runoutput tests to run" )
207
202
@@ -248,16 +243,14 @@ func main() {
248
243
findExecCmd ()
249
244
250
245
// Disable parallelism if using a simulator.
251
- // GOPHERJS: Do not disable parallelism in verbose mode, since Go's file IO had internal
246
+ // Do not disable parallelism in verbose mode, since Go's file IO had internal
252
247
// r/w locking, which should make significant output garbling very unlikely.
253
- // GOPHERJS: CI setup runs these tests in verbose mode, but it can benefit from
248
+ // GopherJS CI setup runs these tests in verbose mode, but it can benefit from
254
249
// parallelism a lot.
255
250
if len (findExecCmd ()) > 0 {
256
251
* numParallel = 1
257
- * runoutputLimit = 1
258
252
}
259
253
260
- // GOPHERJS: Additional verbose output
261
254
if * verbose {
262
255
fmt .Printf ("goos: %q, goarch: %q\n " , goos , goarch )
263
256
fmt .Printf ("parallel: %d\n " , * numParallel )
@@ -322,7 +315,6 @@ func main() {
322
315
status = "FAIL"
323
316
}
324
317
if test .err != nil {
325
- // GOPHERJS: Ignore expectFail, see initExpectFail in original go/test/run.go
326
318
status = "FAIL"
327
319
errStr = test .err .Error ()
328
320
}
@@ -334,7 +326,6 @@ func main() {
334
326
failed = true
335
327
}
336
328
resCount [status ]++
337
- // GOPHERJS.
338
329
if status == "skip" && ! * verbose && ! * showSkips {
339
330
continue
340
331
}
@@ -369,22 +360,6 @@ func main() {
369
360
}
370
361
}
371
362
372
- // goTool reports the path of the go tool to use to run the tests.
373
- // If possible, use the same Go used to run run.go, otherwise
374
- // fallback to the go version found in the PATH.
375
- func goTool () string {
376
- var exeSuffix string
377
- if runtime .GOOS == "windows" {
378
- exeSuffix = ".exe"
379
- }
380
- path := filepath .Join (runtime .GOROOT (), "bin" , "go" + exeSuffix )
381
- if _ , err := os .Stat (path ); err == nil {
382
- return path
383
- }
384
- // Just run "go" from PATH
385
- return "go"
386
- }
387
-
388
363
func shardMatch (name string ) bool {
389
364
if * shards == 0 {
390
365
return true
@@ -396,14 +371,10 @@ func shardMatch(name string) bool {
396
371
397
372
func goFiles (dir string ) []string {
398
373
f , err := os .Open (dir )
399
- if err != nil {
400
- log .Fatal (err )
401
- }
374
+ check (err )
402
375
dirnames , err := f .Readdirnames (- 1 )
403
376
f .Close ()
404
- if err != nil {
405
- log .Fatal (err )
406
- }
377
+ check (err )
407
378
names := []string {}
408
379
for _ , name := range dirnames {
409
380
if ! strings .HasPrefix (name , "." ) && strings .HasSuffix (name , ".go" ) && shardMatch (name ) {
@@ -416,80 +387,21 @@ func goFiles(dir string) []string {
416
387
417
388
type runCmd func (... string ) ([]byte , error )
418
389
419
- func compileFile (runcmd runCmd , longname string , flags []string ) (out []byte , err error ) {
420
- cmd := []string {goTool (), "tool" , "compile" , "-e" , "-p=p" , "-importcfg=" + stdlibImportcfgFile ()}
421
- cmd = append (cmd , flags ... )
422
- if * linkshared {
423
- cmd = append (cmd , "-dynlink" , "-installsuffix=dynlink" )
424
- }
425
- cmd = append (cmd , longname )
426
- return runcmd (cmd ... )
390
+ func compileFile (runcmd runCmd , longname string ) (out []byte , err error ) {
391
+ return runcmd ("go" , "tool" , "compile" , "-e" , longname )
427
392
}
428
393
429
- func compileInDir (runcmd runCmd , dir string , flags []string , importcfg string , pkgname string , names ... string ) (out []byte , err error ) {
430
- if importcfg == "" {
431
- importcfg = stdlibImportcfgFile ()
432
- }
433
- cmd := []string {goTool (), "tool" , "compile" , "-e" , "-D" , "test" , "-importcfg=" + importcfg }
434
- if pkgname == "main" {
435
- cmd = append (cmd , "-p=main" )
436
- } else {
437
- pkgname = path .Join ("test" , strings .TrimSuffix (names [0 ], ".go" ))
438
- cmd = append (cmd , "-o" , pkgname + ".a" , "-p" , pkgname )
439
- }
440
- cmd = append (cmd , flags ... )
441
- if * linkshared {
442
- cmd = append (cmd , "-dynlink" , "-installsuffix=dynlink" )
443
- }
394
+ func compileInDir (runcmd runCmd , dir string , names ... string ) (out []byte , err error ) {
395
+ cmd := []string {"go" , "tool" , "compile" , "-e" , "-D" , "." , "-I" , "." }
444
396
for _ , name := range names {
445
397
cmd = append (cmd , filepath .Join (dir , name ))
446
398
}
447
399
return runcmd (cmd ... )
448
400
}
449
401
450
- var stdlibImportcfgString string
451
- var stdlibImportcfgFilename string
452
- var cfgonce sync.Once
453
- var fileonce sync.Once
454
-
455
- func stdlibImportcfg () string {
456
- cfgonce .Do (func () {
457
- output , err := exec .Command (goTool (), "list" , "-export" , "-f" , "{{if .Export}}packagefile {{.ImportPath}}={{.Export}}{{end}}" , "std" ).Output ()
458
- if err != nil {
459
- log .Fatal (err )
460
- }
461
- stdlibImportcfgString = string (output )
462
- })
463
- return stdlibImportcfgString
464
- }
465
-
466
- func stdlibImportcfgFile () string {
467
- fileonce .Do (func () {
468
- tmpdir , err := os .MkdirTemp ("" , "importcfg" )
469
- if err != nil {
470
- log .Fatal (err )
471
- }
472
- filename := filepath .Join (tmpdir , "importcfg" )
473
- os .WriteFile (filename , []byte (stdlibImportcfg ()), 0644 )
474
- stdlibImportcfgFilename = filename
475
- })
476
- return stdlibImportcfgFilename
477
- }
478
-
479
- func linkFile (runcmd runCmd , goname string , importcfg string , ldflags []string ) (err error ) {
480
- if importcfg == "" {
481
- importcfg = stdlibImportcfgFile ()
482
- }
402
+ func linkFile (runcmd runCmd , goname string ) (err error ) {
483
403
pfile := strings .Replace (goname , ".go" , ".o" , - 1 )
484
- cmd := []string {goTool (), "tool" , "link" , "-w" , "-o" , "a.exe" , "-importcfg=" + importcfg }
485
- if * linkshared {
486
- cmd = append (cmd , "-linkshared" , "-installsuffix=dynlink" )
487
- }
488
- if ldflags != nil {
489
- cmd = append (cmd , ldflags ... )
490
- }
491
- cmd = append (cmd , pfile )
492
- _ , err = runcmd (cmd ... )
404
+ _ , err = runcmd ("go" , "tool" , "link" , "-w" , "-o" , "a.exe" , "-L" , "." , pfile )
493
405
return
494
406
}
495
407
@@ -498,6 +410,12 @@ type skipError string
498
410
499
411
func (s skipError ) Error () string { return string (s ) }
500
412
413
+ func check (err error ) {
414
+ if err != nil {
415
+ log .Fatal (err )
416
+ }
417
+ }
418
+
501
419
// test holds the state of a test.
502
420
type test struct {
503
421
dir , gofile string
@@ -509,10 +427,9 @@ type test struct {
509
427
510
428
tempDir string
511
429
err error
512
-
513
- // GOPHERJS: Skipping expectFail, see initExpectFail in go/test/run.go
514
430
}
515
431
432
+ // startTest
516
433
func startTest (dir , gofile string ) * test {
517
434
t := & test {
518
435
dir : dir ,
@@ -555,7 +472,7 @@ func (t *test) goDirName() string {
555
472
}
556
473
557
474
func goDirFiles (longdir string ) (filter []os.DirEntry , err error ) {
558
- files , dirErr := os .ReadDir (longdir ) // GOPHERJS: Updated to not use deprecated ioutil.ReadDir
475
+ files , dirErr := os .ReadDir (longdir )
559
476
if dirErr != nil {
560
477
return nil , dirErr
561
478
}
@@ -615,8 +532,6 @@ func goDirPackages(longdir string, singlefilepkgs bool) ([]*goDirPkg, error) {
615
532
type context struct {
616
533
GOOS string
617
534
GOARCH string
618
- // GOPHERJS: Doesn't support `cgoEnabled` related to CGO_ENABLED
619
- // GOPHERJS: Doesn't support `noOptEnv` related to GO_GCFLAGS
620
535
}
621
536
622
537
// shouldTest looks for build tags in a source file and returns
@@ -702,7 +617,7 @@ func (t *test) run() {
702
617
return
703
618
}
704
619
705
- srcBytes , err := os .ReadFile (t .goFileName ()) // GOPHERJS: Updated to no use deprecated ioutil.ReadFile
620
+ srcBytes , err := os .ReadFile (t .goFileName ())
706
621
if err != nil {
707
622
t .err = err
708
623
return
0 commit comments