Skip to content

Commit

Permalink
rename fromTxtar based on cl 613160 respective
Browse files Browse the repository at this point in the history
  • Loading branch information
xieyuschen committed Sep 18, 2024
1 parent 5bd4573 commit 9cb2d4e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions go/ssa/source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func TestObjValueLookup(t *testing.T) {
if err != nil {
t.Fatal(err)
}
pkgs := packagesFromArchive(t, string(src))
pkgs := fromTxtar(t, string(src))
prog, _ := ssautil.Packages(pkgs, ssa.BuilderMode(0))

info := getPkgInfo(prog, pkgs, "main")
Expand Down Expand Up @@ -246,7 +246,7 @@ func testValueForExpr(t *testing.T, testfile string) {
t.Fatal(err)
}

pkgs := packagesFromArchive(t, string(src))
pkgs := fromTxtar(t, string(src))
prog, _ := ssautil.Packages(pkgs, ssa.BuilderMode(0))

info := getPkgInfo(prog, pkgs, "main")
Expand Down
9 changes: 5 additions & 4 deletions go/ssa/testutil_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
// It's useful to create a ssa package and its packages.Package and ast.File representation.
func loadPackageFromSingleFile(t *testing.T, content string, mode ssa.BuilderMode) *pkgInfo {
ar := archiveFromSingleFileContent(content)
pkgs := packagesFromArchive(t, ar)
pkgs := fromTxtar(t, ar)
prog, _ := ssautil.Packages(pkgs, mode)

pkgName := packageName(t, content)
Expand All @@ -49,9 +49,10 @@ go 1.18
%s`, content)
}

// packagesFromArchive creates a temporary folder from the archive and load packages from it.
func packagesFromArchive(t *testing.T, archive string) []*packages.Package {
ar := txtar.Parse([]byte(archive))
// fromTxtar creates a temporary folder from the content in txtar format
// and then loads the packages.
func fromTxtar(t *testing.T, content string) []*packages.Package {
ar := txtar.Parse([]byte(content))

fs, err := txtar.FS(ar)
if err != nil {
Expand Down

0 comments on commit 9cb2d4e

Please sign in to comment.