diff options
Diffstat (limited to 'tools/rbcrun/host_test.go')
-rw-r--r-- | tools/rbcrun/host_test.go | 34 |
1 files changed, 8 insertions, 26 deletions
diff --git a/tools/rbcrun/host_test.go b/tools/rbcrun/host_test.go index 97f6ce9e93..e109c02c54 100644 --- a/tools/rbcrun/host_test.go +++ b/tools/rbcrun/host_test.go @@ -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") } |