Skip to content

Commit

Permalink
Add various integration tests for .scl
Browse files Browse the repository at this point in the history
- add buildfiles() test for .scl to AbstractQueryTest, disabling it (as per precedent) for subclass PostAnalysisQueryTest which doesn't support this operator
- add loadfiles() test for .scl to QueryTest. Seems strange that this is in a different place than buildfiles(), but I'm just following precedent.
- rename the below test case in QueryTest which looks like it was misnamed when created
- override scl flag to true in SkyframeQueryHelper for testing purposes

PiperOrigin-RevId: 566306847
Change-Id: Iaa3a345634e2c93f8d54cbd00e7ca087b10ef332
  • Loading branch information
brandjon authored and copybara-github committed Sep 18, 2023
1 parent 8cd6c43 commit 065f09d
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,31 @@ protected void writeBuildFiles3() throws Exception {
writeFile("d/BUILD", "exports_files(['d'])");
}

/**
* Setup a BUILD file that loads two .scl files, one directly and the other through a .bzl file.
*/
protected void writeBzlAndSclFiles() throws Exception {
writeFile(
"foo/BUILD", //
"load('//bar:direct.scl', 'x')",
"load('//bar:intermediate.bzl', 'y')",
"sh_library(",
" name = 'foo',",
" tags = [x, y],",
")");
writeFile("bar/BUILD");
writeFile(
"bar/direct.scl", //
"x = 'X'");
writeFile(
"bar/intermediate.bzl", //
"load(':indirect.scl', _y='y')",
"y = _y");
writeFile(
"bar/indirect.scl", //
"y = 'Y'");
}

protected void writeBuildFilesWithConfigurableAttributesUnconditionally() throws Exception {
writeFile(
"conditions/BUILD",
Expand Down Expand Up @@ -1867,6 +1892,15 @@ public void bzlPackageBadDueToBrokenSyntax() throws Exception {
.containsExactly("//foo:BUILD", "//bar:bar.bzl", "//bar:BUILD");
}

@Test
public void testBuildfilesContainingScl() throws Exception {
writeBzlAndSclFiles();

assertThat(evalToString("buildfiles(deps(//foo))"))
.isEqualTo(
"//bar:BUILD //bar:direct.scl //bar:indirect.scl //bar:intermediate.bzl //foo:BUILD");
}

@Test
public void badRuleInDeps() throws Exception {
runBadRuleInDeps(Code.STARLARK_EVAL_ERROR);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -834,6 +834,9 @@ public void bzlPackageBadDueToBrokenLoad() {}
@Override
public void bzlPackageBadDueToBrokenSyntax() {}

@Override
public void testBuildfilesContainingScl() {}

@Override
public void buildfilesBazel() {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,15 @@ public void testLoadfiles_starlarkDep() throws Exception {
}

@Test
public void testLoadfiles_labelKeyedStringDictDeps() throws Exception {
public void testLoadfiles_sclDep() throws Exception {
writeBzlAndSclFiles();

assertThat(targetLabels(eval("loadfiles(//foo:BUILD)")))
.containsExactly("//bar:direct.scl", "//bar:indirect.scl", "//bar:intermediate.bzl");
}

@Test
public void testDeps_labelKeyedStringDictDeps() throws Exception {
writeFile(
"test//starlark/rule.bzl",
"def _impl(ctx):",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,8 @@ protected void initTargetPatternEvaluator(ConfiguredRuleClassProvider ruleClassP

BuildLanguageOptions buildLanguageOptions = Options.getDefaults(BuildLanguageOptions.class);
buildLanguageOptions.enableBzlmod = enableBzlmod();
// TODO(b/256127926): Delete once flipped.
buildLanguageOptions.experimentalEnableSclDialect = true;

PathPackageLocator packageLocator =
skyframeExecutor.createPackageLocator(
Expand Down

0 comments on commit 065f09d

Please sign in to comment.