(args []string)
| 24 | } |
| 25 | |
| 26 | func runTest(args []string) error { |
| 27 | track, err := getTrack() |
| 28 | if err != nil { |
| 29 | return err |
| 30 | } |
| 31 | |
| 32 | testConf, ok := workspace.TestConfigurations[track] |
| 33 | |
| 34 | if !ok { |
| 35 | return fmt.Errorf("the \"%s\" track does not yet support running tests using the Exercism CLI. Please see HELP.md for testing instructions", track) |
| 36 | } |
| 37 | |
| 38 | command, err := testConf.GetTestCommand() |
| 39 | if err != nil { |
| 40 | return err |
| 41 | } |
| 42 | cmdParts := strings.Split(command, " ") |
| 43 | |
| 44 | // pass args/flags to this command down to the test handler |
| 45 | if len(args) > 0 { |
| 46 | cmdParts = append(cmdParts, args...) |
| 47 | } |
| 48 | |
| 49 | fmt.Printf("Running tests via `%s`\n\n", strings.Join(cmdParts, " ")) |
| 50 | exerciseTestCmd := exec.Command(cmdParts[0], cmdParts[1:]...) |
| 51 | |
| 52 | // pipe output directly out, preserving any color |
| 53 | exerciseTestCmd.Stdout = os.Stdout |
| 54 | exerciseTestCmd.Stderr = os.Stderr |
| 55 | |
| 56 | err = exerciseTestCmd.Run() |
| 57 | if err != nil { |
| 58 | // unclear what other errors would pop up here, but it pays to be defensive |
| 59 | if exitErr, ok := err.(*exec.ExitError); ok { |
| 60 | exitCode := exitErr.ExitCode() |
| 61 | // if subcommand returned a non-zero exit code, exit with the same |
| 62 | os.Exit(exitCode) |
| 63 | } else { |
| 64 | log.Fatalf("Failed to get error from failed subcommand: %v", err) |
| 65 | } |
| 66 | } |
| 67 | return nil |
| 68 | } |
| 69 | |
| 70 | func getTrack() (string, error) { |
| 71 | metadata, err := workspace.NewExerciseMetadata(".") |
no test coverage detected