Skip to content

Commit a6296e1

Browse files
committed
Merge pull request #189 from pminten/test-submit
Allow submitting test file with --test flag
2 parents 139105a + 585f178 commit a6296e1

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

cmd/submit.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,11 @@ func Submit(ctx *cli.Context) {
5151
log.Printf("file name: %s", filename)
5252
}
5353

54-
if isTest(filename) {
55-
log.Fatal("Please submit the solution, not the test file.")
54+
if isTest(filename) && !ctx.Bool("test") {
55+
log.Fatal("You're trying to submit a test file. If this is really what " +
56+
"you want, please pass the --test flag to exercism submit.")
57+
} else if !isTest(filename) && ctx.Bool("test") {
58+
log.Fatal("You've passed the --test flag but you're not submitting a test file.")
5659
}
5760

5861
file, err := filepath.Abs(filename)

exercism/main.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,12 @@ func main() {
121121
ShortName: "s",
122122
Usage: descSubmit,
123123
Action: cmd.Submit,
124+
Flags: []cli.Flag{
125+
cli.BoolFlag{
126+
Name: "test",
127+
Usage: "submit a test file",
128+
},
129+
},
124130
},
125131
{
126132
Name: "unsubmit",

0 commit comments

Comments
 (0)