Hold a cgo file's directory whole: its preamble may include from below it (hq ADR 0267, review)
This commit is contained in:
@@ -351,6 +351,8 @@ func goFileReads(file string) (imports, embeds []string, err error) {
|
||||
}
|
||||
}
|
||||
}
|
||||
// A cgo file may include from below its directory: the directory is held whole.
|
||||
embeds = append(embeds, ".")
|
||||
continue
|
||||
}
|
||||
imports = append(imports, ip)
|
||||
|
||||
@@ -304,3 +304,15 @@ func TestNativeSourcesHoldTheirDirectoryWhole(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// A cgo file may include from below its directory with nothing native beside it: its directory is held whole.
|
||||
func TestACgoFileHoldsItsDirectoryWhole(t *testing.T) {
|
||||
got, err := GoBuildSource(aGoTree(t, map[string]string{"go.mod": "module x\n",
|
||||
"p/main.go": "package main\n\n// #include \"inc/x.h\"\nimport \"C\"\n", "p/inc/x.h": ""}), "p")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !SourceHolds(got, "p/inc/x.h") {
|
||||
t.Fatalf("a header a cgo preamble includes is not held: %v", got)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user