-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from k1LoW/use-line-directive
Prepend line directive to copied source files and add test
- Loading branch information
Showing
5 changed files
with
79 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package testutil | ||
|
||
import ( | ||
"os" | ||
"path/filepath" | ||
"testing" | ||
|
||
"golang.org/x/tools/go/analysis/analysistest" | ||
) | ||
|
||
func TestWithModules(t *testing.T) { | ||
t.Parallel() | ||
|
||
t.Run("The line directive is appended to the go source codes", func(t *testing.T) { | ||
testdata := WithModules(t, analysistest.TestData(), nil) | ||
tests := []struct { | ||
path string | ||
want string | ||
}{ | ||
{filepath.Join(testdata, "src", "a", "a.go"), "//line src/a/a.go:1"}, | ||
{filepath.Join(testdata, "src", "a", "b", "b.go"), "//line src/a/b/b.go:1"}, | ||
} | ||
for _, tt := range tests { | ||
b, err := os.ReadFile(tt.path) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
if got := string(b[:len(tt.want)]); got != tt.want { | ||
t.Errorf("got %q, want %q", got, tt.want) | ||
} | ||
} | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package a | ||
|
||
func a() { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package b | ||
|
||
func b() { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module a | ||
|
||
go 1.21.0 |