-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Include module file globals in
builtin.proto
This allows consumers of the proto to learn about globals only available in `MODULE.bazel` under a new `ApiContext`. Also adds a smoke test to verify that common symbols are contained in the proto for each API context.
- Loading branch information
Showing
6 changed files
with
93 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
src/test/java/com/google/devtools/build/lib/BuiltinProtoSmokeTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package com.google.devtools.build.lib; | ||
|
||
import static com.google.common.truth.Truth.assertThat; | ||
import static java.util.stream.Collectors.toMap; | ||
|
||
import com.google.devtools.build.docgen.builtin.BuiltinProtos; | ||
import com.google.devtools.build.runfiles.Runfiles; | ||
import java.io.BufferedInputStream; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import org.junit.BeforeClass; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.junit.runners.JUnit4; | ||
|
||
@RunWith(JUnit4.class) | ||
public final class BuiltinProtoSmokeTest { | ||
static BuiltinProtos.Builtins builtins; | ||
|
||
@BeforeClass | ||
public static void loadProto() throws IOException { | ||
Path protoPath = | ||
Path.of(Runfiles.preload().unmapped().rlocation(System.getenv("BUILTIN_PROTO"))); | ||
try (InputStream inputStream = Files.newInputStream(protoPath); | ||
BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream)) { | ||
builtins = BuiltinProtos.Builtins.parseFrom(bufferedInputStream); | ||
} | ||
} | ||
|
||
@Test | ||
public void hasGlobalCallableFromEachApiContext() { | ||
assertThat( | ||
builtins.getGlobalList().stream() | ||
.filter(BuiltinProtos.Value::hasCallable) | ||
.filter(global -> !global.getCallable().getParamList().isEmpty()) | ||
.collect(toMap(BuiltinProtos.Value::getName, BuiltinProtos.Value::getApiContext))) | ||
.containsAtLeast( | ||
"range", BuiltinProtos.ApiContext.ALL, | ||
"glob", BuiltinProtos.ApiContext.BUILD, | ||
"DefaultInfo", BuiltinProtos.ApiContext.BZL, | ||
"bazel_dep", BuiltinProtos.ApiContext.MODULE); | ||
} | ||
} |