Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/query/whatinputs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,16 @@
inputLabels := whatInputs(graph.AllTargets(), "package1/file1.txt", true)
assert.Equal(t, []core.BuildLabel{{PackageName: "package1", Name: "_target1#srcs"}, {PackageName: "package1", Name: "target1"}}, inputLabels)
}

func TestWhatInputsSingleTargetParentUnderscore(t *testing.T) {
graph := core.NewGraph()
pkg := core.NewPackage("package1")
fileSource := core.FileLabel{File: "file1.txt", Package: pkg.Name}
internalTarget := addNewTarget(graph, pkg, "__target1#srcs", []core.BuildInput{fileSource})
addNewTarget(graph, pkg, "_target1", []core.BuildInput{fileSource, internalTarget.Label})
graph.AddPackage(pkg)

inputLabels := whatInputs(graph.AllTargets(), "package1/file1.txt", false)
assert.Equal(t, []core.BuildLabel{{PackageName: "package1", Name: "_target1"}}, inputLabels)

Check failure on line 101 in src/query/whatinputs_test.go

View check run for this annotation

Cirrus CI / main

src/query/whatinputs_test.go#L101

src.query.query_test.TestWhatInputsSingleTargetParentUnderscore
Raw output
whatinputs_test.go:101: 
        	Error Trace:	src/query/whatinputs_test.go:101
        	Error:      	Not equal: 
        	            	expected: []core.BuildLabel{core.BuildLabel{PackageName:"package1", Name:"_target1", Subrepo:""}}
        	            	actual  : []core.BuildLabel{core.BuildLabel{PackageName:"package1", Name:"_target1", Subrepo:""}, core.BuildLabel{PackageName:"package1", Name:"target1", Subrepo:""}}
        	            	
        	            	Diff:
        	            	--- Expected
        	            	+++ Actual
        	            	@@ -1,2 +1,2 @@
        	            	-([]core.BuildLabel) (len=1) {
        	            	+([]core.BuildLabel) (len=2) {
        	            	  (core.BuildLabel) {
        	            	@@ -5,2 +5,7 @@
        	            	   Subrepo: (string) ""
        	            	+ },
        	            	+ (core.BuildLabel) {
        	            	+  PackageName: (string) (len=8) "package1",
        	            	+  Name: (string) (len=7) "target1",
        	            	+  Subrepo: (string) ""
        	            	  }
        	Test:       	TestWhatInputsSingleTargetParentUnderscore
}

Check failure on line 103 in src/query/whatinputs_test.go

View workflow job for this annotation

GitHub Actions / lint

File is not properly formatted (gci)
7 changes: 7 additions & 0 deletions test/whatinputs/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ plz_e2e_test(
expected_output = "multiple_sources.txt",
)

plz_e2e_test(
name = "hidden_targets",
cmd = "plz query whatinputs test/whatinputs/test_package/bar.txt",
expected_failure = False,
expect_output_contains = "//test/whatinputs/test_package:_target2",
)

plz_e2e_test(
name = "source_and_no_source",
cmd = "plz query whatinputs making/up/a/file/path/should/be/easy test/whatinputs/test_package/foo.txt",
Expand Down
14 changes: 14 additions & 0 deletions test/whatinputs/test_package/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,17 @@ genrule(
outs = ["out.txt"],
cmd = "cat $SRCS > $OUT",
)

genrule(
name = "_target2",
srcs = ["_target2#child"],
outs = ["out2.txt"],
cmd = "cat $SRCS > $OUT",
)

genrule(
name = "_target2#child",
srcs = ["bar.txt"],
outs = ["out2_child.txt"],
cmd = "cat $SRCS > $OUT",
)
Empty file.
Loading