-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2a816b4
commit 81ce9e1
Showing
15 changed files
with
302 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,11 @@ | ||
build: | ||
$(info INFO: Starting build $@) | ||
go build cmd/commander/commander.go | ||
|
||
test: | ||
go test ./... | ||
$(info INFO: Starting build $@) | ||
go test ./... | ||
|
||
test-integration: build | ||
$(info INFO: Starting build $@) | ||
./commander test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
tests: | ||
it should fail with invalid argument: | ||
command: ./commander asfdf | ||
exit-code: 3 | ||
it should display help: | ||
command: ./commander | ||
exit-code: 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,4 @@ tests: | |
"it should print hello world": | ||
command: "echo hello world" | ||
stdout: hello world | ||
exit-code: 0 | ||
exit-code: 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package output | ||
|
||
import ( | ||
"fmt" | ||
"log" | ||
) | ||
|
||
type HumanOutput struct { | ||
buffer []string | ||
} | ||
|
||
func (o HumanOutput) BuildHeader() { | ||
s := "Starting test suite...\n" | ||
o.add(s) | ||
} | ||
|
||
func (o HumanOutput) BuildTestResult(test TestCase) string { | ||
var s string | ||
|
||
if test.Result.Success { | ||
s = fmt.Sprintf("✓ %s", test.Title) | ||
} else { | ||
s = fmt.Sprintf("✗ %s\n", test.Title) | ||
for _, p := range test.Result.FailureProperties { | ||
log.Printf("Printing property result '%s'", p) | ||
if p == "Stdout" { | ||
s += fmt.Sprintf("Got '%s', expected '%s'\n", test.Result.Stdout, test.Stdout) | ||
} | ||
if p == "Stderr" { | ||
s += fmt.Sprintf("Got %s, expected %s\n", test.Result.Stderr, test.Stderr) | ||
} | ||
if p == "ExitCode" { | ||
s += fmt.Sprintf("Got %d, expected %d\n", test.Result.ExitCode, test.ExitCode) | ||
} | ||
} | ||
} | ||
|
||
o.add(s) | ||
return s | ||
} | ||
|
||
func (o HumanOutput) BuildSuiteResult() { | ||
s := "Duration: 3.24sec" | ||
o.add(s) | ||
} | ||
|
||
func (o HumanOutput) add(out string) { | ||
o.buffer = append(o.buffer, out) | ||
} | ||
|
||
func (o HumanOutput) GetBuffer() []string { | ||
return o.buffer | ||
} | ||
|
||
func (o HumanOutput) Print() { | ||
for _, s := range o.GetBuffer() { | ||
fmt.Println(s) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package output | ||
|
||
import ( | ||
"github.com/SimonBaeumer/commander/pkg" | ||
) | ||
|
||
type TestCase commander.TestCase | ||
|
||
type Output interface { | ||
BuildHeader() | ||
BuildTestResult(test TestCase) | ||
BuildSuiteResult() | ||
GetBuffer() []string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.