Skip to content

Commit c7d23cb

Browse files
committed
Finish adding file-order option
1 parent f4f057c commit c7d23cb

7 files changed

Lines changed: 28 additions & 17 deletions

File tree

.githooks/pre-commit

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
#!/usr/bin/env bash
22

3-
# FMT_FILES=`gofmt -l . | grep -v "vendor/"`
4-
# if [[ $FMT_FILES != "" ]]; then
5-
# echo "Some files aren't formatted, please run 'go fmt ./...' to format your source code before committing"
6-
# echo "${FMT_FILES}"
7-
# exit 1
8-
# fi
3+
FMT_FILES=`gofmt -l . | grep -v "vendor/"`
4+
if [[ $FMT_FILES != "" ]]; then
5+
echo "Some files aren't formatted, please run 'go fmt ./...' to format your source code before committing"
6+
echo "${FMT_FILES}"
7+
exit 1
8+
fi
99

10-
# vetcount=`go vet ./... 2>&1 | wc -l`
11-
# if [ $vetcount -gt 0 ]; then
12-
# echo "Some files aren't passing vet heuristics, please run 'go vet ./...' to see the errors it flags and correct your source code before committing"
13-
# exit 1
14-
# fi
10+
vetcount=`go vet ./... 2>&1 | wc -l`
11+
if [ $vetcount -gt 0 ]; then
12+
echo "Some files aren't passing vet heuristics, please run 'go vet ./...' to see the errors it flags and correct your source code before committing"
13+
exit 1
14+
fi

cmd/commander/commander.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@ package main
22

33
import (
44
"fmt"
5-
"github.com/SimonBaeumer/commander/pkg/app"
6-
"github.com/urfave/cli"
75
"io/ioutil"
86
"log"
97
"os"
108
"path"
119
"strings"
10+
11+
"github.com/SimonBaeumer/commander/pkg/app"
12+
"github.com/urfave/cli"
1213
)
1314

1415
var version string
@@ -58,6 +59,11 @@ func createTestCommand() cli.Command {
5859
Usage: "More output for debugging",
5960
EnvVar: "COMMANDER_VERBOSE",
6061
},
62+
cli.BoolFlag{
63+
Name: "file-order",
64+
Usage: "Preserve file order",
65+
EnvVar: "COMMANDER_FILE_ORDER",
66+
},
6167
},
6268
Action: func(c *cli.Context) error {
6369
if c.Bool("verbose") {

pkg/app/app.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ const (
1313
type AddCommandContext struct {
1414
Verbose bool
1515
NoColor bool
16+
FileOrder bool
1617
Concurrent int
1718
}
1819

@@ -21,6 +22,7 @@ func NewAddContextFromCli(c *cli.Context) AddCommandContext {
2122
return AddCommandContext{
2223
Verbose: c.Bool("verbose"),
2324
NoColor: c.Bool("no-color"),
25+
FileOrder: c.Bool("file-order"),
2426
Concurrent: c.Int("concurrent"),
2527
}
2628
}

pkg/app/test_command.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ func TestCommand(input string, title string, ctx AddCommandContext) error {
4545
return fmt.Errorf("Error " + err.Error())
4646
}
4747

48-
out := output.NewCliOutput(!ctx.NoColor, true)
48+
out := output.NewCliOutput(!ctx.NoColor, ctx.FileOrder)
4949
if !out.Start(results) {
5050
return fmt.Errorf("Test suite failed, use --verbose for more detailed output")
5151
}

pkg/output/cli.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ func (w *OutputWriter) Start(results <-chan runtime.TestResult) bool {
9393

9494
w.fprintf("")
9595
for _, e := range fileErrors {
96+
w.fprintf("File Errors:")
9697
w.fprintf(e)
9798
}
9899
return failed == 0

pkg/output/cli_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
)
1313

1414
func Test_NewCliOutput(t *testing.T) {
15-
got := NewCliOutput(true)
15+
got := NewCliOutput(true, true)
1616
assert.IsType(t, OutputWriter{}, got)
1717
}
1818

pkg/runtime/runtime_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
package runtime
22

33
import (
4-
"github.com/stretchr/testify/assert"
54
"testing"
65
"time"
6+
7+
"github.com/stretchr/testify/assert"
78
)
89

910
func Test_NewRuntime(t *testing.T) {
10-
runtime := NewRuntime(Node{Name: "test"}, Node{Name: "test2"})
11+
runtime := NewRuntime("myfile", Node{Name: "test"}, Node{Name: "test2"})
1112

1213
assert.Len(t, runtime.Nodes, 3)
1314
}
@@ -70,6 +71,7 @@ func TestRuntime_WithRetriesAndInterval(t *testing.T) {
7071

7172
func Test_Runtime_getExecutor(t *testing.T) {
7273
r := NewRuntime(
74+
"myfile",
7375
Node{Name: "ssh-host", Type: "ssh"},
7476
Node{Name: "localhost", Type: "local"},
7577
Node{Name: "default", Type: ""},

0 commit comments

Comments
 (0)