@@ -23,6 +23,8 @@ import (
2323 "strings"
2424 "time"
2525
26+ "golang.org/x/benchmarks/sweet/common/fileutil"
27+
2628 "github.com/BurntSushi/toml"
2729)
2830
@@ -78,7 +80,6 @@ var runContainer = "" // if nonempty, skip builds and use existing named c
7880var wikiTable = false // emit the tests in a form usable in a wiki table
7981var explicitAll counterFlag // Include "-a" on "go test -c" test build ; repeating flag causes multiple rebuilds, useful for build benchmarking.
8082var shuffle = 2 // Dimensionality of (build) shuffling; 0 = none, 1 = per-benchmark, configuration ordering, 2 = bench, config pairs, 3 = across repetitions.
81- var haveRsync = true
8283var reportBuildTime = true
8384var experiment = false // Don't reset go.mod, for testing purposes
8485var 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'.
234235 os .Exit (1 )
235236 }
236237
237- _ , errRsync := exec .LookPath ("rsync" )
238- if errRsync != nil {
239- haveRsync = false
240- fmt .Println ("Warning: using cp instead of rsync" )
241- }
242-
243238 if requireSandbox {
244239 _ , errDocker := exec .LookPath ("docker" )
245240 if errDocker != nil {
@@ -680,23 +675,9 @@ results will also appear in 'bench'.
680675 todo .Configurations [ci ] = config
681676
682677 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 )
700681 }
701682 }
702683
@@ -926,23 +907,29 @@ benchmarks_loop:
926907 testdata := path .Join (rundir , subdir )
927908 if stat , err := os .Stat (testdata ); err == nil {
928909 testdataCopy := path .Join (bench .RunDir , subdir )
929- var cp * exec.Cmd
910+ var err error
911+ var commandLine string
930912 os .RemoveAll (testdataCopy ) // clean out what can be cleaned
931913 if stat .IsDir () {
932914 if verbose > 0 {
933915 fmt .Printf ("mkdir -p %s\n " , testdataCopy )
934916 }
935917 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+ }
937922 } 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+ }
939927 }
940928 if verbose > 0 {
941- fmt .Println (asCommandLine ( dirs . wd , cp ) )
929+ fmt .Println (commandLine )
942930 }
943- _ , err := cp .Output ()
944931 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 )
946933 fmt .Println (s + "\n DISABLING benchmark " + bench .Name )
947934 getAndBuildFailures = append (getAndBuildFailures , s + "(" + bench .Name + ")\n " )
948935 todo .Benchmarks [i ].Disabled = true
@@ -1294,18 +1281,6 @@ ADD . /
12941281 return nil
12951282}
12961283
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-
13091284func copyAsset (fs embed.FS , dir , file string ) {
13101285 f , err := fs .Open (path .Join (dir , file ))
13111286 if err != nil {
0 commit comments