Here are the examples of the java api com.google.devtools.build.lib.testutil.TestConstants.LOAD_PROTO_LIBRARY taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
59 Examples
19
View Complete Implementation : CcProtoLibraryTest.java
Copyright Apache License 2.0
Author : bazelbuild
Copyright Apache License 2.0
Author : bazelbuild
@Test
public void disallowMultipleDeps() throws Exception {
checkError("x", "foo_cc_proto", "'deps' attribute must contain exactly one label", TestConstants.LOAD_PROTO_LIBRARY, "cc_proto_library(name = 'foo_cc_proto', deps = ['foo_proto', 'bar_proto'])", "proto_library(name = 'foo_proto', srcs = ['foo.proto'])", "proto_library(name = 'bar_proto', srcs = ['bar.proto'])");
checkError("y", "foo_cc_proto", "'deps' attribute must contain exactly one label", "cc_proto_library(name = 'foo_cc_proto', deps = [])");
}
19
View Complete Implementation : CcProtoLibraryTest.java
Copyright Apache License 2.0
Author : bazelbuild
Copyright Apache License 2.0
Author : bazelbuild
@Test
public void stripImportPrefixWorksWithRepositories() throws Exception {
FileSystemUtils.appendIsoLatin1(scratch.resolve("WORKSPACE"), "local_repository(name = 'yolo_repo', path = '/yolo_repo')");
invalidatePackages();
scratch.file("/yolo_repo/WORKSPACE");
scratch.file("/yolo_repo/yolo_pkg/yolo.proto");
scratch.file("/yolo_repo/yolo_pkg/BUILD", TestConstants.LOAD_PROTO_LIBRARY, "proto_library(", " name = 'yolo_proto',", " srcs = ['yolo.proto'],", " strip_import_prefix = '/yolo_pkg',", ")", "cc_proto_library(", " name = 'yolo_cc_proto',", " deps = [':yolo_proto'],", ")");
replacedertThat(getTarget("@yolo_repo//yolo_pkg:yolo_cc_proto")).isNotNull();
replacedertThat(getProtoHeaderExecPath()).endsWith("_virtual_includes/yolo_proto/yolo.pb.h");
}
19
View Complete Implementation : CcProtoLibraryTest.java
Copyright Apache License 2.0
Author : bazelbuild
Copyright Apache License 2.0
Author : bazelbuild
@Test
public void aliasProtos() throws Exception {
scratch.file("x/BUILD", TestConstants.LOAD_PROTO_LIBRARY, "cc_proto_library(name = 'foo_cc_proto', deps = ['alias_proto'])", "proto_library(name = 'alias_proto', deps = [':foo_proto'])", "proto_library(name = 'foo_proto', srcs = ['foo.proto'])");
CcCompilationContext ccCompilationContext = getConfiguredTarget("//x:foo_cc_proto").get(CcInfo.PROVIDER).getCcCompilationContext();
replacedertThat(prettyArtifactNames(ccCompilationContext.getDeclaredIncludeSrcs())).containsExactly("x/foo.pb.h");
}
19
View Complete Implementation : CcProtoLibraryTest.java
Copyright Apache License 2.0
Author : bazelbuild
Copyright Apache License 2.0
Author : bazelbuild
@Test
public void importPrefixWorksWithRepositories() throws Exception {
FileSystemUtils.appendIsoLatin1(scratch.resolve("WORKSPACE"), "local_repository(name = 'yolo_repo', path = '/yolo_repo')");
invalidatePackages();
scratch.file("/yolo_repo/WORKSPACE");
scratch.file("/yolo_repo/yolo_pkg/yolo.proto");
scratch.file("/yolo_repo/yolo_pkg/BUILD", TestConstants.LOAD_PROTO_LIBRARY, "proto_library(", " name = 'yolo_proto',", " srcs = ['yolo.proto'],", " import_prefix = 'bazel.build/yolo',", ")", "cc_proto_library(", " name = 'yolo_cc_proto',", " deps = [':yolo_proto'],", ")");
replacedertThat(getTarget("@yolo_repo//yolo_pkg:yolo_cc_proto")).isNotNull();
replacedertThat(getProtoHeaderExecPath()).endsWith("_virtual_includes/yolo_proto/bazel.build/yolo/yolo_pkg/yolo.pb.h");
}
19
View Complete Implementation : CcProtoLibraryTest.java
Copyright Apache License 2.0
Author : bazelbuild
Copyright Apache License 2.0
Author : bazelbuild
@Test
public void importPrefixAndStripImportPrefixWorksWithRepositories() throws Exception {
FileSystemUtils.appendIsoLatin1(scratch.resolve("WORKSPACE"), "local_repository(name = 'yolo_repo', path = '/yolo_repo')");
invalidatePackages();
scratch.file("/yolo_repo/WORKSPACE");
scratch.file("/yolo_repo/yolo_pkg/yolo.proto");
scratch.file("/yolo_repo/yolo_pkg/BUILD", TestConstants.LOAD_PROTO_LIBRARY, "proto_library(", " name = 'yolo_proto',", " srcs = ['yolo.proto'],", " import_prefix = 'bazel.build/yolo',", " strip_import_prefix = '/yolo_pkg'", ")", "cc_proto_library(", " name = 'yolo_cc_proto',", " deps = [':yolo_proto'],", ")");
getTarget("@yolo_repo//yolo_pkg:yolo_cc_proto");
replacedertThat(getTarget("@yolo_repo//yolo_pkg:yolo_cc_proto")).isNotNull();
replacedertThat(getProtoHeaderExecPath()).endsWith("_virtual_includes/yolo_proto/bazel.build/yolo/yolo.pb.h");
}
19
View Complete Implementation : CcProtoLibraryTest.java
Copyright Apache License 2.0
Author : bazelbuild
Copyright Apache License 2.0
Author : bazelbuild
@Test
public void blacklistedProtos() throws Exception {
scratch.file("x/BUILD", TestConstants.LOAD_PROTO_LIBRARY, "cc_proto_library(name = 'any_cc_proto', deps = ['@com_google_protobuf//:any_proto'])");
CcCompilationContext ccCompilationContext = getConfiguredTarget("//x:any_cc_proto").get(CcInfo.PROVIDER).getCcCompilationContext();
replacedertThat(prettyArtifactNames(ccCompilationContext.getDeclaredIncludeSrcs())).isEmpty();
}
19
View Complete Implementation : CcProtoLibraryTest.java
Copyright Apache License 2.0
Author : bazelbuild
Copyright Apache License 2.0
Author : bazelbuild
// TODO(carmi): test blacklisted protos. I don't currently understand what's the wanted behavior.
@Test
public void generatedSourcesNotCoverageInstrumented() throws Exception {
useConfiguration("--collect_code_coverage", "--instrumentation_filter=.");
scratch.file("x/BUILD", TestConstants.LOAD_PROTO_LIBRARY, "cc_proto_library(name = 'foo_cc_proto', deps = ['foo_proto'])", "proto_library(name = 'foo_proto', srcs = ['foo.proto'])");
ConfiguredTarget target = getConfiguredTarget("//x:foo_cc_proto");
List<CppCompileAction> compilationSteps = actionsTestUtil().findTransitivePrerequisitesOf(getFirstArtifactEndingWith(getFilesToBuild(target), ".a"), CppCompileAction.clreplaced);
List<String> options = compilationSteps.get(0).getCompilerOptions();
replacedertThat(options).doesNotContain("-fprofile-arcs");
replacedertThat(options).doesNotContain("-ftest-coverage");
}
19
View Complete Implementation : CcProtoLibraryTest.java
Copyright Apache License 2.0
Author : bazelbuild
Copyright Apache License 2.0
Author : bazelbuild
@Test
public void blacklistedProtosInTransitiveDeps() throws Exception {
scratch.file("x/BUILD", TestConstants.LOAD_PROTO_LIBRARY, "cc_proto_library(name = 'foo_cc_proto', deps = ['foo_proto'])", "proto_library(", " name = 'foo_proto',", " srcs = ['foo.proto'],", " deps = ['@com_google_protobuf//:any_proto'],", ")");
CcCompilationContext ccCompilationContext = getConfiguredTarget("//x:foo_cc_proto").get(CcInfo.PROVIDER).getCcCompilationContext();
replacedertThat(prettyArtifactNames(ccCompilationContext.getDeclaredIncludeSrcs())).containsExactly("x/foo.pb.h");
}
19
View Complete Implementation : CcProtoLibraryTest.java
Copyright Apache License 2.0
Author : bazelbuild
Copyright Apache License 2.0
Author : bazelbuild
private void setupTestCcProtoLibraryLoadedThroughMacro(boolean loadMacro) throws Exception {
useConfiguration("--incompatible_load_cc_rules_from_bzl");
scratch.file("a/BUILD", getreplacedysisMock().ccSupport().getMacroLoadStatement(loadMacro, "cc_proto_library"), TestConstants.LOAD_PROTO_LIBRARY, "cc_proto_library(", " name='a',", " deps=[':a_p'],", ")", "proto_library(", " name='a_p',", " srcs = ['a.proto'],", ")");
}
19
View Complete Implementation : CcProtoLibraryTest.java
Copyright Apache License 2.0
Author : bazelbuild
Copyright Apache License 2.0
Author : bazelbuild
@Test
public void ccCompilationContext() throws Exception {
scratch.file("x/BUILD", TestConstants.LOAD_PROTO_LIBRARY, "cc_proto_library(name = 'foo_cc_proto', deps = ['foo_proto'])", "proto_library(name = 'foo_proto', srcs = ['foo.proto'], deps = [':bar_proto'])", "proto_library(name = 'bar_proto', srcs = ['bar.proto'])");
CcCompilationContext ccCompilationContext = getConfiguredTarget("//x:foo_cc_proto").get(CcInfo.PROVIDER).getCcCompilationContext();
replacedertThat(prettyArtifactNames(ccCompilationContext.getDeclaredIncludeSrcs())).containsExactly("x/foo.pb.h", "x/bar.pb.h");
}
19
View Complete Implementation : CcProtoLibraryTest.java
Copyright Apache License 2.0
Author : bazelbuild
Copyright Apache License 2.0
Author : bazelbuild
@Test
public void canBeUsedFromCcRules() throws Exception {
scratch.file("x/BUILD", TestConstants.LOAD_PROTO_LIBRARY, "cc_library(name = 'foo', srcs = ['foo.cc'], deps = ['foo_cc_proto'])", "cc_binary(name = 'bin', srcs = ['bin.cc'], deps = ['foo_cc_proto'])", "cc_proto_library(name = 'foo_cc_proto', deps = ['foo_proto'])", "proto_library(name = 'foo_proto', srcs = ['foo.proto'])");
update(ImmutableList.of("//x:foo", "//x:bin"), false, /* keepGoing */
1, /* loadingPhaseThreads */
true, /* doreplacedysis */
new EventBus());
}
18
View Complete Implementation : BazelProtoLibraryTest.java
Copyright Apache License 2.0
Author : bazelbuild
Copyright Apache License 2.0
Author : bazelbuild
@Test
public void testIllegalStripImportPrefix() throws Exception {
scratch.file("third_party/a/BUILD", "licenses(['unenreplacedbered'])", TestConstants.LOAD_PROTO_LIBRARY, "proto_library(", " name = 'a',", " srcs = ['a.proto'],", " strip_import_prefix = 'foo')");
reporter.removeHandler(failFastHandler);
getConfiguredTarget("//third_party/a");
replacedertContainsEvent(".proto file 'third_party/a/a.proto' is not under the specified strip prefix");
}
18
View Complete Implementation : BazelProtoLibraryTest.java
Copyright Apache License 2.0
Author : bazelbuild
Copyright Apache License 2.0
Author : bazelbuild
@Test
public void testDescriptorSetOutput_strictDeps() throws Exception {
useConfiguration("--proto_compiler=//proto:compiler", "--strict_proto_deps=error");
scratch.file("x/BUILD", TestConstants.LOAD_PROTO_LIBRARY, "proto_library(name='nodeps', srcs=['nodeps.proto'])", "proto_library(name='withdeps', srcs=['withdeps.proto'], deps=[':dep1', ':dep2'])", "proto_library(name='depends_on_alias', srcs=['depends_on_alias.proto'], deps=[':alias'])", "proto_library(name='alias', deps=[':dep1', ':dep2'])", "proto_library(name='dep1', srcs=['dep1.proto'])", "proto_library(name='dep2', srcs=['dep2.proto'])");
replacedertThat(getGeneratingSpawnAction(getDescriptorOutput("//x:nodeps")).getRemainingArguments()).containsAtLeast("--direct_dependencies", "x/nodeps.proto").inOrder();
replacedertThat(getGeneratingSpawnAction(getDescriptorOutput("//x:withdeps")).getRemainingArguments()).containsAtLeast("--direct_dependencies", "x/dep1.proto:x/dep2.proto:x/withdeps.proto").inOrder();
replacedertThat(getGeneratingSpawnAction(getDescriptorOutput("//x:depends_on_alias")).getRemainingArguments()).containsAtLeast("--direct_dependencies", "x/dep1.proto:x/dep2.proto:x/depends_on_alias.proto").inOrder();
}
18
View Complete Implementation : BazelProtoLibraryTest.java
Copyright Apache License 2.0
Author : bazelbuild
Copyright Apache License 2.0
Author : bazelbuild
@Test
public void testDotDotInStripImportPrefix() throws Exception {
scratch.file("third_party/a/b/BUILD", "licenses(['unenreplacedbered'])", TestConstants.LOAD_PROTO_LIBRARY, "proto_library(", " name = 'd',", " srcs = ['c/d.proto'],", " strip_import_prefix = '../b/c')");
reporter.removeHandler(failFastHandler);
getConfiguredTarget("//third_party/a/b:d");
replacedertContainsEvent("should be normalized");
}
18
View Complete Implementation : BazelProtoLibraryTest.java
Copyright Apache License 2.0
Author : bazelbuild
Copyright Apache License 2.0
Author : bazelbuild
@Test
public void testStripImportPrefixAndImportPrefixWithStrictProtoDeps() throws Exception {
if (!isThisBazel()) {
return;
}
useConfiguration("--strict_proto_deps=STRICT");
scratch.file("a/b/BUILD", TestConstants.LOAD_PROTO_LIBRARY, "proto_library(", " name = 'd',", " srcs = ['c/d.proto'],", " import_prefix = 'foo',", " strip_import_prefix = 'c')");
Iterable<String> commandLine = paramFileArgsForAction(getDescriptorWriteAction("//a/b:d"));
replacedertThat(commandLine).containsAtLeast("--direct_dependencies", "foo/d.proto").inOrder();
}
18
View Complete Implementation : BazelProtoLibraryTest.java
Copyright Apache License 2.0
Author : bazelbuild
Copyright Apache License 2.0
Author : bazelbuild
@Test
public void testRelativeStripImportPrefix() throws Exception {
scratch.file("third_party/a/b/BUILD", "licenses(['unenreplacedbered'])", TestConstants.LOAD_PROTO_LIBRARY, "proto_library(", " name = 'd',", " srcs = ['c/d.proto'],", " strip_import_prefix = 'c')");
Iterable<String> commandLine = paramFileArgsForAction(getDescriptorWriteAction("//third_party/a/b:d"));
String genfiles = getTargetConfiguration().getGenfilesFragment().toString();
replacedertThat(commandLine).contains("-Id.proto=" + genfiles + "/third_party/a/b/_virtual_imports/d/d.proto");
}
18
View Complete Implementation : BazelProtoLibraryTest.java
Copyright Apache License 2.0
Author : bazelbuild
Copyright Apache License 2.0
Author : bazelbuild
@Test
public void testAbsoluteStripImportPrefix() throws Exception {
scratch.file("third_party/a/b/BUILD", "licenses(['unenreplacedbered'])", TestConstants.LOAD_PROTO_LIBRARY, "proto_library(", " name = 'd',", " srcs = ['c/d.proto'],", " strip_import_prefix = '/third_party/a')");
Iterable<String> commandLine = paramFileArgsForAction(getDescriptorWriteAction("//third_party/a/b:d"));
String genfiles = getTargetConfiguration().getGenfilesFragment().toString();
replacedertThat(commandLine).contains("-Ib/c/d.proto=" + genfiles + "/third_party/a/b/_virtual_imports/d/b/c/d.proto");
}
18
View Complete Implementation : BazelProtoLibraryTest.java
Copyright Apache License 2.0
Author : bazelbuild
Copyright Apache License 2.0
Author : bazelbuild
@Test
public void testIllegalImportPrefix() throws Exception {
if (!isThisBazel()) {
return;
}
scratch.file("a/BUILD", TestConstants.LOAD_PROTO_LIBRARY, "proto_library(", " name = 'a',", " srcs = ['a.proto'],", " import_prefix = '/foo')");
reporter.removeHandler(failFastHandler);
getConfiguredTarget("//a");
replacedertContainsEvent("should be a relative path");
}
18
View Complete Implementation : BazelProtoLibraryTest.java
Copyright Apache License 2.0
Author : bazelbuild
Copyright Apache License 2.0
Author : bazelbuild
@Test
public void testDotInImportPrefix() throws Exception {
if (!isThisBazel()) {
return;
}
scratch.file("a/b/BUILD", TestConstants.LOAD_PROTO_LIBRARY, "proto_library(", " name = 'd',", " srcs = ['c/d.proto'],", " import_prefix = './e')");
reporter.removeHandler(failFastHandler);
getConfiguredTarget("//a/b:d");
replacedertContainsEvent("should be normalized");
}
18
View Complete Implementation : CcProtoLibraryTest.java
Copyright Apache License 2.0
Author : bazelbuild
Copyright Apache License 2.0
Author : bazelbuild
@Before
public void setUp() throws Exception {
scratch.file("protobuf/WORKSPACE");
scratch.overwriteFile("protobuf/BUILD", TestConstants.LOAD_PROTO_LANG_TOOLCHAIN, TestConstants.LOAD_PROTO_LIBRARY, "package(default_visibility=['//visibility:public'])", "exports_files(['protoc'])", "proto_library(", " name = 'any_proto',", " srcs = ['any.proto'],", ")", "proto_lang_toolchain(", " name = 'cc_toolchain',", " command_line = '--cpp_out=$(OUT)',", " blacklisted_protos = [':any_proto'],", ")");
scratch.appendFile("WORKSPACE", "local_repository(", " name = 'com_google_protobuf',", " path = 'protobuf',", ")");
MockProtoSupport.setupWorkspace(scratch);
// A dash of magic to re-evaluate the WORKSPACE file.
invalidatePackages();
}
18
View Complete Implementation : BazelProtoLibraryTest.java
Copyright Apache License 2.0
Author : bazelbuild
Copyright Apache License 2.0
Author : bazelbuild
@Test
public void testDotDotInImportPrefix() throws Exception {
if (!isThisBazel()) {
return;
}
scratch.file("a/b/BUILD", TestConstants.LOAD_PROTO_LIBRARY, "proto_library(", " name = 'd',", " srcs = ['c/d.proto'],", " import_prefix = '../e')");
reporter.removeHandler(failFastHandler);
getConfiguredTarget("//a/b:d");
replacedertContainsEvent("should be normalized");
}
18
View Complete Implementation : BazelProtoLibraryTest.java
Copyright Apache License 2.0
Author : bazelbuild
Copyright Apache License 2.0
Author : bazelbuild
@Test
public void testStripImportPrefixAndImportPrefix() throws Exception {
if (!isThisBazel()) {
return;
}
scratch.file("a/b/BUILD", TestConstants.LOAD_PROTO_LIBRARY, "proto_library(", " name = 'd',", " srcs = ['c/d.proto'],", " import_prefix = 'foo',", " strip_import_prefix = 'c')");
Iterable<String> commandLine = paramFileArgsForAction(getDescriptorWriteAction("//a/b:d"));
String genfiles = getTargetConfiguration().getGenfilesFragment().toString();
replacedertThat(commandLine).contains("-Ifoo/d.proto=" + genfiles + "/a/b/_virtual_imports/d/foo/d.proto");
}
18
View Complete Implementation : BazelProtoLibraryTest.java
Copyright Apache License 2.0
Author : bazelbuild
Copyright Apache License 2.0
Author : bazelbuild
@Test
public void createsDescriptorSets() throws Exception {
scratch.file("x/BUILD", TestConstants.LOAD_PROTO_LIBRARY, "proto_library(name='alias', deps = ['foo'])", "proto_library(name='foo', srcs=['foo.proto'])", "proto_library(name='alias_to_no_srcs', deps = ['no_srcs'])", "proto_library(name='no_srcs')");
replacedertThat(getDescriptorOutput("//x:alias").getRootRelativePathString()).isEqualTo("x/alias-descriptor-set.proto.bin");
replacedertThat(getDescriptorOutput("//x:foo").getRootRelativePathString()).isEqualTo("x/foo-descriptor-set.proto.bin");
replacedertThat(getDescriptorOutput("//x:alias_to_no_srcs").getRootRelativePathString()).isEqualTo("x/alias_to_no_srcs-descriptor-set.proto.bin");
replacedertThat(getDescriptorOutput("//x:no_srcs").getRootRelativePathString()).isEqualTo("x/no_srcs-descriptor-set.proto.bin");
}
18
View Complete Implementation : CcProtoLibraryTest.java
Copyright Apache License 2.0
Author : bazelbuild
Copyright Apache License 2.0
Author : bazelbuild
@Test
public void commandLineControlsOutputFileSuffixes() throws Exception {
getreplacedysisMock().ccSupport().setupCcToolchainConfig(mockToolsConfig, CcToolchainConfig.builder().withFeatures(CppRuleClreplacedes.SUPPORTS_DYNAMIC_LINKER, CppRuleClreplacedes.SUPPORTS_INTERFACE_SHARED_LIBRARIES));
useConfiguration("--cc_proto_library_header_suffixes=.pb.h,.proto.h", "--cc_proto_library_source_suffixes=.pb.cc,.pb.cc.meta");
scratch.file("x/BUILD", TestConstants.LOAD_PROTO_LIBRARY, "cc_proto_library(name = 'foo_cc_proto', deps = ['foo_proto'])", "proto_library(name = 'foo_proto', srcs = ['foo.proto'])");
replacedertThat(prettyArtifactNames(getFilesToBuild(getConfiguredTarget("//x:foo_cc_proto")))).containsExactly("x/foo.pb.cc", "x/foo.pb.h", "x/foo.pb.cc.meta", "x/foo.proto.h", "x/libfoo_proto.a", "x/libfoo_proto.ifso", "x/libfoo_proto.so");
}
18
View Complete Implementation : BazelProtoLibraryTest.java
Copyright Apache License 2.0
Author : bazelbuild
Copyright Apache License 2.0
Author : bazelbuild
@Test
public void testStripImportPrefixWithStrictProtoDeps() throws Exception {
if (!isThisBazel()) {
return;
}
useConfiguration("--strict_proto_deps=STRICT");
scratch.file("a/b/BUILD", TestConstants.LOAD_PROTO_LIBRARY, "proto_library(", " name = 'd',", " srcs = ['c/d.proto','c/e.proto'],", " strip_import_prefix = 'c')");
Iterable<String> commandLine = paramFileArgsForAction(getDescriptorWriteAction("//a/b:d"));
replacedertThat(commandLine).containsAtLeast("--direct_dependencies", "d.proto:e.proto").inOrder();
}
18
View Complete Implementation : BazelProtoLibraryTest.java
Copyright Apache License 2.0
Author : bazelbuild
Copyright Apache License 2.0
Author : bazelbuild
@Test
public void testStripImportPrefixForExternalRepositories() throws Exception {
if (!isThisBazel()) {
return;
}
FileSystemUtils.appendIsoLatin1(scratch.resolve("WORKSPACE"), "local_repository(name = 'foo', path = '/foo')");
invalidatePackages();
scratch.file("/foo/WORKSPACE");
scratch.file("/foo/x/y/BUILD", TestConstants.LOAD_PROTO_LIBRARY, "proto_library(", " name = 'q',", " srcs = ['z/q.proto'],", " strip_import_prefix = '/x')");
scratch.file("a/BUILD", TestConstants.LOAD_PROTO_LIBRARY, "proto_library(name='a', srcs=['a.proto'], deps=['@foo//x/y:q'])");
Iterable<String> commandLine = paramFileArgsForAction(getDescriptorWriteAction("//a:a"));
String genfiles = getTargetConfiguration().getGenfilesFragment().toString();
replacedertThat(commandLine).contains("-Iy/z/q.proto=" + genfiles + "/external/foo/x/y/_virtual_imports/q/y/z/q.proto");
}
18
View Complete Implementation : BazelProtoLibraryTest.java
Copyright Apache License 2.0
Author : bazelbuild
Copyright Apache License 2.0
Author : bazelbuild
@Test
public void testImportPrefixWithoutStripImportPrefix() throws Exception {
if (!isThisBazel()) {
return;
}
scratch.file("a/b/BUILD", TestConstants.LOAD_PROTO_LIBRARY, "proto_library(", " name = 'd',", " srcs = ['c/d.proto'],", " import_prefix = 'foo')");
Iterable<String> commandLine = paramFileArgsForAction(getDescriptorWriteAction("//a/b:d"));
String genfiles = getTargetConfiguration().getGenfilesFragment().toString();
replacedertThat(commandLine).contains("-Ifoo/a/b/c/d.proto=" + genfiles + "/a/b/_virtual_imports/d/foo/a/b/c/d.proto");
}
18
View Complete Implementation : BazelProtoLibraryTest.java
Copyright Apache License 2.0
Author : bazelbuild
Copyright Apache License 2.0
Author : bazelbuild
/**
* replacederts that the actions creating descriptor sets for rule R, take as input (=depend on) all of
* the descriptor sets of the transitive dependencies of R.
*
* <p>This is needed so that building R, that has a dependency R' which violates strict proto
* deps, would break.
*/
@Test
public void descriptorSetsDependOnChildren() throws Exception {
scratch.file("x/BUILD", TestConstants.LOAD_PROTO_LIBRARY, "proto_library(name='alias', deps = ['foo'])", "proto_library(name='foo', srcs=['foo.proto'], deps = ['bar'])", "proto_library(name='bar', srcs=['bar.proto'])", "proto_library(name='alias_to_no_srcs', deps = ['no_srcs'])", "proto_library(name='no_srcs')");
replacedertThat(getDepsDescriptorSets(getDescriptorOutput("//x:alias"))).containsExactly("x/foo-descriptor-set.proto.bin", "x/bar-descriptor-set.proto.bin");
replacedertThat(getDepsDescriptorSets(getDescriptorOutput("//x:foo"))).containsExactly("x/bar-descriptor-set.proto.bin");
replacedertThat(getDepsDescriptorSets(getDescriptorOutput("//x:bar"))).isEmpty();
replacedertThat(getDepsDescriptorSets(getDescriptorOutput("//x:alias_to_no_srcs"))).containsExactly("x/no_srcs-descriptor-set.proto.bin");
replacedertThat(getDepsDescriptorSets(getDescriptorOutput("//x:no_srcs"))).isEmpty();
}
18
View Complete Implementation : CcProtoLibraryTest.java
Copyright Apache License 2.0
Author : bazelbuild
Copyright Apache License 2.0
Author : bazelbuild
@Test
public void basic() throws Exception {
getreplacedysisMock().ccSupport().setupCcToolchainConfig(mockToolsConfig, CcToolchainConfig.builder().withFeatures(CppRuleClreplacedes.SUPPORTS_DYNAMIC_LINKER, CppRuleClreplacedes.SUPPORTS_INTERFACE_SHARED_LIBRARIES));
scratch.file("x/BUILD", TestConstants.LOAD_PROTO_LIBRARY, "cc_proto_library(name = 'foo_cc_proto', deps = ['foo_proto'])", "proto_library(name = 'foo_proto', srcs = ['foo.proto'])");
replacedertThat(prettyArtifactNames(getFilesToBuild(getConfiguredTarget("//x:foo_cc_proto")))).containsExactly("x/foo.pb.h", "x/foo.pb.cc", "x/libfoo_proto.a", "x/libfoo_proto.ifso", "x/libfoo_proto.so");
}
18
View Complete Implementation : BazelProtoLibraryTest.java
Copyright Apache License 2.0
Author : bazelbuild
Copyright Apache License 2.0
Author : bazelbuild
/**
* replacederts that we register a FileWriteAction with empty contents if there are no srcs.
*/
@Test
public void descriptorSets_ruleWithoutSrcsWritesEmptyFile() throws Exception {
scratch.file("x/BUILD", TestConstants.LOAD_PROTO_LIBRARY, "proto_library(name='no_srcs')");
Action action = getDescriptorWriteAction("//x:no_srcs");
replacedertThat(action).isInstanceOf(FileWriteAction.clreplaced);
replacedertThat(((FileWriteAction) action).getFileContents()).isEmpty();
}
18
View Complete Implementation : BazelProtoLibraryTest.java
Copyright Apache License 2.0
Author : bazelbuild
Copyright Apache License 2.0
Author : bazelbuild
@Test
public void testDotInStripImportPrefix() throws Exception {
scratch.file("third_party/a/b/BUILD", "licenses(['unenreplacedbered'])", TestConstants.LOAD_PROTO_LIBRARY, "proto_library(", " name = 'd',", " srcs = ['c/d.proto'],", " strip_import_prefix = './c')");
reporter.removeHandler(failFastHandler);
getConfiguredTarget("//third_party/a/b:d");
replacedertContainsEvent("should be normalized");
}
18
View Complete Implementation : BazelProtoLibraryTest.java
Copyright Apache License 2.0
Author : bazelbuild
Copyright Apache License 2.0
Author : bazelbuild
@Test
public void testDescriptorSetOutput_strictDeps_disabled() throws Exception {
useConfiguration("--proto_compiler=//proto:compiler", "--strict_proto_deps=off");
scratch.file("x/BUILD", TestConstants.LOAD_PROTO_LIBRARY, "proto_library(name='foo', srcs=['foo.proto'])");
for (String arg : getGeneratingSpawnAction(getDescriptorOutput("//x:foo")).getRemainingArguments()) {
replacedertThat(arg).doesNotContain("--direct_dependencies=");
}
}
18
View Complete Implementation : BazelProtoLibraryTest.java
Copyright Apache License 2.0
Author : bazelbuild
Copyright Apache License 2.0
Author : bazelbuild
@Test
public void testDepOnStripImportPrefixWithStrictProtoDeps() throws Exception {
if (!isThisBazel()) {
return;
}
useConfiguration("--strict_proto_deps=STRICT");
scratch.file("a/b/BUILD", TestConstants.LOAD_PROTO_LIBRARY, "proto_library(", " name = 'd',", " srcs = ['c/d.proto'],", " strip_import_prefix = 'c')");
scratch.file("a/b/e/BUILD", TestConstants.LOAD_PROTO_LIBRARY, "proto_library(", " name = 'e',", " srcs = ['e.proto'],", " deps = ['//a/b:d'])");
Iterable<String> commandLine = paramFileArgsForAction(getDescriptorWriteAction("//a/b/e:e"));
replacedertThat(commandLine).containsAtLeast("--direct_dependencies", "d.proto:a/b/e/e.proto").inOrder();
}
17
View Complete Implementation : CcSkylarkApiProviderTest.java
Copyright Apache License 2.0
Author : bazelbuild
Copyright Apache License 2.0
Author : bazelbuild
@Test
public void testDisableInCcProtoLibrary() throws Exception {
if (!replacedysisMock.isThisBazel()) {
// Our internal version does not have this rule
return;
}
mockToolsConfig.create("/protobuf/WORKSPACE");
mockToolsConfig.overwrite("/protobuf/BUILD", TestConstants.LOAD_PROTO_LANG_TOOLCHAIN, "package(default_visibility=['//visibility:public'])", "exports_files(['protoc'])", "proto_lang_toolchain(", " name = 'cc_toolchain',", " command_line = '--cpp_out=$(OUT)',", " blacklisted_protos = [],", ")");
String existingWorkspace = new String(FileSystemUtils.readContentAsLatin1(rootDirectory.getRelative("WORKSPACE")));
mockToolsConfig.overwrite("WORKSPACE", "local_repository(name = 'com_google_protobuf', path = '/protobuf/')", existingWorkspace);
// A dash of magic to re-evaluate the WORKSPACE file.
invalidatePackages();
useConfiguration("--incompatible_disable_legacy_cc_provider");
scratch.file("a/BUILD", TestConstants.LOAD_PROTO_LIBRARY, "cc_proto_library(name='a', deps=[':p'])", "proto_library(name='p', srcs=['p.proto'])");
replacedertThat(getApi("//a:a")).isNull();
}
17
View Complete Implementation : CcProtoLibraryTest.java
Copyright Apache License 2.0
Author : bazelbuild
Copyright Apache License 2.0
Author : bazelbuild
@Test
public void outputDirectoryForProtoCompileAction_externalRepos() throws Exception {
scratch.file("x/BUILD", "cc_proto_library(name = 'foo_cc_proto', deps = ['@bla//foo:bar_proto'])");
scratch.file("/bla/WORKSPACE");
// Create the rule '@bla//foo:bar_proto'.
scratch.file("/bla/foo/BUILD", TestConstants.LOAD_PROTO_LIBRARY, "package(default_visibility=['//visibility:public'])", "proto_library(name = 'bar_proto', srcs = ['bar.proto'])");
String existingWorkspace = new String(FileSystemUtils.readContentAsLatin1(rootDirectory.getRelative("WORKSPACE")));
scratch.overwriteFile("WORKSPACE", "local_repository(name = 'bla', path = '/bla/')", existingWorkspace);
// A dash of magic to re-evaluate the WORKSPACE file.
invalidatePackages();
ConfiguredTarget target = getConfiguredTarget("//x:foo_cc_proto");
Artifact hFile = getFirstArtifactEndingWith(getFilesToBuild(target), "bar.pb.h");
SpawnAction protoCompileAction = getGeneratingSpawnAction(hFile);
replacedertThat(protoCompileAction.getArguments()).contains(String.format("--cpp_out=%s/external/bla", getTargetConfiguration().getGenfilesFragment().toString()));
Artifact headerFile = getDerivedArtifact(PathFragment.create("external/bla/foo/bar.pb.h"), targetConfig.getGenfilesDirectory(), getOwnerForAspect(getConfiguredTarget("@bla//foo:bar_proto"), ruleClreplacedProvider.getNativeAspectClreplaced(BazelCcProtoAspect.clreplaced.getSimpleName()), AspectParameters.EMPTY));
CcCompilationContext ccCompilationContext = target.get(CcInfo.PROVIDER).getCcCompilationContext();
replacedertThat(ccCompilationContext.getDeclaredIncludeSrcs().toList()).containsExactly(headerFile);
}
17
View Complete Implementation : CcProtoLibraryTest.java
Copyright Apache License 2.0
Author : bazelbuild
Copyright Apache License 2.0
Author : bazelbuild
@Test
public void outputDirectoryForProtoCompileAction() throws Exception {
scratch.file("x/BUILD", TestConstants.LOAD_PROTO_LIBRARY, "cc_proto_library(name = 'foo_cc_proto', deps = [':bar_proto'])", "proto_library(name = 'bar_proto', srcs = ['bar.proto'])");
Artifact hFile = getFirstArtifactEndingWith(getFilesToBuild(getConfiguredTarget("//x:foo_cc_proto")), "bar.pb.h");
SpawnAction protoCompileAction = getGeneratingSpawnAction(hFile);
replacedertThat(protoCompileAction.getArguments()).contains(String.format("--cpp_out=%s", getTargetConfiguration().getGenfilesFragment().toString()));
}
17
View Complete Implementation : ObjcProtoAspectTest.java
Copyright Apache License 2.0
Author : bazelbuild
Copyright Apache License 2.0
Author : bazelbuild
@Test
public void testObjcProtoAspectPropagatesProvider() throws Exception {
MockObjcSupport.setupObjcProtoLibrary(scratch);
scratch.file("x/data_filter.pbascii");
scratch.file("x/BUILD", TestConstants.LOAD_PROTO_LIBRARY, "load('//objc_proto_library:objc_proto_library.bzl', 'objc_proto_library')", "proto_library(", " name = 'protos',", " srcs = ['data.proto'],", ")", "objc_proto_library(", " name = 'x',", " deps = [':protos'],", " portable_proto_filters = ['data_filter.pbascii'],", ")");
ConfiguredTarget topTarget = getObjcProtoAspectConfiguredTarget("//x:x");
ObjcProtoProvider objcProtoProvider = topTarget.get(ObjcProtoProvider.SKYLARK_CONSTRUCTOR);
replacedertThat(objcProtoProvider).isNotNull();
}
17
View Complete Implementation : ObjcProtoAspectTest.java
Copyright Apache License 2.0
Author : bazelbuild
Copyright Apache License 2.0
Author : bazelbuild
@Test
public void testObjcProtoAspectPropagatesProviderThroughSkylarkRule() throws Exception {
MockObjcSupport.setupObjcProtoLibrary(scratch);
scratch.file("x/data_filter.pbascii");
scratch.file("test_skylark/BUILD");
scratch.file("test_skylark/top_level_stub.bzl", "MyInfo = provider()", "def top_level_stub_impl(ctx):", " deps = hasattr(ctx.attr.deps[0], 'ObjcProto')", " return MyInfo(dep = ctx.attr.deps[0])", "top_level_stub = rule(", " top_level_stub_impl,", " attrs = {", " 'deps': attr.label_list(", " aspects=[apple_common.objc_proto_aspect],", " ),", " },", " fragments = ['apple'],", ")");
scratch.file("x/BUILD", TestConstants.LOAD_PROTO_LIBRARY, "load('//objc_proto_library:objc_proto_library.bzl', 'objc_proto_library')", "proto_library(", " name = 'protos',", " srcs = ['data.proto'],", ")", "objc_proto_library(", " name = 'x',", " deps = [':protos'],", " portable_proto_filters = ['data_filter.pbascii'],", ")");
scratch.file("bin/BUILD", "load('//test_skylark:top_level_stub.bzl', 'top_level_stub')", "top_level_stub(", " name = 'link_target',", " deps = ['//x:x'],", ")");
ConfiguredTarget topTarget = getConfiguredTarget("//bin:link_target");
Provider.Key key = new SkylarkProvider.SkylarkKey(Label.parseAbsolute("//test_skylark:top_level_stub.bzl", ImmutableMap.of()), "MyInfo");
StructImpl info = (StructImpl) topTarget.get(key);
ConfiguredTarget depTarget = (ConfiguredTarget) info.getValue("dep");
ObjcProtoProvider objcProtoProvider = depTarget.get(ObjcProtoProvider.SKYLARK_CONSTRUCTOR);
replacedertThat(objcProtoProvider).isNotNull();
}
17
View Complete Implementation : BazelProtoInfoStarlarkTest.java
Copyright Apache License 2.0
Author : bazelbuild
Copyright Apache License 2.0
Author : bazelbuild
@Test
public void testProtoSourceRootExportedInStarlark() throws Exception {
scratch.file("third_party/foo/myTestRule.bzl", "load('//myinfo:myinfo.bzl', 'MyInfo')", "", "def _my_test_rule_impl(ctx):", " return MyInfo(", " fetched_proto_source_root = ctx.attr.protodep[ProtoInfo].proto_source_root", " )", "", "my_test_rule = rule(", " implementation = _my_test_rule_impl,", " attrs = {'protodep': attr.label()},", ")");
scratch.file("third_party/foo/BUILD", TestConstants.LOAD_PROTO_LIBRARY, "licenses(['unenreplacedbered'])", "load(':myTestRule.bzl', 'my_test_rule')", "my_test_rule(", " name = 'myRule',", " protodep = ':myProto',", ")", "proto_library(", " name = 'myProto',", " srcs = ['myProto.proto'],", " strip_import_prefix = '/third_party/foo',", ")");
ConfiguredTarget ct = getConfiguredTarget("//third_party/foo:myRule");
String protoSourceRoot = (String) getMyInfoFromTarget(ct).getValue("fetched_proto_source_root");
String genfiles = getTargetConfiguration().getGenfilesFragment().toString();
replacedertThat(protoSourceRoot).isEqualTo(genfiles + "/third_party/foo/_virtual_imports/myProto");
}
17
View Complete Implementation : BazelProtoInfoStarlarkTest.java
Copyright Apache License 2.0
Author : bazelbuild
Copyright Apache License 2.0
Author : bazelbuild
@Test
public void testProvider() throws Exception {
scratch.file("foo/test.bzl", "load('//myinfo:myinfo.bzl', 'MyInfo')", "def _impl(ctx):", // NB: This is the modern provider
" provider = ctx.attr.dep[ProtoInfo]", " return MyInfo(direct_sources=provider.direct_sources)", "test = rule(implementation = _impl, attrs = {'dep': attr.label()})");
scratch.file("foo/BUILD", TestConstants.LOAD_PROTO_LIBRARY, "load(':test.bzl', 'test')", "test(name='test', dep=':proto')", "proto_library(name='proto', srcs=['p.proto'])");
ConfiguredTarget test = getConfiguredTarget("//foo:test");
@SuppressWarnings("unchecked")
Iterable<Artifact> directSources = (Iterable<Artifact>) getMyInfoFromTarget(test).getValue("direct_sources");
replacedertThat(ActionsTestUtil.baseArtifactNames(directSources)).containsExactly("p.proto");
}
17
View Complete Implementation : BazelProtoLibraryTest.java
Copyright Apache License 2.0
Author : bazelbuild
Copyright Apache License 2.0
Author : bazelbuild
@Test
public void descriptorSets_ruleWithSrcsCallsProtoc() throws Exception {
scratch.file("x/BUILD", TestConstants.LOAD_PROTO_LIBRARY, "proto_library(name='foo', srcs=['foo.proto'])");
Artifact file = getDescriptorOutput("//x:foo");
replacedertThat(getGeneratingSpawnAction(file).getRemainingArguments()).containsAtLeast("-Ix/foo.proto=x/foo.proto", "--descriptor_set_out=" + file.getExecPathString(), "x/foo.proto");
}
17
View Complete Implementation : BazelProtoLibraryTest.java
Copyright Apache License 2.0
Author : bazelbuild
Copyright Apache License 2.0
Author : bazelbuild
@Test
public void descriptorSetsAreExposedInProvider() throws Exception {
scratch.file("x/BUILD", TestConstants.LOAD_PROTO_LIBRARY, "proto_library(name='alias', deps = ['foo'])", "proto_library(name='foo', srcs=['foo.proto'], deps = ['bar'])", "proto_library(name='bar', srcs=['bar.proto'])", "proto_library(name='alias_to_no_srcs', deps = ['no_srcs'])", "proto_library(name='no_srcs')");
{
ProtoInfo provider = getConfiguredTarget("//x:alias").get(ProtoInfo.PROVIDER);
replacedertThat(provider.getDirectDescriptorSet().getRootRelativePathString()).isEqualTo("x/alias-descriptor-set.proto.bin");
replacedertThat(prettyArtifactNames(provider.getTransitiveDescriptorSets())).containsExactly("x/alias-descriptor-set.proto.bin", "x/foo-descriptor-set.proto.bin", "x/bar-descriptor-set.proto.bin");
}
{
ProtoInfo provider = getConfiguredTarget("//x:foo").get(ProtoInfo.PROVIDER);
replacedertThat(provider.getDirectDescriptorSet().getRootRelativePathString()).isEqualTo("x/foo-descriptor-set.proto.bin");
replacedertThat(prettyArtifactNames(provider.getTransitiveDescriptorSets())).containsExactly("x/foo-descriptor-set.proto.bin", "x/bar-descriptor-set.proto.bin");
}
{
ProtoInfo provider = getConfiguredTarget("//x:bar").get(ProtoInfo.PROVIDER);
replacedertThat(provider.getDirectDescriptorSet().getRootRelativePathString()).isEqualTo("x/bar-descriptor-set.proto.bin");
replacedertThat(prettyArtifactNames(provider.getTransitiveDescriptorSets())).containsExactly("x/bar-descriptor-set.proto.bin");
}
{
ProtoInfo provider = getConfiguredTarget("//x:alias_to_no_srcs").get(ProtoInfo.PROVIDER);
replacedertThat(provider.getDirectDescriptorSet().getRootRelativePathString()).isEqualTo("x/alias_to_no_srcs-descriptor-set.proto.bin");
replacedertThat(prettyArtifactNames(provider.getTransitiveDescriptorSets())).containsExactly("x/alias_to_no_srcs-descriptor-set.proto.bin", "x/no_srcs-descriptor-set.proto.bin");
}
{
ProtoInfo provider = getConfiguredTarget("//x:no_srcs").get(ProtoInfo.PROVIDER);
replacedertThat(provider.getDirectDescriptorSet().getRootRelativePathString()).isEqualTo("x/no_srcs-descriptor-set.proto.bin");
replacedertThat(prettyArtifactNames(provider.getTransitiveDescriptorSets())).containsExactly("x/no_srcs-descriptor-set.proto.bin");
}
}
16
View Complete Implementation : AppleStaticLibraryTest.java
Copyright Apache License 2.0
Author : bazelbuild
Copyright Apache License 2.0
Author : bazelbuild
@Test
public void testProtoDeps() throws Exception {
MockObjcSupport.setupObjcProtoLibrary(scratch);
scratch.file("x/filter_a.pbascii");
scratch.file("x/filter_b.pbascii");
scratch.file("protos/BUILD", TestConstants.LOAD_PROTO_LIBRARY, "load('//objc_proto_library:objc_proto_library.bzl', 'objc_proto_library')", "proto_library(", " name = 'protos_main',", " srcs = ['data_a.proto', 'data_b.proto'],", ")", "proto_library(", " name = 'protos_low_level',", " srcs = ['data_b.proto'],", ")", "objc_proto_library(", " name = 'objc_protos_main',", " portable_proto_filters = ['filter_a.pbascii'],", " deps = [':protos_main'],", ")", "objc_proto_library(", " name = 'objc_protos_low_level',", " portable_proto_filters = ['filter_b.pbascii'],", " deps = [':protos_low_level'],", ")");
scratch.file("libs/BUILD", "objc_library(", " name = 'main_lib',", " srcs = ['a.m'],", " deps = ['//protos:objc_protos_main',]", ")", "objc_library(", " name = 'apple_low_level_lib',", " srcs = ['a.m'],", " deps = ['//protos:objc_protos_low_level',]", ")");
RULE_TYPE.scratchTarget(scratch, "deps", "['//libs:main_lib']", "avoid_deps", "['//libs:apple_low_level_lib']");
CommandAction linkAction = linkLibAction("//x:x");
Iterable<Artifact> linkActionInputs = linkAction.getInputs().toList();
ImmutableList.Builder<Artifact> objects = ImmutableList.builder();
for (Artifact binActionArtifact : linkActionInputs) {
if (binActionArtifact.getRootRelativePath().getPathString().endsWith(".a")) {
CommandAction subLinkAction = (CommandAction) getGeneratingAction(binActionArtifact);
for (Artifact linkActionArtifact : subLinkAction.getInputs().toList()) {
if (linkActionArtifact.getRootRelativePath().getPathString().endsWith(".o")) {
objects.add(linkActionArtifact);
}
}
}
}
ImmutableList<Artifact> objectFiles = objects.build();
replacedertThat(getFirstArtifactEndingWith(objectFiles, "DataA.pbobjc.o")).isNotNull();
replacedertThat(getFirstArtifactEndingWith(objectFiles, "DataB.pbobjc.o")).isNull();
}
16
View Complete Implementation : ObjcProtoAspectTest.java
Copyright Apache License 2.0
Author : bazelbuild
Copyright Apache License 2.0
Author : bazelbuild
@Test
public void testObjcProtoAspectPropagatesFiltersFromDependenciesOfObjcProtoLibrary() throws Exception {
MockObjcSupport.setupObjcProtoLibrary(scratch);
scratch.file("x/filter.pbascii");
scratch.file("x/BUILD", TestConstants.LOAD_PROTO_LIBRARY, "load('//objc_proto_library:objc_proto_library.bzl', 'objc_proto_library')", "objc_library(", " name = 'x',", " srcs = ['A.m'],", " deps = [", " ':objc_proto_all',", " ],", ")", "proto_library(", " name = 'protos',", " srcs = ['data.proto'],", ")", "objc_proto_library(", " name = 'objc_proto_all',", " deps = [':objc_proto_1', ':objc_proto_2'],", ")", "objc_proto_library(", " name = 'objc_proto_1',", " deps = [':protos'],", " portable_proto_filters = ['filter.pbascii'],", ")", "objc_proto_library(", " name = 'objc_proto_2',", " deps = [':protos'],", ")");
ConfiguredTarget topTarget = getObjcProtoAspectConfiguredTarget("//x:x");
ObjcProtoProvider objcProtoProvider = topTarget.get(ObjcProtoProvider.SKYLARK_CONSTRUCTOR);
replacedertThat(objcProtoProvider).isNotNull();
replacedertThat(Artifact.asExecPaths(objcProtoProvider.getPortableProtoFilters())).containsAtLeast("x/filter.pbascii", configurationGenfiles("x86_64", ConfigurationDistinguisher.APPLEBIN_IOS, null) + "/x/_proto_filters/objc_proto_2/generated_filter_file.pbascii");
}
16
View Complete Implementation : ObjcProtoAspectTest.java
Copyright Apache License 2.0
Author : bazelbuild
Copyright Apache License 2.0
Author : bazelbuild
@Test
public void testObjcProtoAspectBundlesDuplicateSymbols() throws Exception {
MockObjcSupport.setupObjcProtoLibrary(scratch);
scratch.file("x/data_filter.pbascii");
scratch.file("x/BUILD", TestConstants.LOAD_PROTO_LIBRARY, "load('//objc_proto_library:objc_proto_library.bzl', 'objc_proto_library')", "objc_library(", " name = 'x',", " srcs = ['A.m'],", " deps = [", " ':objc_proto',", " ':objc_proto_duplicate',", " ],", ")", "proto_library(", " name = 'protos',", " srcs = ['data.proto'],", ")", "objc_proto_library(", " name = 'objc_proto',", " deps = [':protos'],", " portable_proto_filters = ['data_filter.pbascii'],", ")", "objc_proto_library(", " name = 'objc_proto_duplicate',", " deps = [':protos'],", " portable_proto_filters = ['data_filter.pbascii'],", ")");
ConfiguredTarget topTarget = getObjcProtoAspectConfiguredTarget("//x:x");
ObjcProtoProvider objcProtoProvider = topTarget.get(ObjcProtoProvider.SKYLARK_CONSTRUCTOR);
replacedertThat(objcProtoProvider).isNotNull();
replacedertThat(Artifact.asExecPaths(Iterables.concat(objcProtoProvider.getProtoFiles().toList()))).containsExactly("x/data.proto");
replacedertThat(Artifact.asExecPaths(objcProtoProvider.getPortableProtoFilters())).containsExactly("x/data_filter.pbascii");
}
16
View Complete Implementation : ObjcProtoAspectTest.java
Copyright Apache License 2.0
Author : bazelbuild
Copyright Apache License 2.0
Author : bazelbuild
@Test
public void testObjcProtoAspectPropagatesGeneratedFilter() throws Exception {
MockObjcSupport.setupObjcProtoLibrary(scratch);
scratch.file("x/BUILD", TestConstants.LOAD_PROTO_LIBRARY, "load('//objc_proto_library:objc_proto_library.bzl', 'objc_proto_library')", "objc_library(", " name = 'x',", " srcs = ['A.m'],", " deps = [", " ':objc_proto',", " ],", ")", "proto_library(", " name = 'protos',", " srcs = ['data.proto'],", ")", "objc_proto_library(", " name = 'objc_proto',", " deps = [':protos'],", ")");
ConfiguredTarget topTarget = getObjcProtoAspectConfiguredTarget("//x:x");
ObjcProtoProvider objcProtoProvider = topTarget.get(ObjcProtoProvider.SKYLARK_CONSTRUCTOR);
replacedertThat(objcProtoProvider).isNotNull();
replacedertThat(Artifact.asExecPaths(objcProtoProvider.getPortableProtoFilters())).containsExactly(configurationGenfiles("x86_64", ConfigurationDistinguisher.APPLEBIN_IOS, null) + "/x/_proto_filters/objc_proto/generated_filter_file.pbascii");
}
16
View Complete Implementation : BazelProtoLibraryTest.java
Copyright Apache License 2.0
Author : bazelbuild
Copyright Apache License 2.0
Author : bazelbuild
@Test
public void testStripImportPrefixWithDeps() throws Exception {
scratch.file("third_party/x/foo/BUILD", TestConstants.LOAD_PROTO_LIBRARY, "licenses(['unenreplacedbered'])", "proto_library(", " name = 'withdeps',", " srcs = ['foo/withdeps.proto'],", " strip_import_prefix = '/third_party/x/foo',", " deps = ['//third_party/x/bar:dep', ':dep'],", ")", "proto_library(", " name = 'dep',", " srcs = ['foo/dep.proto'],", ")");
scratch.file("third_party/x/bar/BUILD", TestConstants.LOAD_PROTO_LIBRARY, "licenses(['unenreplacedbered'])", "proto_library(", " name = 'dep',", " srcs = ['foo/dep.proto'],", " strip_import_prefix = '/third_party/x/bar',", ")");
ConfiguredTarget protoTarget = getConfiguredTarget("//third_party/x/foo:withdeps");
ProtoInfo sourcesProvider = protoTarget.get(ProtoInfo.PROVIDER);
String genfiles = getTargetConfiguration().getGenfilesFragment().toString();
replacedertThat(sourcesProvider.getTransitiveProtoSourceRoots().toList()).containsExactly(genfiles + "/third_party/x/foo/_virtual_imports/withdeps", genfiles + "/third_party/x/bar/_virtual_imports/dep", ".");
}
16
View Complete Implementation : BazelProtoLibraryTest.java
Copyright Apache License 2.0
Author : bazelbuild
Copyright Apache License 2.0
Author : bazelbuild
@Test
public void testExternalRepoWithGeneratedProto() throws Exception {
if (!isThisBazel()) {
return;
}
FileSystemUtils.appendIsoLatin1(scratch.resolve("WORKSPACE"), "local_repository(name = 'foo', path = '/foo')");
invalidatePackages();
scratch.file("/foo/WORKSPACE");
scratch.file("/foo/x/BUILD", TestConstants.LOAD_PROTO_LIBRARY, "proto_library(name='x', srcs=['generated.proto'])", "genrule(name='g', srcs=[], outs=['generated.proto'], cmd='')");
scratch.file("a/BUILD", TestConstants.LOAD_PROTO_LIBRARY, "proto_library(name='a', srcs=['a.proto'], deps=['@foo//x:x'])");
String genfiles = getTargetConfiguration().getGenfilesFragment().toString();
ConfiguredTarget a = getConfiguredTarget("//a:a");
ProtoInfo aInfo = a.get(ProtoInfo.PROVIDER);
replacedertThat(aInfo.getTransitiveProtoSourceRoots().toList()).containsExactly(".", genfiles + "/external/foo/x/_virtual_imports/x");
ConfiguredTarget x = getConfiguredTarget("@foo//x:x");
ProtoInfo xInfo = x.get(ProtoInfo.PROVIDER);
replacedertThat(xInfo.getTransitiveProtoSourceRoots().toList()).containsExactly(genfiles + "/external/foo/x/_virtual_imports/x");
}
16
View Complete Implementation : BazelProtoLibraryTest.java
Copyright Apache License 2.0
Author : bazelbuild
Copyright Apache License 2.0
Author : bazelbuild
@Test
public void testStripImportPrefixWithDepsDuplicate() throws Exception {
scratch.file("third_party/x/foo/BUILD", TestConstants.LOAD_PROTO_LIBRARY, "licenses(['unenreplacedbered'])", "proto_library(", " name = 'withdeps',", " srcs = ['foo/withdeps.proto'],", " strip_import_prefix = '/third_party/x/foo',", " deps = [':dep'],", ")", "proto_library(", " name = 'dep',", " srcs = ['foo/dep.proto'],", " strip_import_prefix = '/third_party/x/foo',", ")");
ConfiguredTarget protoTarget = getConfiguredTarget("//third_party/x/foo:withdeps");
ProtoInfo sourcesProvider = protoTarget.get(ProtoInfo.PROVIDER);
String genfiles = getTargetConfiguration().getGenfilesFragment().toString();
replacedertThat(sourcesProvider.getTransitiveProtoSourceRoots().toList()).containsExactly(genfiles + "/third_party/x/foo/_virtual_imports/dep", genfiles + "/third_party/x/foo/_virtual_imports/withdeps");
replacedertThat(getGeneratingSpawnAction(getDescriptorOutput("//third_party/x/foo:withdeps")).getRemainingArguments()).containsAtLeast("--proto_path=" + genfiles + "/third_party/x/foo/_virtual_imports/withdeps", "--proto_path=" + genfiles + "/third_party/x/foo/_virtual_imports/dep");
}
16
View Complete Implementation : BazelProtoLibraryTest.java
Copyright Apache License 2.0
Author : bazelbuild
Copyright Apache License 2.0
Author : bazelbuild
@Test
public void testStripImportPrefixWithoutDeps() throws Exception {
scratch.file("third_party/x/foo/BUILD", TestConstants.LOAD_PROTO_LIBRARY, "licenses(['unenreplacedbered'])", "proto_library(", " name = 'nodeps',", " srcs = ['foo/nodeps.proto'],", " strip_import_prefix = '/third_party/x/foo',", ")");
ConfiguredTarget protoTarget = getConfiguredTarget("//third_party/x/foo:nodeps");
ProtoInfo sourcesProvider = protoTarget.get(ProtoInfo.PROVIDER);
String genfiles = getTargetConfiguration().getGenfilesFragment().toString();
replacedertThat(sourcesProvider.getTransitiveProtoSourceRoots().toList()).containsExactly(genfiles + "/third_party/x/foo/_virtual_imports/nodeps");
replacedertThat(getGeneratingSpawnAction(getDescriptorOutput("//third_party/x/foo:nodeps")).getRemainingArguments()).contains("--proto_path=" + genfiles + "/third_party/x/foo/_virtual_imports/nodeps");
}