Skip to content
This repository has been archived by the owner on Nov 18, 2021. It is now read-only.

Commit

Permalink
cmd/cue: use gotooltest within testscript tests
Browse files Browse the repository at this point in the history
This obviates the need for any per-script setup of HOME, USERPROFILE and
LOCALAPPDATA, whilst also making the command "go" available natively
within a script.

In preparation for later cue get go changes/fixes.

Change-Id: I03d396c8d381f2f67bb15a348cbec464042af611
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/8290
Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
Reviewed-by: CUE cueckoo <cueckoo@gmail.com>
  • Loading branch information
myitcv committed Jan 29, 2021
1 parent ef59f61 commit 37c16cc
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
9 changes: 7 additions & 2 deletions cmd/cue/cmd/script_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"strings"
"testing"

"github.com/rogpeppe/go-internal/gotooltest"
"github.com/rogpeppe/go-internal/testscript"
"github.com/rogpeppe/go-internal/txtar"

Expand Down Expand Up @@ -71,10 +72,14 @@ func TestLatest(t *testing.T) {
}

func TestScript(t *testing.T) {
testscript.Run(t, testscript.Params{
p := testscript.Params{
Dir: "testdata/script",
UpdateScripts: *update,
})
}
if err := gotooltest.Setup(&p); err != nil {
t.Fatal(err)
}
testscript.Run(t, p)
}

// TestScriptDebug takes a single testscript file and then runs it within the
Expand Down
5 changes: 0 additions & 5 deletions cmd/cue/cmd/testdata/script/get_go_basic.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
# Test that a basic get go works using golden files to verify output

# Set HOME for go-build cache to be valid
env HOME=$WORK${/}home
env USERPROFILE=$HOME
env LOCALAPPDATA=$WORK${/}appdata

# All the things
cue get go --local
cmp blah_go_gen.cue all.cue.golden
Expand Down
6 changes: 6 additions & 0 deletions cmd/cue/cmd/testdata/script/go_cmd.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Basic sanity check that go command works as expected
# within testscript tests

go version
stdout '^go version'

0 comments on commit 37c16cc

Please sign in to comment.