mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-03 02:27:48 +00:00
loader: fix testing a main package
This was broken because multiple packages in the program were named 'main', even one that was imported (by the generated main package). This fixes tests for main packages.
This commit is contained in:
committed by
Ron Evans
parent
98f117fca4
commit
af65c006e6
+5
-6
@@ -343,12 +343,11 @@ func (p *Package) Check() error {
|
||||
checker.Importer = p
|
||||
|
||||
packageName := p.ImportPath
|
||||
if p.Name == "main" {
|
||||
// The main package normally has a different import path, such as
|
||||
// "command-line-arguments" or "./testdata/cgo". Therefore, use the name
|
||||
// "main" in such a case: this package isn't imported from anywhere.
|
||||
// This is safe as it isn't possible to import a package with the name
|
||||
// "main".
|
||||
if p == p.program.MainPkg() {
|
||||
if p.Name != "main" {
|
||||
// Sanity check. Should not ever trigger.
|
||||
panic("expected main package to have name 'main'")
|
||||
}
|
||||
packageName = "main"
|
||||
}
|
||||
typesPkg, err := checker.Check(packageName, p.program.fset, p.Files, &p.info)
|
||||
|
||||
Reference in New Issue
Block a user