-
-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: Add --trackDir
option
#72
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great! Approving pending the fix for the writing of the tests.toml files relative to the track dir.
d807ca3
to
5d7f540
Compare
5d7f540
to
64ae1f0
Compare
@@ -100,13 +101,13 @@ proc sync(exercise: Exercise, mode: Mode): Exercise = | |||
|
|||
result.tests = initExerciseTests(included, excluded, missing) | |||
|
|||
writeFile(result) | |||
writeTestsToml(result, conf.trackDir) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is conf.trackDir
set to the current directory if the --track-dir
argument is not specified?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was set to the empty string, which ends up meaning the current directory.
From the examples in https://nim-lang.github.io/Nim/os.html#/,string,string
`assert "" / "lib" == "lib"`
So
trackDir / "exercises" / exercise.slug / ".meta" / "tests.toml"
was the same as
"exercises" / exercise.slug / ".meta" / "tests.toml"
when trackDir
is empty.
I pushed a new commit, do you prefer it?
src/sync/tracks.nim
Outdated
if conf.trackDir.len > 0: | ||
TrackRepo(dir: conf.trackDir) | ||
else: | ||
newTrackRepo() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering if it would perhaps be easier to set conf.trackDir
to the current directory if the --track-dir
argument is specified.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
set
conf.trackDir
to the current directory if the--track-dir
argument is specified.
Do you mean "set the current directory to conf.trackDir
if --track-dir
is specified"?
We could indeed change the current directory in the program somewhere, but I think that might be harder to debug - it's more implicit. In particular, we might not want to change directory all the time when we're running the tests. It's also a problem that we have some instances of deep quit
in the code right now.
We could use the withDir
template, but it might be easier to just pass conf
or conf.trackDir
around for now. In the long-term I want to do a refactoring pass on exercises.nim
, tracks.nim
, and sync.nim
that should help some of these issues. I have an old branch for that, but I never finished it.
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: configlet -t /tmp/python -p /tmp/my_prob_specs --offline and then asserting that the changes made are as expected. Closes: exercism#50
Previously the test file path was always derived from the working directory.
64ae1f0
to
4f3ff45
Compare
Previously `conf.trackDir` was the empty string when `--track-dir` was not provided. That worked previously because code like let myPath = "" / "foo" resolves to "foo" in the current directory, but setting it explicitly is more obvious.
proc newTrackRepo: TrackRepo = | ||
result.dir = getCurrentDir() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made this change partly because I find it more readable to inline it in findTrackExercises
.
But there's also a general issue that I'll try to fix everywhere eventually: I believe that procs that initialize non-ref
objects should be named starting with init
, not new
- even if they contain a field of a type like string
.
From the style guide: https://nim-lang.github.io/Nim/nep1.html#introduction-naming-conventions
The stdlib API is designed to be easy to use and consistent. Ease of use is measured by the number of calls to achieve a concrete high level action. The ultimate goal is that the programmer can guess a name.
The library uses a simple naming scheme that makes use of common abbreviations to keep the names short but meaningful.
English word To use Notes initialize initT
init
is used to create a value typeT
new newP
new
is used to create a reference typeP
... ... ...
For example, in the stdlib sets
module, we write initHashSet
for an object
named HashSet
, even though that object has a field of type seq
But in my refactoring branch I think I changed a lot of this stuff to use distinct string
rather than an one-field object anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! The only thing I found was that when using --track-dir
, the prob-specs
repo gets cloned to the current directory instead of the track's dir. We can fix that later.
Yes, currently the temporary We should be careful that everything behaves correctly when both options are provided, regardless of the order:
|
Correct. It would be mostly for the error case that I would expect it to be located in the track dir. |
This commit allows the configlet binary to act on a different directory than its own. This is useful in general, but it will also help us to test configlet itself - we can now establish an initial state for end-to-end tests by specifying: - a track directory - a problem-specifications directory - the offline mode That allows us to do black-box testing of the release binary, running something like: configlet sync -t=/tmp/python -p=/tmp/my_prob_specs -o -m=include and then asserting that the changes made are as expected. Note that we implement `-t, --track-dir` as a global option, rather than an option for `sync` - it will also be useful for e.g. `lint`. Some decisions: - Set the default value of `conf.trackDir` explicitly to the current directory in `cli.nim`. - Determine the `tests.toml` path from `conf.trackDir`, but don't change the current directory to `conf.trackDir`. Closes: exercism#50
This commit allows the
configlet
binary to act on a different directorythan its own. This is useful in general, but it will also help us to
test
configlet
itself - we can now establish an initial state forend-to-end tests by specifying:
That allows us to do black-box testing of the release binary, running
something like:
and then asserting that the changes made are as expected.
Note that we implement
-t, --track-dir
as a global option, rather thanan option for
sync
- it will also be useful for e.g.lint
.Some decisions:
conf.trackDir
explicitly to the currentdirectory in
cli.nim
.tests.toml
path fromconf.trackDir
, but don't changethe current directory to
conf.trackDir
.Closes: #50
WIP:
master
and reflect recent changes (e.g.--trackDir
->--track-dir
)sync
mode, make it write to the given-t, --trackDir
, rather than relative to the current directory.tests.toml
#134 and rebase this PR on top.Let's add tests in a later PR. We can leave
-t, --track-dir
undocumented in the firstconfiglet
releases if we feel it isn't tested well enough.