@@ -866,12 +866,54 @@ func (tg *testgoData) failSSH() {
866
866
867
867
func TestNewReleaseRebuildsStalePackagesInGOPATH (t * testing.T ) {
868
868
if testing .Short () {
869
- t .Skip ("don't rebuild the standard library in short mode" )
869
+ t .Skip ("skipping lengthy test in short mode" )
870
870
}
871
871
872
872
tg := testgo (t )
873
873
defer tg .cleanup ()
874
874
875
+ // Copy the runtime packages into a temporary GOROOT
876
+ // so that we can change files.
877
+ for _ , copydir := range []string {
878
+ "src/runtime" ,
879
+ "src/internal/bytealg" ,
880
+ "src/internal/cpu" ,
881
+ "src/unsafe" ,
882
+ filepath .Join ("pkg" , runtime .GOOS + "_" + runtime .GOARCH ),
883
+ filepath .Join ("pkg/tool" , runtime .GOOS + "_" + runtime .GOARCH ),
884
+ "pkg/include" ,
885
+ } {
886
+ srcdir := filepath .Join (testGOROOT , copydir )
887
+ tg .tempDir (filepath .Join ("goroot" , copydir ))
888
+ err := filepath .Walk (srcdir ,
889
+ func (path string , info os.FileInfo , err error ) error {
890
+ if err != nil {
891
+ return err
892
+ }
893
+ if info .IsDir () {
894
+ return nil
895
+ }
896
+ srcrel , err := filepath .Rel (srcdir , path )
897
+ if err != nil {
898
+ return err
899
+ }
900
+ dest := filepath .Join ("goroot" , copydir , srcrel )
901
+ data , err := ioutil .ReadFile (path )
902
+ if err != nil {
903
+ return err
904
+ }
905
+ tg .tempFile (dest , string (data ))
906
+ if err := os .Chmod (tg .path (dest ), info .Mode ()); err != nil {
907
+ return err
908
+ }
909
+ return nil
910
+ })
911
+ if err != nil {
912
+ t .Fatal (err )
913
+ }
914
+ }
915
+ tg .setenv ("GOROOT" , tg .path ("goroot" ))
916
+
875
917
addVar := func (name string , idx int ) (restore func ()) {
876
918
data , err := ioutil .ReadFile (name )
877
919
if err != nil {
@@ -900,7 +942,7 @@ func TestNewReleaseRebuildsStalePackagesInGOPATH(t *testing.T) {
900
942
// Changing mtime of runtime/internal/sys/sys.go
901
943
// should have no effect: only the content matters.
902
944
// In fact this should be true even outside a release branch.
903
- sys := runtime . GOROOT () + " /src/runtime/internal/sys/sys.go"
945
+ sys := tg . path ( "goroot /src/runtime/internal/sys/sys.go")
904
946
tg .sleep ()
905
947
restore := addVar (sys , 0 )
906
948
restore ()
@@ -915,7 +957,7 @@ func TestNewReleaseRebuildsStalePackagesInGOPATH(t *testing.T) {
915
957
restore ()
916
958
tg .wantNotStale ("p1" , "" , "./testgo list claims p1 is stale, incorrectly, after changing back to old release" )
917
959
addVar (sys , 2 )
918
- tg .wantStale ("p1" , "stale dependency: runtime/internal/sys " , "./testgo list claims p1 is NOT stale, incorrectly, after changing sys.go again" )
960
+ tg .wantStale ("p1" , "stale dependency: runtime" , "./testgo list claims p1 is NOT stale, incorrectly, after changing sys.go again" )
919
961
tg .run ("install" , "-i" , "p1" )
920
962
tg .wantNotStale ("p1" , "" , "./testgo list claims p1 is stale after building with new release" )
921
963
@@ -924,9 +966,6 @@ func TestNewReleaseRebuildsStalePackagesInGOPATH(t *testing.T) {
924
966
tg .wantStale ("p1" , "stale dependency: runtime/internal/sys" , "./testgo list claims p1 is NOT stale, incorrectly, after restoring sys.go" )
925
967
tg .run ("install" , "-i" , "p1" )
926
968
tg .wantNotStale ("p1" , "" , "./testgo list claims p1 is stale after building with old release" )
927
-
928
- // Everything is out of date. Rebuild to leave things in a better state.
929
- tg .run ("install" , "std" )
930
969
}
931
970
932
971
func testLocalRun (tg * testgoData , exepath , local , match string ) {
0 commit comments