Merge "v.io/jiri/profiles: transition and fix profile list command to new profiles.."
diff --git a/cmd/jiri/bootstrap_jiri_test.go b/cmd/jiri/bootstrap_jiri_test.go
index c0300ac..ebab84a 100644
--- a/cmd/jiri/bootstrap_jiri_test.go
+++ b/cmd/jiri/bootstrap_jiri_test.go
@@ -17,7 +17,8 @@
)
func TestBootstrapJiri(t *testing.T) {
- sh := gosh.NewShell(gosh.Opts{Fatalf: t.Fatalf, Logf: t.Logf, PropagateChildOutput: true})
+ sh := gosh.NewShell(t)
+ sh.PropagateChildOutput = true
defer sh.Cleanup()
bootstrap, err := filepath.Abs("./scripts/bootstrap_jiri")
@@ -43,7 +44,8 @@
// TestBuildJiriLocally checks that the jiri binary built in the bootstrap
// script can be built locally.
func TestBuildJiriLocally(t *testing.T) {
- sh := gosh.NewShell(gosh.Opts{Fatalf: t.Fatalf, Logf: t.Logf, PropagateChildOutput: true})
+ sh := gosh.NewShell(t)
+ sh.PropagateChildOutput = true
defer sh.Cleanup()
// Extract jiri package path from this line.
@@ -66,7 +68,8 @@
}
func TestBootstrapJiriAlreadyExists(t *testing.T) {
- sh := gosh.NewShell(gosh.Opts{Fatalf: t.Fatalf, Logf: t.Logf, PropagateChildOutput: true})
+ sh := gosh.NewShell(t)
+ sh.PropagateChildOutput = true
defer sh.Cleanup()
bootstrap, err := filepath.Abs("./scripts/bootstrap_jiri")
diff --git a/cmd/jiri/import_test.go b/cmd/jiri/import_test.go
index 2410fd4..5e9c6d7 100644
--- a/cmd/jiri/import_test.go
+++ b/cmd/jiri/import_test.go
@@ -135,19 +135,18 @@
`,
},
}
- opts := gosh.Opts{Fatalf: t.Fatalf, Logf: t.Logf}
- sh := gosh.NewShell(opts)
+ sh := gosh.NewShell(t)
defer sh.Cleanup()
jiriTool := gosh.BuildGoPkg(sh, sh.MakeTempDir(), "v.io/jiri/cmd/jiri")
for _, test := range tests {
- if err := testImport(opts, jiriTool, test); err != nil {
+ if err := testImport(t, jiriTool, test); err != nil {
t.Errorf("%v: %v", test.Args, err)
}
}
}
-func testImport(opts gosh.Opts, jiriTool string, test importTestCase) error {
- sh := gosh.NewShell(opts)
+func testImport(t *testing.T, jiriTool string, test importTestCase) error {
+ sh := gosh.NewShell(t)
defer sh.Cleanup()
tmpDir := sh.MakeTempDir()
jiriRoot := filepath.Join(tmpDir, "root")
diff --git a/cmd/jiri/upgrade_test.go b/cmd/jiri/upgrade_test.go
index 7aae9c5..8803792 100644
--- a/cmd/jiri/upgrade_test.go
+++ b/cmd/jiri/upgrade_test.go
@@ -198,20 +198,19 @@
`,
},
}
- opts := gosh.Opts{Fatalf: t.Fatalf, Logf: t.Logf}
- sh := gosh.NewShell(opts)
+ sh := gosh.NewShell(t)
defer sh.Cleanup()
jiriTool := gosh.BuildGoPkg(sh, sh.MakeTempDir(), "v.io/jiri/cmd/jiri")
for _, test := range tests {
- if err := testUpgrade(opts, jiriTool, test); err != nil {
+ if err := testUpgrade(t, jiriTool, test); err != nil {
t.Errorf("%v: %v", test.Args, err)
}
}
}
-func testUpgrade(opts gosh.Opts, jiriTool string, test upgradeTestCase) error {
- opts.PropagateChildOutput = true
- sh := gosh.NewShell(opts)
+func testUpgrade(t *testing.T, jiriTool string, test upgradeTestCase) error {
+ sh := gosh.NewShell(t)
+ sh.PropagateChildOutput = true
defer sh.Cleanup()
jiriRoot := sh.MakeTempDir()
sh.Pushd(jiriRoot)
@@ -260,7 +259,7 @@
}
func TestUpgradeRevert(t *testing.T) {
- sh := gosh.NewShell(gosh.Opts{Fatalf: t.Fatalf, Logf: t.Logf})
+ sh := gosh.NewShell(t)
defer sh.Cleanup()
jiriRoot := sh.MakeTempDir()
sh.Pushd(jiriRoot)
diff --git a/cmd/jiri/which_test.go b/cmd/jiri/which_test.go
index 1e2fe4b..c329ea7 100644
--- a/cmd/jiri/which_test.go
+++ b/cmd/jiri/which_test.go
@@ -13,7 +13,8 @@
)
func TestWhich(t *testing.T) {
- sh := gosh.NewShell(gosh.Opts{Fatalf: t.Fatalf, Logf: t.Logf, PropagateChildOutput: true})
+ sh := gosh.NewShell(t)
+ sh.PropagateChildOutput = true
defer sh.Cleanup()
jiriBinary := gosh.BuildGoPkg(sh, sh.MakeTempDir(), "v.io/jiri/cmd/jiri")
@@ -28,7 +29,8 @@
// TestWhichScript tests the behavior of "jiri which" for the shim script.
func TestWhichScript(t *testing.T) {
- sh := gosh.NewShell(gosh.Opts{Fatalf: t.Fatalf, Logf: t.Logf, PropagateChildOutput: true})
+ sh := gosh.NewShell(t)
+ sh.PropagateChildOutput = true
defer sh.Cleanup()
jiriScript, err := filepath.Abs("./scripts/jiri")
diff --git a/profiles/profilescmdline/manager_test.go b/profiles/profilescmdline/manager_test.go
index 5e8e579..0409849 100644
--- a/profiles/profilescmdline/manager_test.go
+++ b/profiles/profilescmdline/manager_test.go
@@ -62,16 +62,6 @@
buildInstallersBinDir, buildJiriBinDir = "", ""
)
-func newShell(t *testing.T) *gosh.Shell {
- fatalf := func(format string, args ...interface{}) {
- _, file, line, _ := runtime.Caller(3)
- loc := fmt.Sprintf("%s:%d: ", filepath.Base(file), line)
- fmt.Fprintf(os.Stderr, loc+format+"\n", args...)
- t.FailNow()
- }
- return gosh.NewShell(gosh.Opts{Fatalf: fatalf, Logf: t.Logf})
-}
-
// TODO(sadovsky): This code leaves a lot of temp dirs behind. It would be nice
// to restructure things so that all temporary artifacts get cleaned up.
func buildInstallers(t *testing.T) string {
@@ -80,7 +70,7 @@
if err != nil {
t.Fatal(err)
}
- sh := newShell(t)
+ sh := gosh.NewShell(t)
defer sh.Cleanup()
prefix := "v.io/jiri/profiles/profilescmdline/internal/"
gosh.BuildGoPkg(sh, binDir, "v.io/jiri/cmd/jiri", "-o", "jiri")
@@ -97,7 +87,7 @@
if err != nil {
t.Fatal(err)
}
- sh := newShell(t)
+ sh := gosh.NewShell(t)
defer sh.Cleanup()
gosh.BuildGoPkg(sh, binDir, "v.io/jiri/cmd/jiri", "-o", "jiri")
buildJiriBinDir = binDir
@@ -116,7 +106,7 @@
func TestManagerAvailable(t *testing.T) {
fake, cleanup := jiritest.NewFakeJiriRoot(t)
defer cleanup()
- dir, sh := buildInstallers(t), newShell(t)
+ dir, sh := buildInstallers(t), gosh.NewShell(t)
sh.Vars["JIRI_ROOT"] = fake.X.Root
sh.Vars["PATH"] = envvar.PrependUsingSeparator(dir, os.Getenv("PATH"), ":")
stdout := run(sh, dir, "jiri", "profile", "available", "-v")
@@ -193,7 +183,7 @@
func TestManagerInstallUninstall(t *testing.T) {
fake, cleanup := jiritest.NewFakeJiriRoot(t)
defer cleanup()
- dir, sh := buildInstallers(t), newShell(t)
+ dir, sh := buildInstallers(t), gosh.NewShell(t)
sh.Vars["JIRI_ROOT"] = fake.X.Root
sh.Vars["PATH"] = envvar.PrependUsingSeparator(dir, os.Getenv("PATH"), ":")
@@ -246,7 +236,7 @@
func TestManagerUpdate(t *testing.T) {
fake, cleanup := jiritest.NewFakeJiriRoot(t)
defer cleanup()
- dir, sh := buildInstallers(t), newShell(t)
+ dir, sh := buildInstallers(t), gosh.NewShell(t)
sh.Vars["JIRI_ROOT"] = fake.X.Root
sh.Vars["PATH"] = dir
@@ -294,7 +284,7 @@
t.Errorf("got %v, want %v", got, want)
}
- dir, sh := buildJiri(t), newShell(t)
+ dir, sh := buildJiri(t), gosh.NewShell(t)
sh.Vars["JIRI_ROOT"] = fake.X.Root
sh.Vars["PATH"] = envvar.PrependUsingSeparator(dir, os.Getenv("PATH"), ":")
run(sh, dir, "jiri", "profile", "list", "-v")