@@ -38,8 +38,9 @@ var baseConfig = &packages.Config{
38
38
packages .NeedTypes ,
39
39
}
40
40
41
- // TestRTASingleFile runs RTA on each testdata/*.go file and compares the
42
- // results with the expectations expressed in the WANT comment.
41
+ // TestRTASingleFile runs RTA on each testdata/*.txtar file containing a single
42
+ // go file and compares the results with the expectations expressed in the WANT
43
+ // comment.
43
44
func TestRTASingleFile (t * testing.T ) {
44
45
archivePaths := []string {
45
46
"testdata/func.txtar" ,
@@ -73,7 +74,7 @@ func TestRTASingleFile(t *testing.T) {
73
74
}
74
75
75
76
// TestRTAOnPackages runs RTA on a go module which contains multiple packages to test the case
76
- // that the interface definition and its implementations locate in different packages.
77
+ // when an interface has implementations across different packages.
77
78
func TestRTAOnPackages (t * testing.T ) {
78
79
baseConfig .Dir = restoreArchive (t , "testdata/multipkgs.txtar" )
79
80
pkgs , err := packages .Load (baseConfig , "./..." )
@@ -83,9 +84,8 @@ func TestRTAOnPackages(t *testing.T) {
83
84
84
85
var f * ast.File
85
86
for _ , p := range pkgs {
86
- // we retrieve first file inside main package as the expected result stays there
87
- // this implies the main package should only have one file or the expected result is stored
88
- // in the first file of main package
87
+ // We assume the packages have a single file or
88
+ // the wanted result is in the first file of the main package.
89
89
if p .Name == "main" {
90
90
f = p .Syntax [0 ]
91
91
}
@@ -110,8 +110,8 @@ func TestRTAOnPackages(t *testing.T) {
110
110
}
111
111
112
112
// restoreArchive restores a go module from the archive file,
113
- // and put all contents in a temporary folder
114
- func restoreArchive (t * testing.T , achieveFilePath string ) ( dir string ) {
113
+ // and puts all contents in a temporary folder.
114
+ func restoreArchive (t * testing.T , achieveFilePath string ) string {
115
115
ar , err := txtar .ParseFile (achieveFilePath )
116
116
if err != nil {
117
117
t .Fatal (err )
@@ -121,8 +121,7 @@ func restoreArchive(t *testing.T, achieveFilePath string) (dir string) {
121
121
if err != nil {
122
122
t .Fatal (err )
123
123
}
124
- dir = testfiles .CopyToTmp (t , fs )
125
- return
124
+ return testfiles .CopyToTmp (t , fs )
126
125
}
127
126
128
127
// check tests the RTA analysis results against the test expectations
0 commit comments