summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Cole Faust <colefaust@google.com> 2023-11-13 11:21:08 -0800
committer Cole Faust <colefaust@google.com> 2023-11-13 11:47:30 -0800
commit630923441169426dab849716d30a6d397055bf04 (patch)
tree8deac7c04302b457b87578bb6bd341915910340f
parent001ed67bbac650ed9baecec1fa4b0945f4fc9184 (diff)
Require scl files in ExecutionModeScl
Also remove json from scl file builtins, as it's not in bazel. Bug: 309686282 Test: Presubmits Change-Id: I6227c5dc14922b4682380254b4716b4ae38c47b9
-rw-r--r--tools/rbcrun/host.go6
-rw-r--r--tools/rbcrun/host_test.go4
2 files changed, 6 insertions, 4 deletions
diff --git a/tools/rbcrun/host.go b/tools/rbcrun/host.go
index f36553e746..8cd2845fae 100644
--- a/tools/rbcrun/host.go
+++ b/tools/rbcrun/host.go
@@ -24,7 +24,6 @@ import (
"strings"
"go.starlark.net/starlark"
- "go.starlark.net/starlarkjson"
"go.starlark.net/starlarkstruct"
)
@@ -60,7 +59,6 @@ var rbcBuiltins starlark.StringDict = starlark.StringDict{
var sclBuiltins starlark.StringDict = starlark.StringDict{
"struct": starlark.NewBuiltin("struct", starlarkstruct.Make),
- "json": starlarkjson.Module,
}
func isSymlink(filepath string) (bool, error) {
@@ -389,6 +387,10 @@ func Run(filename string, src interface{}, mode ExecutionMode, allowExternalEntr
return nil, nil, err
}
+ if mode == ExecutionModeScl && !strings.HasSuffix(filename, ".scl") {
+ return nil, nil, fmt.Errorf("filename must end in .scl: %s", filename)
+ }
+
// Add top-level file to cache for cycle detection purposes
moduleCache[filename] = nil
diff --git a/tools/rbcrun/host_test.go b/tools/rbcrun/host_test.go
index 7cfeb14463..38b292376a 100644
--- a/tools/rbcrun/host_test.go
+++ b/tools/rbcrun/host_test.go
@@ -143,7 +143,7 @@ func TestBzlLoadsScl(t *testing.T) {
if err := os.Chdir(filepath.Dir(dir)); err != nil {
t.Fatal(err)
}
- vars, _, err := Run("testdata/bzl_loads_scl.bzl", nil, ExecutionModeScl, false)
+ vars, _, err := Run("testdata/bzl_loads_scl.bzl", nil, ExecutionModeRbc, false)
if err != nil {
t.Fatal(err)
}
@@ -160,7 +160,7 @@ func TestNonEntrypointBzlLoadsScl(t *testing.T) {
if err := os.Chdir(filepath.Dir(dir)); err != nil {
t.Fatal(err)
}
- vars, _, err := Run("testdata/bzl_loads_scl_2.bzl", nil, ExecutionModeScl, false)
+ vars, _, err := Run("testdata/bzl_loads_scl_2.bzl", nil, ExecutionModeRbc, false)
if err != nil {
t.Fatal(err)
}