@@ -4870,122 +4870,6 @@ func TestTestCache(t *testing.T) {
4870
4870
}
4871
4871
}
4872
4872
4873
- func TestTestCacheInputs (t * testing.T ) {
4874
- tooSlow (t )
4875
-
4876
- if strings .Contains (os .Getenv ("GODEBUG" ), "gocacheverify" ) {
4877
- t .Skip ("GODEBUG gocacheverify" )
4878
- }
4879
- tg := testgo (t )
4880
- defer tg .cleanup ()
4881
- tg .parallel ()
4882
- tg .makeTempdir ()
4883
- tg .setenv ("GOPATH" , filepath .Join (tg .pwd (), "testdata" ))
4884
- tg .setenv ("GOCACHE" , tg .path ("cache" ))
4885
-
4886
- defer os .Remove (filepath .Join (tg .pwd (), "testdata/src/testcache/file.txt" ))
4887
- defer os .Remove (filepath .Join (tg .pwd (), "testdata/src/testcache/script.sh" ))
4888
- tg .must (ioutil .WriteFile (filepath .Join (tg .pwd (), "testdata/src/testcache/file.txt" ), []byte ("x" ), 0644 ))
4889
- old := time .Now ().Add (- 1 * time .Minute )
4890
- tg .must (os .Chtimes (filepath .Join (tg .pwd (), "testdata/src/testcache/file.txt" ), old , old ))
4891
- info , err := os .Stat (filepath .Join (tg .pwd (), "testdata/src/testcache/file.txt" ))
4892
- if err != nil {
4893
- t .Fatal (err )
4894
- }
4895
- t .Logf ("file.txt: old=%v, info.ModTime=%v" , old , info .ModTime ()) // help debug when Chtimes lies about succeeding
4896
- tg .setenv ("TESTKEY" , "x" )
4897
-
4898
- tg .must (ioutil .WriteFile (filepath .Join (tg .pwd (), "testdata/src/testcache/script.sh" ), []byte ("#!/bin/sh\n exit 0\n " ), 0755 ))
4899
- tg .must (os .Chtimes (filepath .Join (tg .pwd (), "testdata/src/testcache/script.sh" ), old , old ))
4900
-
4901
- tg .run ("test" , "testcache" )
4902
- tg .run ("test" , "testcache" )
4903
- tg .grepStdout (`\(cached\)` , "did not cache" )
4904
-
4905
- tg .setenv ("TESTKEY" , "y" )
4906
- tg .run ("test" , "testcache" )
4907
- tg .grepStdoutNot (`\(cached\)` , "did not notice env var change" )
4908
- tg .run ("test" , "testcache" )
4909
- tg .grepStdout (`\(cached\)` , "did not cache" )
4910
-
4911
- tg .run ("test" , "testcache" , "-run=FileSize" )
4912
- tg .run ("test" , "testcache" , "-run=FileSize" )
4913
- tg .grepStdout (`\(cached\)` , "did not cache" )
4914
- tg .must (ioutil .WriteFile (filepath .Join (tg .pwd (), "testdata/src/testcache/file.txt" ), []byte ("xxx" ), 0644 ))
4915
- tg .run ("test" , "testcache" , "-run=FileSize" )
4916
- tg .grepStdoutNot (`\(cached\)` , "did not notice file size change" )
4917
- tg .run ("test" , "testcache" , "-run=FileSize" )
4918
- tg .grepStdout (`\(cached\)` , "did not cache" )
4919
-
4920
- tg .run ("test" , "testcache" , "-run=Chdir" )
4921
- tg .run ("test" , "testcache" , "-run=Chdir" )
4922
- tg .grepStdout (`\(cached\)` , "did not cache" )
4923
- tg .must (ioutil .WriteFile (filepath .Join (tg .pwd (), "testdata/src/testcache/file.txt" ), []byte ("xxxxx" ), 0644 ))
4924
- tg .run ("test" , "testcache" , "-run=Chdir" )
4925
- tg .grepStdoutNot (`\(cached\)` , "did not notice file size change" )
4926
- tg .run ("test" , "testcache" , "-run=Chdir" )
4927
- tg .grepStdout (`\(cached\)` , "did not cache" )
4928
-
4929
- tg .must (os .Chtimes (filepath .Join (tg .pwd (), "testdata/src/testcache/file.txt" ), old , old ))
4930
- tg .run ("test" , "testcache" , "-run=FileContent" )
4931
- tg .run ("test" , "testcache" , "-run=FileContent" )
4932
- tg .grepStdout (`\(cached\)` , "did not cache" )
4933
- tg .must (ioutil .WriteFile (filepath .Join (tg .pwd (), "testdata/src/testcache/file.txt" ), []byte ("yyy" ), 0644 ))
4934
- old2 := old .Add (10 * time .Second )
4935
- tg .must (os .Chtimes (filepath .Join (tg .pwd (), "testdata/src/testcache/file.txt" ), old2 , old2 ))
4936
- tg .run ("test" , "testcache" , "-run=FileContent" )
4937
- tg .grepStdoutNot (`\(cached\)` , "did not notice file content change" )
4938
- tg .run ("test" , "testcache" , "-run=FileContent" )
4939
- tg .grepStdout (`\(cached\)` , "did not cache" )
4940
-
4941
- tg .run ("test" , "testcache" , "-run=DirList" )
4942
- tg .run ("test" , "testcache" , "-run=DirList" )
4943
- tg .grepStdout (`\(cached\)` , "did not cache" )
4944
- tg .must (os .Remove (filepath .Join (tg .pwd (), "testdata/src/testcache/file.txt" )))
4945
- tg .run ("test" , "testcache" , "-run=DirList" )
4946
- tg .grepStdoutNot (`\(cached\)` , "did not notice directory change" )
4947
- tg .run ("test" , "testcache" , "-run=DirList" )
4948
- tg .grepStdout (`\(cached\)` , "did not cache" )
4949
-
4950
- tg .tempFile ("file.txt" , "" )
4951
- tg .must (ioutil .WriteFile (filepath .Join (tg .pwd (), "testdata/src/testcache/testcachetmp_test.go" ), []byte (`package testcache
4952
-
4953
- import (
4954
- "os"
4955
- "testing"
4956
- )
4957
-
4958
- func TestExternalFile(t *testing.T) {
4959
- os.Open(` + fmt .Sprintf ("%q" , tg .path ("file.txt" ))+ `)
4960
- _, err := os.Stat(` + fmt .Sprintf ("%q" , tg .path ("file.txt" ))+ `)
4961
- if err != nil {
4962
- t.Fatal(err)
4963
- }
4964
- }
4965
- ` ), 0666 ))
4966
- defer os .Remove (filepath .Join (tg .pwd (), "testdata/src/testcache/testcachetmp_test.go" ))
4967
- tg .run ("test" , "testcache" , "-run=ExternalFile" )
4968
- tg .run ("test" , "testcache" , "-run=ExternalFile" )
4969
- tg .grepStdout (`\(cached\)` , "did not cache" )
4970
- tg .must (os .Remove (filepath .Join (tg .tempdir , "file.txt" )))
4971
- tg .run ("test" , "testcache" , "-run=ExternalFile" )
4972
- tg .grepStdout (`\(cached\)` , "did not cache" )
4973
-
4974
- switch runtime .GOOS {
4975
- case "plan9" , "windows" :
4976
- // no shell scripts
4977
- default :
4978
- tg .run ("test" , "testcache" , "-run=Exec" )
4979
- tg .run ("test" , "testcache" , "-run=Exec" )
4980
- tg .grepStdout (`\(cached\)` , "did not cache" )
4981
- tg .must (os .Chtimes (filepath .Join (tg .pwd (), "testdata/src/testcache/script.sh" ), old2 , old2 ))
4982
- tg .run ("test" , "testcache" , "-run=Exec" )
4983
- tg .grepStdoutNot (`\(cached\)` , "did not notice script change" )
4984
- tg .run ("test" , "testcache" , "-run=Exec" )
4985
- tg .grepStdout (`\(cached\)` , "did not cache" )
4986
- }
4987
- }
4988
-
4989
4873
func TestTestVet (t * testing.T ) {
4990
4874
tooSlow (t )
4991
4875
tg := testgo (t )
0 commit comments