Program: 53184
Project: 53184
Buggy source:
@Test @SuppressWarnings("String_Node_Str") public void createBuildRule(){
  BuildRuleResolver resolver=new BuildRuleResolver();
  SourcePathResolver pathResolver=new SourcePathResolver(resolver);
  CxxPlatform cxxPlatform=CxxLibraryBuilder.createDefaultPlatform();
  String genHeaderName="String_Node_Str";
  BuildTarget genHeaderTarget=BuildTargetFactory.newInstance("String_Node_Str");
  GenruleBuilder genHeaderBuilder=GenruleBuilder.newGenruleBuilder(genHeaderTarget).setOut(genHeaderName);
  genHeaderBuilder.build(resolver);
  String genSourceName="String_Node_Str";
  BuildTarget genSourceTarget=BuildTargetFactory.newInstance("String_Node_Str");
  GenruleBuilder genSourceBuilder=GenruleBuilder.newGenruleBuilder(genSourceTarget).setOut(genSourceName);
  genSourceBuilder.build(resolver);
  final BuildRule header=new FakeBuildRule("String_Node_Str",pathResolver);
  final BuildRule headerSymlinkTree=new FakeBuildRule("String_Node_Str",pathResolver);
  final Path headerSymlinkTreeRoot=Paths.get("String_Node_Str");
  final BuildRule privateHeader=new FakeBuildRule("String_Node_Str",pathResolver);
  final BuildRule privateHeaderSymlinkTree=new FakeBuildRule("String_Node_Str",pathResolver);
  final Path privateHeaderSymlinkTreeRoot=Paths.get("String_Node_Str");
  final BuildRule archive=new FakeBuildRule("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){
switch (headerVisibility) {
case PUBLIC:
        return CxxPreprocessorInput.builder().addRules(header.getBuildTarget(),headerSymlinkTree.getBuildTarget()).addIncludeRoots(headerSymlinkTreeRoot).build();
case PRIVATE:
      return CxxPreprocessorInput.builder().addRules(privateHeader.getBuildTarget(),privateHeaderSymlinkTree.getBuildTarget()).addIncludeRoots(privateHeaderSymlinkTreeRoot).build();
  }
  throw new RuntimeException("String_Node_Str" + headerVisibility);
}
@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,privateHeader,privateHeaderSymlinkTree,archive,dep));
BuildTarget target=BuildTargetFactory.newInstance("String_Node_Str");
CxxSourceRuleFactory cxxSourceRuleFactory=CxxSourceRuleFactoryHelper.of(target,cxxPlatform);
String headerName="String_Node_Str";
String privateHeaderName="String_Node_Str";
CxxLibraryBuilder cxxLibraryBuilder=(CxxLibraryBuilder)new CxxLibraryBuilder(target).setExportedHeaders(ImmutableSortedSet.<SourcePath>of(new TestSourcePath(headerName),new BuildTargetSourcePath(genHeaderTarget))).setHeaders(ImmutableSortedSet.<SourcePath>of(new TestSourcePath(privateHeaderName))).setSrcs(ImmutableList.of(SourceWithFlags.of(new TestSourcePath("String_Node_Str")),SourceWithFlags.of(new BuildTargetSourcePath(genSourceTarget)))).setFrameworkSearchPaths(ImmutableSet.of(Paths.get("String_Node_Str"),Paths.get("String_Node_Str"))).setDeps(ImmutableSortedSet.of(dep.getBuildTarget()));
CxxLibrary rule=(CxxLibrary)cxxLibraryBuilder.build(resolver,new FakeProjectFilesystem(),TargetGraphFactory.newInstance(cxxLibraryBuilder.build(),genSourceBuilder.build(),genHeaderBuilder.build(),GenruleBuilder.newGenruleBuilder(depTarget).build()));
Path headerRoot=CxxDescriptionEnhancer.getHeaderSymlinkTreePath(target,cxxPlatform.getFlavor(),HeaderVisibility.PUBLIC);
assertEquals(CxxPreprocessorInput.builder().addRules(CxxDescriptionEnhancer.createHeaderSymlinkTreeTarget(target,cxxPlatform.getFlavor(),HeaderVisibility.PUBLIC)).setIncludes(CxxHeaders.builder().putNameToPathMap(Paths.get(headerName),new TestSourcePath(headerName)).putNameToPathMap(Paths.get(genHeaderName),new BuildTargetSourcePath(genHeaderTarget)).putFullNameToPathMap(headerRoot.resolve(headerName),new TestSourcePath(headerName)).putFullNameToPathMap(headerRoot.resolve(genHeaderName),new BuildTargetSourcePath(genHeaderTarget)).build()).addIncludeRoots(CxxDescriptionEnhancer.getHeaderSymlinkTreePath(target,cxxPlatform.getFlavor(),HeaderVisibility.PUBLIC)).addFrameworkRoots(Paths.get("String_Node_Str"),Paths.get("String_Node_Str")).build(),rule.getCxxPreprocessorInput(cxxPlatform,HeaderVisibility.PUBLIC));
Path privateHeaderRoot=CxxDescriptionEnhancer.getHeaderSymlinkTreePath(target,cxxPlatform.getFlavor(),HeaderVisibility.PRIVATE);
assertEquals(CxxPreprocessorInput.builder().addRules(CxxDescriptionEnhancer.createHeaderSymlinkTreeTarget(target,cxxPlatform.getFlavor(),HeaderVisibility.PRIVATE)).setIncludes(CxxHeaders.builder().putNameToPathMap(Paths.get(privateHeaderName),new TestSourcePath(privateHeaderName)).putFullNameToPathMap(privateHeaderRoot.resolve(privateHeaderName),new TestSourcePath(privateHeaderName)).build()).addIncludeRoots(CxxDescriptionEnhancer.getHeaderSymlinkTreePath(target,cxxPlatform.getFlavor(),HeaderVisibility.PRIVATE)).addFrameworkRoots(Paths.get("String_Node_Str"),Paths.get("String_Node_Str")).build(),rule.getCxxPreprocessorInput(cxxPlatform,HeaderVisibility.PRIVATE));
rule.getNativeLinkableInput(cxxPlatform,Linker.LinkableDepType.STATIC);
BuildRule archiveRule=resolver.getRule(CxxDescriptionEnhancer.createStaticLibraryBuildTarget(target,cxxPlatform.getFlavor(),CxxSourceRuleFactory.PicType.PDC));
assertNotNull(archiveRule);
assertEquals(ImmutableSet.of(cxxSourceRuleFactory.createCompileBuildTarget("String_Node_Str",CxxSourceRuleFactory.PicType.PDC),cxxSourceRuleFactory.createCompileBuildTarget(genSourceName,CxxSourceRuleFactory.PicType.PDC)),FluentIterable.from(archiveRule.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),CxxDescriptionEnhancer.createHeaderSymlinkTreeTarget(target,cxxPlatform.getFlavor(),HeaderVisibility.PUBLIC)),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),CxxDescriptionEnhancer.createHeaderSymlinkTreeTarget(target,cxxPlatform.getFlavor(),HeaderVisibility.PUBLIC)),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(){
  BuildRuleResolver resolver=new BuildRuleResolver();
  SourcePathResolver pathResolver=new SourcePathResolver(resolver);
  CxxPlatform cxxPlatform=CxxLibraryBuilder.createDefaultPlatform();
  String genHeaderName="String_Node_Str";
  BuildTarget genHeaderTarget=BuildTargetFactory.newInstance("String_Node_Str");
  GenruleBuilder genHeaderBuilder=GenruleBuilder.newGenruleBuilder(genHeaderTarget).setOut(genHeaderName);
  genHeaderBuilder.build(resolver);
  String genSourceName="String_Node_Str";
  BuildTarget genSourceTarget=BuildTargetFactory.newInstance("String_Node_Str");
  GenruleBuilder genSourceBuilder=GenruleBuilder.newGenruleBuilder(genSourceTarget).setOut(genSourceName);
  genSourceBuilder.build(resolver);
  final BuildRule header=new FakeBuildRule("String_Node_Str",pathResolver);
  final BuildRule headerSymlinkTree=new FakeBuildRule("String_Node_Str",pathResolver);
  final Path headerSymlinkTreeRoot=Paths.get("String_Node_Str");
  final BuildRule privateHeader=new FakeBuildRule("String_Node_Str",pathResolver);
  final BuildRule privateHeaderSymlinkTree=new FakeBuildRule("String_Node_Str",pathResolver);
  final Path privateHeaderSymlinkTreeRoot=Paths.get("String_Node_Str");
  final BuildRule archive=new FakeBuildRule("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){
switch (headerVisibility) {
case PUBLIC:
        return CxxPreprocessorInput.builder().addRules(header.getBuildTarget(),headerSymlinkTree.getBuildTarget()).addIncludeRoots(headerSymlinkTreeRoot).build();
case PRIVATE:
      return CxxPreprocessorInput.builder().addRules(privateHeader.getBuildTarget(),privateHeaderSymlinkTree.getBuildTarget()).addIncludeRoots(privateHeaderSymlinkTreeRoot).build();
  }
  throw new RuntimeException("String_Node_Str" + headerVisibility);
}
@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,privateHeader,privateHeaderSymlinkTree,archive,dep));
BuildTarget target=BuildTargetFactory.newInstance("String_Node_Str");
CxxSourceRuleFactory cxxSourceRuleFactory=CxxSourceRuleFactoryHelper.of(target,cxxPlatform);
String headerName="String_Node_Str";
String privateHeaderName="String_Node_Str";
CxxLibraryBuilder cxxLibraryBuilder=(CxxLibraryBuilder)new CxxLibraryBuilder(target).setExportedHeaders(ImmutableSortedSet.<SourcePath>of(new TestSourcePath(headerName),new BuildTargetSourcePath(genHeaderTarget))).setHeaders(ImmutableSortedSet.<SourcePath>of(new TestSourcePath(privateHeaderName))).setSrcs(ImmutableList.of(SourceWithFlags.of(new TestSourcePath("String_Node_Str")),SourceWithFlags.of(new BuildTargetSourcePath(genSourceTarget)))).setFrameworkSearchPaths(ImmutableSet.of(Paths.get("String_Node_Str"),Paths.get("String_Node_Str"))).setDeps(ImmutableSortedSet.of(dep.getBuildTarget()));
CxxLibrary rule=(CxxLibrary)cxxLibraryBuilder.build(resolver,new FakeProjectFilesystem(),TargetGraphFactory.newInstance(cxxLibraryBuilder.build(),genSourceBuilder.build(),genHeaderBuilder.build(),GenruleBuilder.newGenruleBuilder(depTarget).build()));
Path headerRoot=CxxDescriptionEnhancer.getHeaderSymlinkTreePath(target,cxxPlatform.getFlavor(),HeaderVisibility.PUBLIC);
assertEquals(CxxPreprocessorInput.builder().addRules(CxxDescriptionEnhancer.createHeaderSymlinkTreeTarget(target,cxxPlatform.getFlavor(),HeaderVisibility.PUBLIC)).setIncludes(CxxHeaders.builder().putNameToPathMap(Paths.get(headerName),new TestSourcePath(headerName)).putNameToPathMap(Paths.get(genHeaderName),new BuildTargetSourcePath(genHeaderTarget)).putFullNameToPathMap(headerRoot.resolve(headerName),new TestSourcePath(headerName)).putFullNameToPathMap(headerRoot.resolve(genHeaderName),new BuildTargetSourcePath(genHeaderTarget)).build()).addIncludeRoots(CxxDescriptionEnhancer.getHeaderSymlinkTreePath(target,cxxPlatform.getFlavor(),HeaderVisibility.PUBLIC)).addFrameworkRoots(Paths.get("String_Node_Str"),Paths.get("String_Node_Str")).build(),rule.getCxxPreprocessorInput(cxxPlatform,HeaderVisibility.PUBLIC));
Path privateHeaderRoot=CxxDescriptionEnhancer.getHeaderSymlinkTreePath(target,cxxPlatform.getFlavor(),HeaderVisibility.PRIVATE);
assertEquals(CxxPreprocessorInput.builder().addRules(CxxDescriptionEnhancer.createHeaderSymlinkTreeTarget(target,cxxPlatform.getFlavor(),HeaderVisibility.PRIVATE)).setIncludes(CxxHeaders.builder().putNameToPathMap(Paths.get(privateHeaderName),new TestSourcePath(privateHeaderName)).putFullNameToPathMap(privateHeaderRoot.resolve(privateHeaderName),new TestSourcePath(privateHeaderName)).build()).addIncludeRoots(CxxDescriptionEnhancer.getHeaderSymlinkTreePath(target,cxxPlatform.getFlavor(),HeaderVisibility.PRIVATE)).addFrameworkRoots(Paths.get("String_Node_Str"),Paths.get("String_Node_Str")).build(),rule.getCxxPreprocessorInput(cxxPlatform,HeaderVisibility.PRIVATE));
rule.getNativeLinkableInput(cxxPlatform,Linker.LinkableDepType.STATIC);
BuildRule archiveRule=resolver.getRule(CxxDescriptionEnhancer.createStaticLibraryBuildTarget(target,cxxPlatform.getFlavor(),CxxSourceRuleFactory.PicType.PDC));
assertNotNull(archiveRule);
assertEquals(ImmutableSet.of(cxxSourceRuleFactory.createCompileBuildTarget("String_Node_Str",CxxSourceRuleFactory.PicType.PDC),cxxSourceRuleFactory.createCompileBuildTarget(genSourceName,CxxSourceRuleFactory.PicType.PDC)),FluentIterable.from(archiveRule.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),CxxDescriptionEnhancer.createHeaderSymlinkTreeTarget(target,cxxPlatform.getFlavor(),HeaderVisibility.PUBLIC)),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),CxxDescriptionEnhancer.createHeaderSymlinkTreeTarget(target,cxxPlatform.getFlavor(),HeaderVisibility.PUBLIC)),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());
}