@@ -23,6 +23,8 @@ import (
23
23
"strings"
24
24
"time"
25
25
26
+ "golang.org/x/benchmarks/sweet/common/fileutil"
27
+
26
28
"github.com/BurntSushi/toml"
27
29
)
28
30
@@ -78,7 +80,6 @@ var runContainer = "" // if nonempty, skip builds and use existing named c
78
80
var wikiTable = false // emit the tests in a form usable in a wiki table
79
81
var explicitAll counterFlag // Include "-a" on "go test -c" test build ; repeating flag causes multiple rebuilds, useful for build benchmarking.
80
82
var shuffle = 2 // Dimensionality of (build) shuffling; 0 = none, 1 = per-benchmark, configuration ordering, 2 = bench, config pairs, 3 = across repetitions.
81
- var haveRsync = true
82
83
var reportBuildTime = true
83
84
var experiment = false // Don't reset go.mod, for testing purposes
84
85
var minGoVersion = "1.22" // This is the release the toolchain started caring about versions of Go that are too new.
@@ -234,12 +235,6 @@ results will also appear in 'bench'.
234
235
os .Exit (1 )
235
236
}
236
237
237
- _ , errRsync := exec .LookPath ("rsync" )
238
- if errRsync != nil {
239
- haveRsync = false
240
- fmt .Println ("Warning: using cp instead of rsync" )
241
- }
242
-
243
238
if requireSandbox {
244
239
_ , errDocker := exec .LookPath ("docker" )
245
240
if errDocker != nil {
@@ -680,23 +675,9 @@ results will also appear in 'bench'.
680
675
todo .Configurations [ci ] = config
681
676
682
677
docopy := func (from , to string ) {
683
- mkdir := exec .Command ("mkdir" , "-p" , to )
684
- s , _ := config .runBinary ("" , mkdir , false )
685
- if s != "" {
686
- fmt .Println ("Error creating directory, " , to )
687
- config .Disabled = true
688
- }
689
-
690
- var cp * exec.Cmd
691
- if haveRsync {
692
- cp = exec .Command ("rsync" , "-a" , from + "/" , to )
693
- } else {
694
- cp = exec .Command ("cp" , "-a" , from + "/." , to )
695
- }
696
- s , _ = config .runBinary ("" , cp , false )
697
- if s != "" {
698
- fmt .Println ("Error copying directory tree, " , from , to )
699
- // Not disabling because gollvm uses a different directory structure
678
+ fileutil .CopyDir (to , from , nil )
679
+ if verbose > 0 || err != nil {
680
+ fmt .Printf ("rsync -a %s %s, error=%v\n " , from , to , err )
700
681
}
701
682
}
702
683
@@ -926,23 +907,29 @@ benchmarks_loop:
926
907
testdata := path .Join (rundir , subdir )
927
908
if stat , err := os .Stat (testdata ); err == nil {
928
909
testdataCopy := path .Join (bench .RunDir , subdir )
929
- var cp * exec.Cmd
910
+ var err error
911
+ var commandLine string
930
912
os .RemoveAll (testdataCopy ) // clean out what can be cleaned
931
913
if stat .IsDir () {
932
914
if verbose > 0 {
933
915
fmt .Printf ("mkdir -p %s\n " , testdataCopy )
934
916
}
935
917
os .Mkdir (testdataCopy , fs .FileMode (0755 ))
936
- cp = copyCommand (testdata , testdataCopy )
918
+ err = fileutil .CopyDir (testdataCopy , testdata , nil )
919
+ if verbose > 0 || err != nil {
920
+ commandLine = fmt .Sprintf ("rsync -a %s/ %s" , testdata , testdataCopy )
921
+ }
937
922
} else {
938
- cp = copyFile (testdata , testdataCopy )
923
+ err = fileutil .CopyFile (testdataCopy , testdata , nil , nil )
924
+ if verbose > 0 || err != nil {
925
+ commandLine = fmt .Sprintf ("cp -p %s %s" , testdata , testdataCopy )
926
+ }
939
927
}
940
928
if verbose > 0 {
941
- fmt .Println (asCommandLine ( dirs . wd , cp ) )
929
+ fmt .Println (commandLine )
942
930
}
943
- _ , err := cp .Output ()
944
931
if err != nil {
945
- s := fmt .Sprintf (`could not %s, err=%v` , asCommandLine ( dirs . wd , cp ) , err )
932
+ s := fmt .Sprintf (`could not %s, err=%v` , commandLine , err )
946
933
fmt .Println (s + "\n DISABLING benchmark " + bench .Name )
947
934
getAndBuildFailures = append (getAndBuildFailures , s + "(" + bench .Name + ")\n " )
948
935
todo .Benchmarks [i ].Disabled = true
@@ -1294,18 +1281,6 @@ ADD . /
1294
1281
return nil
1295
1282
}
1296
1283
1297
- func copyCommand (from , to string ) * exec.Cmd {
1298
- if haveRsync {
1299
- return exec .Command ("rsync" , "-a" , from + "/" , to )
1300
- } else {
1301
- return exec .Command ("cp" , "-a" , from + "/." , to )
1302
- }
1303
- }
1304
-
1305
- func copyFile (from , to string ) * exec.Cmd {
1306
- return exec .Command ("cp" , "-p" , from , to )
1307
- }
1308
-
1309
1284
func copyAsset (fs embed.FS , dir , file string ) {
1310
1285
f , err := fs .Open (path .Join (dir , file ))
1311
1286
if err != nil {
0 commit comments