Skip to content

Commit

Permalink
Feature: Add --trackDir option
Browse files Browse the repository at this point in the history
With this commit, we can now establish a beginning state by specifying:
- a track directory
- a problem-specifications directory
- the offline mode

This allows us to do black-box testing of the release binary, running
something like:
    canonical_data_syncer -t /tmp/python -p /tmp/my_prob_specs --offline
and then asserting that the changes made are as expected.

Closes: exercism#50
  • Loading branch information
ee7 committed Oct 23, 2020
1 parent a674d6e commit 35c43e1
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Options:
-v, --verbosity <verbosity> The verbosity of output. Allowed values: q[uiet], n[ormal], d[etailed]
-p, --probSpecsDir <dir> Use this `problem-specifications` directory, rather than cloning temporarily
-o, --offline Do not check that the directory specified by `-p, --probSpecsDir` is up-to-date
-t, --trackDir <dir> Specify a track directory to use instead of the current directory
-h, --help Show this help message and exit
--version Show this tool's version information and exit
```
Expand Down
8 changes: 7 additions & 1 deletion src/cli.nim
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ type
verbosity*: Verbosity
probSpecsDir*: Option[string]
offline*: bool
trackDir*: Option[string]

Opt = enum
optExercise, optCheck, optMode, optVerbosity, optProbSpecsDir, optOffline,
optHelp, optVersion
optTrackDir, optHelp, optVersion

OptKey = tuple
short: string
Expand All @@ -37,6 +38,7 @@ const
("v", "verbosity"),
("p", "probSpecsDir"),
("o", "offline"),
("t", "trackDir"),
("h", "help"),
("_", "version"), # No short option for `--version`
]
Expand All @@ -61,6 +63,7 @@ Options:
-{optVerbosity.short}, --{optVerbosity.long} <verbosity> The verbosity of output. Allowed values: q[uiet], n[ormal], d[etailed]
-{optProbSpecsDir.short}, --{optProbSpecsDir.long} <dir> Use this `problem-specifications` directory, rather than cloning temporarily
-{optOffline.short}, --{optOffline.long} Do not check that the directory specified by `-p, --probSpecsDir` is up-to-date
-{optTrackDir.short}, --{optTrackDir.long} <dir> Specify a track directory to use instead of the current directory
-{optHelp.short}, --{optHelp.long} Show this help message and exit
--{optVersion.long} Show this tool's version information and exit"""

Expand Down Expand Up @@ -146,6 +149,9 @@ proc processCmdLine*: Conf =
result.probSpecsDir = some(val)
of optOffline.short, optOffline.long:
result.offline = true
of optTrackDir.short, optTrackDir.long:
showErrorForMissingVal(kind, key, val)
result.trackDir = some(val)
of optHelp.short, optHelp.long:
showHelp()
of optVersion.short, optVersion.long:
Expand Down
6 changes: 5 additions & 1 deletion src/tracks.nim
Original file line number Diff line number Diff line change
Expand Up @@ -83,5 +83,9 @@ proc findTrackExercises(repo: TrackRepo, conf: Conf): seq[TrackExercise] =
result.add(newTrackExercise(repoExercise))

proc findTrackExercises*(conf: Conf): seq[TrackExercise] =
let trackRepo = newTrackRepo()
let trackRepo =
if conf.trackDir.isSome():
TrackRepo(dir: conf.trackDir.get())
else:
newTrackRepo()
trackRepo.findTrackExercises(conf)

0 comments on commit 35c43e1

Please sign in to comment.