-
-
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
cli, tests: write more things to stderr #205
Conversation
e0c293e
to
c16b2d7
Compare
There's a few other places that I'd like to change in order to close #200. What do you think about adding this commit to this PR? output-to-stderr...ee7:output-to-stderr With that commit, searching for
src/cli.nim
177: let f = if exitCode == 0: stdout else: stderr
src/uuid/uuid.nim
6: ## Writes `n` version 4 UUIDs to stdout. Writes only 1000 UUIDs if `n` is
17: stdout.write s and searching for
src/cli.nim
177: let f = if exitCode == 0: stdout else: stderr
188: stderr.styledWrite(fgRed, "Error: ")
189: stderr.write(s)
190: stderr.write("\n\n")
src/helpers.nim
21: stderr.styledWriteLine(fgRed, description & ":")
22: stderr.writeLine(details)
23: stderr.write "\n"
tests/test_binary.nim
23: stderr.writeLine outp
274: stderr.write(&"Running `{cmd}`... ")
277: stderr.writeLine "success"
279: stderr.writeLine "failure" And searching for
.github/bin/create-artifact
23:echo "ARTIFACT_FILE=${artifact_file}" >> "${GITHUB_ENV}"
.github/bin/publish-release
3:version="$(echo "${REF}" | cut -d'/' -f3)"
src/cli.nim
184: echo &"{configletVersion}"
src/lint/lint.nim
47: echo "The lint command is under development.\n" &
58: echo """
src/sync/sync.nim
12: echo &"""The following test case is missing:"
26: echo "Unknown response. Skipping test case..."
32: echo &"""The following test case is missing:"
49: echo "Unknown response. Skipping test case..." We can also consider:
But I think at least the latter is best saved for a later PR. |
I've opened #208 to make it easier to discuss. I've left two comments on that PR. |
Another thing: when running Let's handle #204 first and then rebase this PR on top.
Thanks. |
🤔 I don't know how other CLI applications do this. |
It's possible to argue that
It looks like
#!/bin/bash
a = 2
But it might be more common for linters to write detected problems to stderr. For example: Rust's I think there isn't always a right answer regarding stdout/stderr separation. I think either is fine for now. Maybe let's stick with stdout in For the current use of
src/helpers.nim
20:proc setFalseAndPrint*(b: var bool; description: string; details: string) =
src/lint/concept_exercises.nim
51: result.setFalseAndPrint("JSON parsing error", getCurrentExceptionMsg())
src/lint/lint.nim
17: result.setFalseAndPrint("Missing file", path)
src/lint/track_config.nim
51: result.setFalseAndPrint("Not a valid tag: " & $data, path)
53: result.setFalseAndPrint("Tag is not a string: " & $data, path)
79: result.setFalseAndPrint("JSON parsing error", getCurrentExceptionMsg())
84: result.setFalseAndPrint("Missing file", configJsonPath)
src/lint/validators.nim
11: result.setFalseAndPrint("Not an object: " & q(context), path)
17: result.setFalseAndPrint("Not an object: " & q(key), path)
19: result.setFalseAndPrint("Missing key: " & q(key), path)
27: result.setFalseAndPrint("String is zero-length: " & q(key), path)
29: result.setFalseAndPrint("String is whitespace-only: " & q(key), path)
31: result.setFalseAndPrint("Not a string: " & q(key) & ": " & $data[key], path)
33: result.setFalseAndPrint("Missing key: " & q(key), path)
49: result.setFalseAndPrint("Array is empty: " & format(context, key), path)
55: result.setFalseAndPrint("Array contains zero-length string: " &
58: result.setFalseAndPrint("Array contains whitespace-only string: " &
61: result.setFalseAndPrint("Array contains non-string: " &
64: result.setFalseAndPrint("Not an array: " & format(context, key), path)
66: result.setFalseAndPrint("Missing key: " & format(context, key), path)
76: result.setFalseAndPrint("Array is empty: " & q(key), path)
82: result.setFalseAndPrint("Not an array: " & q(key), path)
84: result.setFalseAndPrint("Missing key: " & q(key), path)
90: result.setFalseAndPrint("Not a bool: " & q(key) & ": " & $data[key], path)
92: result.setFalseAndPrint("Missing key: " & q(key), path)
98: result.setFalseAndPrint("Not an integer: " & q(key) & ": " & $data[key], path)
100: result.setFalseAndPrint("Missing key: " & q(key), path) |
Sounds good! |
This proc is currently called when: - the user passes invalid options/arguments to configlet - there was an error when trying to clone the problem-specifications repo
Rationale: - When the user writes `--help`, the help message should go to stdout. - When the user writes some incorrect options/arguments, the help message should go to stderr.
We can argue that this message isn't really the "output" of the tests, but is just a temporary communication to the user that the program hasn't hung unexpectedly. `unittest` writes everything to stdout, and so with this commit, the user who compiles the tests and runs ``` $ ./tests/all_tests > /tmp/configlet_test_results.txt ``` will no longer see the message in that file - they see it in their terminal instead.
I've amended the first commit to exclude that change, and rebased on I don't have a big preference about "squash and merge" vs "rebase and merge" here. But if we do squash then
is a bad commit message heading, since now only 1 of the 3 commits is really about "error messages". Happy to "rebase and merge" on the basis of preserving the specificity of the commit messages? |
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.
Approved for "rebase and merge".
Closes https://github.com/exercism/configlet/issues/200