use of com.google.devtools.build.lib.packages.Package in project bazel by bazelbuild.
the class PackageFactoryApparatus method evalAndReturnGlobCache.
/**
* Evaluates the {@code buildFileAST} into a {@link Package}.
*/
public Pair<Package, GlobCache> evalAndReturnGlobCache(String packageName, Path buildFile, BuildFileAST buildFileAST) throws InterruptedException {
PackageIdentifier packageId = PackageIdentifier.createInMainRepo(packageName);
GlobCache globCache = new GlobCache(buildFile.getParentDirectory(), packageId, getPackageLocator(), null, TestUtils.getPool(), -1);
LegacyGlobber globber = PackageFactory.createLegacyGlobber(globCache);
Package externalPkg = factory.newExternalPackageBuilder(buildFile.getParentDirectory().getRelative("WORKSPACE"), "TESTING").build();
Builder resultBuilder = factory.evaluateBuildFile(externalPkg.getWorkspaceName(), packageId, buildFileAST, buildFile, globber, ImmutableList.<Event>of(), ConstantRuleVisibility.PUBLIC, false, new MakeEnvironment.Builder(), ImmutableMap.<String, Extension>of(), ImmutableList.<Label>of());
Package result = resultBuilder.build();
Event.replayEventsOn(eventHandler, result.getEvents());
return Pair.of(result, globCache);
}
use of com.google.devtools.build.lib.packages.Package in project bazel by bazelbuild.
the class PackageFactoryTestBase method assertGlobProducesError.
protected void assertGlobProducesError(String pattern, boolean errorExpected) throws Exception {
events.setFailFast(false);
Package pkg = evaluateGlob(ImmutableList.of(pattern), Collections.<String>emptyList(), false, "").first;
assertEquals(errorExpected, pkg.containsErrors());
boolean foundError = false;
for (Event event : events.collector()) {
if (event.getMessage().contains("glob")) {
if (!errorExpected) {
fail("error not expected for glob pattern " + pattern + ", but got: " + event);
return;
}
foundError = errorExpected;
break;
}
}
assertEquals(errorExpected, foundError);
}
use of com.google.devtools.build.lib.packages.Package in project bazel by bazelbuild.
the class PackageFactoryTestBase method expectEvalError.
protected void expectEvalError(String expectedError, String... content) throws Exception {
events.setFailFast(false);
Path file = scratch.file("/pkg/BUILD", content);
Package pkg = packages.eval("pkg", file);
assertTrue("Expected evaluation error, but none was not reported", pkg.containsErrors());
events.assertContainsError(expectedError);
}
use of com.google.devtools.build.lib.packages.Package in project bazel by bazelbuild.
the class PackageFactoryTestBase method isValidPackageName.
protected boolean isValidPackageName(String packageName) throws Exception {
// Write a license decl just in case it's a third_party package:
Path buildFile = scratch.file(getPathPrefix() + "/" + packageName + "/BUILD", "licenses(['notice'])");
Package pkg = packages.createPackage(packageName, buildFile);
return !pkg.containsErrors();
}
use of com.google.devtools.build.lib.packages.Package in project bazel by bazelbuild.
the class PackageFactoryTestBase method assertGlobFails.
/********************************************************************
* *
* Test "glob" function in build language *
* *
********************************************************************/
protected void assertGlobFails(String globCallExpression, String expectedError) throws Exception {
Package pkg = buildPackageWithGlob(globCallExpression);
events.assertContainsError(expectedError);
assertTrue(pkg.containsErrors());
}
Aggregations