Program: 53182
Project: 53182
Buggy source:
@Test @SuppressWarnings("String_Node_Str") public void createBuildRule(){
  ProjectFilesystem projectFilesystem=new FakeProjectFilesystem();
  BuildRuleResolver resolver=new BuildRuleResolver();
  SourcePathResolver pathResolver=new SourcePathResolver(resolver);
  CxxPlatform cxxPlatform=CxxBinaryBuilder.createDefaultPlatform();
  String genHeaderName="String_Node_Str";
  BuildTarget genHeaderTarget=BuildTargetFactory.newInstance("String_Node_Str");
  Genrule genHeader=(Genrule)GenruleBuilder.newGenruleBuilder(genHeaderTarget).setOut(genHeaderName).build(resolver);
  String genSourceName="String_Node_Str";
  BuildTarget genSourceTarget=BuildTargetFactory.newInstance("String_Node_Str");
  Genrule genSource=(Genrule)GenruleBuilder.newGenruleBuilder(genSourceTarget).setOut(genSourceName).build(resolver);
  final BuildRule header=createFakeBuildRule("String_Node_Str",pathResolver);
  final BuildRule headerSymlinkTree=createFakeBuildRule("String_Node_Str",pathResolver);
  final Path headerSymlinkTreeRoot=Paths.get("String_Node_Str");
  final BuildRule archive=createFakeBuildRule("String_Node_Str",pathResolver);
  final Path archiveOutput=Paths.get("String_Node_Str");
  BuildTarget depTarget=BuildTargetFactory.newInstance("String_Node_Str");
  BuildRuleParams depParams=BuildRuleParamsFactory.createTrivialBuildRuleParams(depTarget);
  AbstractCxxLibrary dep=new AbstractCxxLibrary(depParams,pathResolver){
    @Override public CxxPreprocessorInput getCxxPreprocessorInput(    CxxPlatform cxxPlatform,    HeaderVisibility headerVisibility){
      return CxxPreprocessorInput.builder().addRules(header.getBuildTarget(),headerSymlinkTree.getBuildTarget()).addIncludeRoots(headerSymlinkTreeRoot).build();
    }
    @Override public ImmutableMap<BuildTarget,CxxPreprocessorInput> getTransitiveCxxPreprocessorInput(    CxxPlatform cxxPlatform,    HeaderVisibility headerVisibility){
      return ImmutableMap.of(getBuildTarget(),getCxxPreprocessorInput(cxxPlatform,headerVisibility));
    }
    @Override public NativeLinkableInput getNativeLinkableInput(    CxxPlatform cxxPlatform,    Linker.LinkableDepType type){
      return NativeLinkableInput.of(ImmutableList.<SourcePath>of(new BuildTargetSourcePath(archive.getBuildTarget())),ImmutableList.of(archiveOutput.toString()),ImmutableSet.<Path>of());
    }
    @Override public Optional<Linker.LinkableDepType> getPreferredLinkage(    CxxPlatform cxxPlatform){
      return Optional.absent();
    }
    @Override public PythonPackageComponents getPythonPackageComponents(    CxxPlatform cxxPlatform){
      return PythonPackageComponents.of(ImmutableMap.<Path,SourcePath>of(),ImmutableMap.<Path,SourcePath>of(),ImmutableMap.<Path,SourcePath>of(),ImmutableSet.<SourcePath>of(),Optional.<Boolean>absent());
    }
    @Override public Iterable<AndroidPackageable> getRequiredPackageables(){
      return ImmutableList.of();
    }
    @Override public void addToCollector(    AndroidPackageableCollector collector){
    }
    @Override public ImmutableMap<String,SourcePath> getSharedLibraries(    CxxPlatform cxxPlatform){
      return ImmutableMap.of();
    }
    @Override public boolean isTestedBy(    BuildTarget buildTarget){
      return false;
    }
  }
;
  resolver.addAllToIndex(ImmutableList.of(header,headerSymlinkTree,archive,dep));
  BuildTarget target=BuildTargetFactory.newInstance("String_Node_Str");
  CxxBinaryBuilder cxxBinaryBuilder=(CxxBinaryBuilder)new CxxBinaryBuilder(target).setSrcs(ImmutableList.of(SourceWithFlags.of(new TestSourcePath("String_Node_Str")),SourceWithFlags.of(new BuildTargetSourcePath(genSource.getBuildTarget())))).setHeaders(ImmutableSortedSet.<SourcePath>of(new TestSourcePath("String_Node_Str"),new BuildTargetSourcePath(genHeader.getBuildTarget()))).setDeps(ImmutableSortedSet.of(dep.getBuildTarget()));
  CxxBinary binRule=(CxxBinary)cxxBinaryBuilder.build(resolver);
  CxxLink rule=binRule.getRule();
  CxxSourceRuleFactory cxxSourceRuleFactory=new CxxSourceRuleFactory(cxxBinaryBuilder.createBuildRuleParams(resolver,projectFilesystem,TargetGraph.EMPTY),resolver,pathResolver,cxxPlatform,ImmutableList.<CxxPreprocessorInput>of(),ImmutableList.<String>of());
  assertEquals(ImmutableSet.of(cxxSourceRuleFactory.createCompileBuildTarget("String_Node_Str",CxxSourceRuleFactory.PicType.PDC),cxxSourceRuleFactory.createCompileBuildTarget(genSourceName,CxxSourceRuleFactory.PicType.PDC),archive.getBuildTarget()),FluentIterable.from(rule.getDeps()).transform(HasBuildTarget.TO_TARGET).toSet());
  BuildRule preprocessRule1=resolver.getRule(cxxSourceRuleFactory.createPreprocessBuildTarget("String_Node_Str",CxxSource.Type.CXX,CxxSourceRuleFactory.PicType.PDC));
  assertEquals(ImmutableSet.of(genHeaderTarget,headerSymlinkTree.getBuildTarget(),header.getBuildTarget(),CxxDescriptionEnhancer.createHeaderSymlinkTreeTarget(target,cxxPlatform.getFlavor(),HeaderVisibility.PRIVATE)),FluentIterable.from(preprocessRule1.getDeps()).transform(HasBuildTarget.TO_TARGET).toSet());
  BuildRule compileRule1=resolver.getRule(cxxSourceRuleFactory.createCompileBuildTarget("String_Node_Str",CxxSourceRuleFactory.PicType.PDC));
  assertNotNull(compileRule1);
  assertEquals(ImmutableSet.of(preprocessRule1.getBuildTarget()),FluentIterable.from(compileRule1.getDeps()).transform(HasBuildTarget.TO_TARGET).toSet());
  BuildRule preprocessRule2=resolver.getRule(cxxSourceRuleFactory.createPreprocessBuildTarget(genSourceName,CxxSource.Type.CXX,CxxSourceRuleFactory.PicType.PDC));
  assertEquals(ImmutableSet.of(genHeaderTarget,genSourceTarget,headerSymlinkTree.getBuildTarget(),header.getBuildTarget(),CxxDescriptionEnhancer.createHeaderSymlinkTreeTarget(target,cxxPlatform.getFlavor(),HeaderVisibility.PRIVATE)),FluentIterable.from(preprocessRule2.getDeps()).transform(HasBuildTarget.TO_TARGET).toSet());
  BuildRule compileRule2=resolver.getRule(cxxSourceRuleFactory.createCompileBuildTarget(genSourceName,CxxSourceRuleFactory.PicType.PDC));
  assertNotNull(compileRule2);
  assertEquals(ImmutableSet.of(preprocessRule2.getBuildTarget()),FluentIterable.from(compileRule2.getDeps()).transform(HasBuildTarget.TO_TARGET).toSet());
}

Fixed version (ground truth):
@Test @SuppressWarnings("String_Node_Str") public void createBuildRule(){
  ProjectFilesystem projectFilesystem=new FakeProjectFilesystem();
  BuildRuleResolver resolver=new BuildRuleResolver();
  SourcePathResolver pathResolver=new SourcePathResolver(resolver);
  CxxPlatform cxxPlatform=CxxBinaryBuilder.createDefaultPlatform();
  String genHeaderName="String_Node_Str";
  BuildTarget genHeaderTarget=BuildTargetFactory.newInstance("String_Node_Str");
  Genrule genHeader=(Genrule)GenruleBuilder.newGenruleBuilder(genHeaderTarget).setOut(genHeaderName).build(resolver);
  String genSourceName="String_Node_Str";
  BuildTarget genSourceTarget=BuildTargetFactory.newInstance("String_Node_Str");
  Genrule genSource=(Genrule)GenruleBuilder.newGenruleBuilder(genSourceTarget).setOut(genSourceName).build(resolver);
  final BuildRule header=createFakeBuildRule("String_Node_Str",pathResolver);
  final BuildRule headerSymlinkTree=createFakeBuildRule("String_Node_Str",pathResolver);
  final Path headerSymlinkTreeRoot=Paths.get("String_Node_Str");
  final BuildRule archive=createFakeBuildRule("String_Node_Str",pathResolver);
  final Path archiveOutput=Paths.get("String_Node_Str");
  BuildTarget depTarget=BuildTargetFactory.newInstance("String_Node_Str");
  BuildRuleParams depParams=BuildRuleParamsFactory.createTrivialBuildRuleParams(depTarget);
  AbstractCxxLibrary dep=new AbstractCxxLibrary(depParams,pathResolver){
    @Override public CxxPreprocessorInput getCxxPreprocessorInput(    CxxPlatform cxxPlatform,    HeaderVisibility headerVisibility){
      return CxxPreprocessorInput.builder().addRules(header.getBuildTarget(),headerSymlinkTree.getBuildTarget()).addIncludeRoots(headerSymlinkTreeRoot).build();
    }
    @Override public ImmutableMap<BuildTarget,CxxPreprocessorInput> getTransitiveCxxPreprocessorInput(    CxxPlatform cxxPlatform,    HeaderVisibility headerVisibility){
      return ImmutableMap.of(getBuildTarget(),getCxxPreprocessorInput(cxxPlatform,headerVisibility));
    }
    @Override public NativeLinkableInput getNativeLinkableInput(    CxxPlatform cxxPlatform,    Linker.LinkableDepType type){
      return NativeLinkableInput.of(ImmutableList.<SourcePath>of(new BuildTargetSourcePath(archive.getBuildTarget())),ImmutableList.of(archiveOutput.toString()),ImmutableSet.<Path>of());
    }
    @Override public NativeLinkable.Linkage getPreferredLinkage(    CxxPlatform cxxPlatform){
      return Linkage.ANY;
    }
    @Override public PythonPackageComponents getPythonPackageComponents(    CxxPlatform cxxPlatform){
      return PythonPackageComponents.of(ImmutableMap.<Path,SourcePath>of(),ImmutableMap.<Path,SourcePath>of(),ImmutableMap.<Path,SourcePath>of(),ImmutableSet.<SourcePath>of(),Optional.<Boolean>absent());
    }
    @Override public Iterable<AndroidPackageable> getRequiredPackageables(){
      return ImmutableList.of();
    }
    @Override public void addToCollector(    AndroidPackageableCollector collector){
    }
    @Override public ImmutableMap<String,SourcePath> getSharedLibraries(    CxxPlatform cxxPlatform){
      return ImmutableMap.of();
    }
    @Override public boolean isTestedBy(    BuildTarget buildTarget){
      return false;
    }
  }
;
  resolver.addAllToIndex(ImmutableList.of(header,headerSymlinkTree,archive,dep));
  BuildTarget target=BuildTargetFactory.newInstance("String_Node_Str");
  CxxBinaryBuilder cxxBinaryBuilder=(CxxBinaryBuilder)new CxxBinaryBuilder(target).setSrcs(ImmutableList.of(SourceWithFlags.of(new TestSourcePath("String_Node_Str")),SourceWithFlags.of(new BuildTargetSourcePath(genSource.getBuildTarget())))).setHeaders(ImmutableSortedSet.<SourcePath>of(new TestSourcePath("String_Node_Str"),new BuildTargetSourcePath(genHeader.getBuildTarget()))).setDeps(ImmutableSortedSet.of(dep.getBuildTarget()));
  CxxBinary binRule=(CxxBinary)cxxBinaryBuilder.build(resolver);
  CxxLink rule=binRule.getRule();
  CxxSourceRuleFactory cxxSourceRuleFactory=new CxxSourceRuleFactory(cxxBinaryBuilder.createBuildRuleParams(resolver,projectFilesystem,TargetGraph.EMPTY),resolver,pathResolver,cxxPlatform,ImmutableList.<CxxPreprocessorInput>of(),ImmutableList.<String>of());
  assertEquals(ImmutableSet.of(cxxSourceRuleFactory.createCompileBuildTarget("String_Node_Str",CxxSourceRuleFactory.PicType.PDC),cxxSourceRuleFactory.createCompileBuildTarget(genSourceName,CxxSourceRuleFactory.PicType.PDC),archive.getBuildTarget()),FluentIterable.from(rule.getDeps()).transform(HasBuildTarget.TO_TARGET).toSet());
  BuildRule preprocessRule1=resolver.getRule(cxxSourceRuleFactory.createPreprocessBuildTarget("String_Node_Str",CxxSource.Type.CXX,CxxSourceRuleFactory.PicType.PDC));
  assertEquals(ImmutableSet.of(genHeaderTarget,headerSymlinkTree.getBuildTarget(),header.getBuildTarget(),CxxDescriptionEnhancer.createHeaderSymlinkTreeTarget(target,cxxPlatform.getFlavor(),HeaderVisibility.PRIVATE)),FluentIterable.from(preprocessRule1.getDeps()).transform(HasBuildTarget.TO_TARGET).toSet());
  BuildRule compileRule1=resolver.getRule(cxxSourceRuleFactory.createCompileBuildTarget("String_Node_Str",CxxSourceRuleFactory.PicType.PDC));
  assertNotNull(compileRule1);
  assertEquals(ImmutableSet.of(preprocessRule1.getBuildTarget()),FluentIterable.from(compileRule1.getDeps()).transform(HasBuildTarget.TO_TARGET).toSet());
  BuildRule preprocessRule2=resolver.getRule(cxxSourceRuleFactory.createPreprocessBuildTarget(genSourceName,CxxSource.Type.CXX,CxxSourceRuleFactory.PicType.PDC));
  assertEquals(ImmutableSet.of(genHeaderTarget,genSourceTarget,headerSymlinkTree.getBuildTarget(),header.getBuildTarget(),CxxDescriptionEnhancer.createHeaderSymlinkTreeTarget(target,cxxPlatform.getFlavor(),HeaderVisibility.PRIVATE)),FluentIterable.from(preprocessRule2.getDeps()).transform(HasBuildTarget.TO_TARGET).toSet());
  BuildRule compileRule2=resolver.getRule(cxxSourceRuleFactory.createCompileBuildTarget(genSourceName,CxxSourceRuleFactory.PicType.PDC));
  assertNotNull(compileRule2);
  assertEquals(ImmutableSet.of(preprocessRule2.getBuildTarget()),FluentIterable.from(compileRule2.getDeps()).transform(HasBuildTarget.TO_TARGET).toSet());
}