@@ -315,6 +315,33 @@ func TestTransitiveInvalidation(t *testing.T) {
315315 }
316316}
317317
318+ func TestTransitiveInvalidationForTool (t * testing.T ) {
319+ spawnDiffs := diffLogs (t , "transitive_invalidation_for_tool" , "8.0.0" )
320+ require .Len (t , spawnDiffs , 2 )
321+
322+ {
323+ sd := spawnDiffs [0 ]
324+ assert .Regexp (t , "^bazel-out/[^/]+-fastbuild/bin/pkg/lib.out$" , sd .PrimaryOutput )
325+ assert .Equal (t , "//pkg:library" , sd .TargetLabel )
326+ assert .Equal (t , "Genrule" , sd .Mnemonic )
327+ assert .Equal (t , map [string ]uint32 {"Genrule" : 1 }, sd .GetModified ().GetTransitivelyInvalidated ())
328+ require .Len (t , sd .GetModified ().GetDiffs (), 1 )
329+ assert .Len (t , sd .GetModified ().GetDiffs ()[0 ].GetInputContents ().GetFileDiffs (), 1 )
330+ }
331+ {
332+ sd := spawnDiffs [1 ]
333+ assert .Regexp (t , "^bazel-out/[^/]+-exec-[^/]+/bin/pkg/lib.out$" , sd .PrimaryOutput )
334+ assert .Equal (t , "//pkg:library" , sd .TargetLabel )
335+ assert .Equal (t , "Genrule" , sd .Mnemonic )
336+ assert .Equal (t , map [string ]uint32 {
337+ "Genrule" : 1 ,
338+ "Genrule (as tool)" : 3 ,
339+ }, sd .GetModified ().GetTransitivelyInvalidated ())
340+ require .Len (t , sd .GetModified ().GetDiffs (), 1 )
341+ assert .Len (t , sd .GetModified ().GetDiffs ()[0 ].GetInputContents ().GetFileDiffs (), 1 )
342+ }
343+ }
344+
318345func TestNonHermetic (t * testing.T ) {
319346 spawnDiffs := diffLogs (t , "non_hermetic" , "7.3.1" )
320347 require .Len (t , spawnDiffs , 1 )
@@ -512,7 +539,7 @@ func TestToolRunfilesPaths(t *testing.T) {
512539 assert .Regexp (t , "^bazel-out/[^/]+/bin/pkg/tool.runfiles" , sd .PrimaryOutput )
513540 assert .Equal (t , "//tools:tool_sh" , sd .TargetLabel )
514541 assert .Equal (t , "Runfiles directory" , sd .Mnemonic )
515- assert .Equal (t , map [string ]uint32 {"Genrule" : 2 }, sd .GetModified ().GetTransitivelyInvalidated ())
542+ assert .Equal (t , map [string ]uint32 {"Genrule (as tool) " : 2 }, sd .GetModified ().GetTransitivelyInvalidated ())
516543 require .Len (t , sd .GetModified ().GetDiffs (), 1 )
517544 d := sd .GetModified ().Diffs [0 ]
518545 require .IsType (t , & spawn_diff.Diff_InputPaths {}, d .Diff )
@@ -528,7 +555,7 @@ func TestToolRunfilesContents(t *testing.T) {
528555 assert .Regexp (t , "^bazel-out/[^/]+/bin/pkg/tool.runfiles" , sd .PrimaryOutput )
529556 assert .Equal (t , "//tools:tool_sh" , sd .TargetLabel )
530557 assert .Equal (t , "Runfiles directory" , sd .Mnemonic )
531- assert .Equal (t , map [string ]uint32 {"Genrule" : 2 }, sd .GetModified ().GetTransitivelyInvalidated ())
558+ assert .Equal (t , map [string ]uint32 {"Genrule (as tool) " : 2 }, sd .GetModified ().GetTransitivelyInvalidated ())
532559 require .Len (t , sd .GetModified ().GetDiffs (), 1 )
533560 d := sd .GetModified ().Diffs [0 ]
534561 require .IsType (t , & spawn_diff.Diff_InputContents {}, d .Diff )
@@ -549,7 +576,7 @@ func TestToolRunfilesContentsTransitive(t *testing.T) {
549576 assert .Regexp (t , "^bazel-out/[^/]+/bin/tools/tool.sh" , sd .PrimaryOutput )
550577 assert .Equal (t , "//tools:tool_sh" , sd .TargetLabel )
551578 assert .Equal (t , "Genrule" , sd .Mnemonic )
552- assert .Equal (t , map [string ]uint32 {"Genrule" : 2 , "Runfiles directory" : 1 }, sd .GetModified ().GetTransitivelyInvalidated ())
579+ assert .Equal (t , map [string ]uint32 {"Genrule (as tool) " : 2 , "Runfiles directory" : 1 }, sd .GetModified ().GetTransitivelyInvalidated ())
553580 require .Len (t , sd .GetModified ().GetDiffs (), 1 )
554581 d := sd .GetModified ().Diffs [0 ]
555582 require .IsType (t , & spawn_diff.Diff_Args {}, d .Diff )
@@ -571,7 +598,7 @@ func TestToolRunfilesSymlinksPaths(t *testing.T) {
571598 assert .Regexp (t , "^bazel-out/[^/]+/bin/tools/tool.runfiles$" , sd .PrimaryOutput )
572599 assert .Empty (t , sd .TargetLabel )
573600 assert .Equal (t , "Runfiles directory" , sd .Mnemonic )
574- assert .Equal (t , map [string ]uint32 {"Genrule" : 1 }, sd .GetModified ().GetTransitivelyInvalidated ())
601+ assert .Equal (t , map [string ]uint32 {"Genrule (as tool) " : 1 }, sd .GetModified ().GetTransitivelyInvalidated ())
575602 require .Len (t , sd .GetModified ().GetDiffs (), 1 )
576603 d := sd .GetModified ().Diffs [0 ]
577604 require .IsType (t , & spawn_diff.Diff_InputPaths {}, d .Diff )
@@ -588,7 +615,7 @@ func TestToolRunfilesSymlinksContents(t *testing.T) {
588615 assert .Regexp (t , "^bazel-out/[^/]+/bin/tools/tool.runfiles$" , sd .PrimaryOutput )
589616 assert .Empty (t , sd .TargetLabel )
590617 assert .Equal (t , "Runfiles directory" , sd .Mnemonic )
591- assert .Equal (t , map [string ]uint32 {"Genrule" : 1 }, sd .GetModified ().GetTransitivelyInvalidated ())
618+ assert .Equal (t , map [string ]uint32 {"Genrule (as tool) " : 1 }, sd .GetModified ().GetTransitivelyInvalidated ())
592619 require .Len (t , sd .GetModified ().GetDiffs (), 1 )
593620 d := sd .GetModified ().Diffs [0 ]
594621 require .IsType (t , & spawn_diff.Diff_InputContents {}, d .Diff )
@@ -620,7 +647,7 @@ func TestToolRunfilesSymlinksContentsTransitive(t *testing.T) {
620647 assert .Equal (t , "//gen:gen" , sd .TargetLabel )
621648 assert .Equal (t , "Genrule" , sd .Mnemonic )
622649 assert .Equal (t , map [string ]uint32 {
623- "Genrule" : 1 ,
650+ "Genrule (as tool)" : 1 ,
624651 "Runfiles directory" : 1 ,
625652 }, sd .GetModified ().GetTransitivelyInvalidated ())
626653 require .Len (t , sd .GetModified ().GetDiffs (), 1 )
0 commit comments