aboutsummaryrefslogtreecommitdiffstats
path: root/_examples/common_test.go
diff options
context:
space:
mode:
authorDavid Pordomingo <David.Pordomingo.F@gmail.com>2019-03-25 19:48:19 +0100
committerDavid Pordomingo <David.Pordomingo.F@gmail.com>2019-06-03 20:58:26 +0200
commit66c4a36212ced976c33712ca4fb6abc6697f2654 (patch)
treeb65d063fc01b32497c57d0b23f4082a5b2235bf2 /_examples/common_test.go
parent37b80726760d2e0b17dfa437f3162dd930590ecf (diff)
downloadgo-git-66c4a36212ced976c33712ca4fb6abc6697f2654.tar.gz
Add merge-base command
Signed-off-by: David Pordomingo <David.Pordomingo.F@gmail.com>
Diffstat (limited to '_examples/common_test.go')
-rw-r--r--_examples/common_test.go13
1 files changed, 7 insertions, 6 deletions
diff --git a/_examples/common_test.go b/_examples/common_test.go
index 47463a1..89d49a3 100644
--- a/_examples/common_test.go
+++ b/_examples/common_test.go
@@ -29,6 +29,7 @@ var args = map[string][]string{
"tag": {cloneRepository(defaultURL, tempFolder())},
"pull": {createRepositoryWithRemote(tempFolder(), defaultURL)},
"ls": {cloneRepository(defaultURL, tempFolder()), "HEAD", "vendor"},
+ "merge_base": {cloneRepository(defaultURL, tempFolder()), "--is-ancestor", "HEAD~3", "HEAD^"},
}
var ignored = map[string]bool{}
@@ -50,14 +51,15 @@ func TestExamples(t *testing.T) {
}
for _, example := range examples {
- _, name := filepath.Split(filepath.Dir(example))
+ dir := filepath.Dir(example)
+ _, name := filepath.Split(dir)
if ignored[name] {
continue
}
t.Run(name, func(t *testing.T) {
- testExample(t, name, example)
+ testExample(t, name, dir)
})
}
}
@@ -135,10 +137,9 @@ func addRemote(local, remote string) {
CheckIfError(err)
}
-func testExample(t *testing.T, name, example string) {
- cmd := exec.Command("go", append([]string{
- "run", filepath.Join(example),
- }, args[name]...)...)
+func testExample(t *testing.T, name, dir string) {
+ arguments := append([]string{"run", dir}, args[name]...)
+ cmd := exec.Command("go", arguments...)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr