Remove unneeded rbcrun features
- rblf_cli and rblf_env - -c and -f This is in preparation for making rbcrun able to function as a more general purpose starlark interpreter. Bug: 280685526 Test: go test, ./out/rbc ./build/make/tests/run.rbc, ./build/bazel/ci/rbc_dashboard.py --quick aosp_arm64 Change-Id: Ifff9ce7b4369422f39c5003bb85a168c78bde7cf
This commit is contained in:
@@ -53,8 +53,8 @@ func starlarktestSetup() {
|
||||
}
|
||||
|
||||
// Common setup for the tests: create thread, change to the test directory
|
||||
func testSetup(t *testing.T, env []string) *starlark.Thread {
|
||||
setup(env)
|
||||
func testSetup(t *testing.T) *starlark.Thread {
|
||||
setup()
|
||||
thread := &starlark.Thread{
|
||||
Load: func(thread *starlark.Thread, module string) (starlark.StringDict, error) {
|
||||
if module == "assert.star" {
|
||||
@@ -72,14 +72,16 @@ func testSetup(t *testing.T, env []string) *starlark.Thread {
|
||||
func dataDir() string {
|
||||
_, thisSrcFile, _, _ := runtime.Caller(0)
|
||||
return filepath.Join(filepath.Dir(thisSrcFile), "testdata")
|
||||
|
||||
}
|
||||
|
||||
func exerciseStarlarkTestFile(t *testing.T, starFile string) {
|
||||
// In order to use "assert.star" from go/starlark.net/starlarktest in the tests, provide:
|
||||
// * load function that handles "assert.star"
|
||||
// * starlarktest.DataFile function that finds its location
|
||||
setup(nil)
|
||||
setup()
|
||||
if err := os.Chdir(dataDir()); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
thread := &starlark.Thread{
|
||||
Load: func(thread *starlark.Thread, module string) (starlark.StringDict, error) {
|
||||
if module == "assert.star" {
|
||||
@@ -98,26 +100,9 @@ func exerciseStarlarkTestFile(t *testing.T, starFile string) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestCliAndEnv(t *testing.T) {
|
||||
// TODO(asmundak): convert this to use exerciseStarlarkTestFile
|
||||
if err := os.Setenv("TEST_ENVIRONMENT_FOO", "test_environment_foo"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
thread := testSetup(t, []string{"CLI_FOO=foo"})
|
||||
if _, err := starlark.ExecFile(thread, "cli_and_env.star", nil, builtins); err != nil {
|
||||
if err, ok := err.(*starlark.EvalError); ok {
|
||||
t.Fatal(err.Backtrace())
|
||||
}
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFileOps(t *testing.T) {
|
||||
// TODO(asmundak): convert this to use exerciseStarlarkTestFile
|
||||
if err := os.Setenv("TEST_DATA_DIR", dataDir()); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
thread := testSetup(t, nil)
|
||||
thread := testSetup(t)
|
||||
if _, err := starlark.ExecFile(thread, "file_ops.star", nil, builtins); err != nil {
|
||||
if err, ok := err.(*starlark.EvalError); ok {
|
||||
t.Fatal(err.Backtrace())
|
||||
@@ -128,7 +113,7 @@ func TestFileOps(t *testing.T) {
|
||||
|
||||
func TestLoad(t *testing.T) {
|
||||
// TODO(asmundak): convert this to use exerciseStarlarkTestFile
|
||||
thread := testSetup(t, nil)
|
||||
thread := testSetup(t)
|
||||
thread.Load = func(thread *starlark.Thread, module string) (starlark.StringDict, error) {
|
||||
if module == "assert.star" {
|
||||
return starlarktest.LoadAssertModule()
|
||||
@@ -148,8 +133,5 @@ func TestLoad(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestShell(t *testing.T) {
|
||||
if err := os.Setenv("TEST_DATA_DIR", dataDir()); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
exerciseStarlarkTestFile(t, "testdata/shell.star")
|
||||
}
|
||||
|
Reference in New Issue
Block a user