Skip to content

Commit

Permalink
sync: improve output for choosing tests (#352)
Browse files Browse the repository at this point in the history
Summary:
- Move the user's response to the end of the line. It was previously on
  a new line.
- Remove some unmatched double quotes, and some strange colons.
- Prompt on stderr.
- Add two blank link between test cases.


Before this commit:

```
[warn] isogram: missing 2 test cases
The following test case is missing:"
{
  (omitted for clarity)
}:

Do you want to include the test case ([y]es/[n]o/[s]kip)?:

s
[warn] kindergarten-garden: missing 3 test cases
```


With this commit:

```
[warn] isogram: missing 2 test cases
The following test case is missing:
{
  (omitted for clarity)
}

Do you want to include the test case ([y]es/[n]o/[s]kip)? s


[warn] kindergarten-garden: missing 3 test cases
```
  • Loading branch information
ee7 authored Jun 10, 2021
1 parent 6b7d98a commit 1d6ccf1
Showing 1 changed file with 22 additions and 11 deletions.
33 changes: 22 additions & 11 deletions src/sync/sync.nim
Original file line number Diff line number Diff line change
Expand Up @@ -6,43 +6,54 @@ type
SyncDecision = enum
sdIncludeTest, sdExcludeTest, sdSkipTest, sdReplaceTest

proc writeBlankLines =
stderr.write "\n\n"

proc chooseRegularSyncDecision(testCase: ExerciseTestCase): SyncDecision =
echo &"""The following test case is missing:"
{testCase.json.pretty()}:
stderr.write &"""
The following test case is missing:
{testCase.json.pretty()}
Do you want to include the test case ([y]es/[n]o/[s]kip)?:
"""
Do you want to include the test case ([y]es/[n]o/[s]kip)? """

case stdin.readLine().toLowerAscii()
of "y", "yes":
writeBlankLines()
sdIncludeTest
of "n", "no":
writeBlankLines()
sdExcludeTest
of "s", "skip":
writeBlankLines()
sdSkipTest
else:
echo "Unknown response. Skipping test case..."
stderr.writeLine "Unknown response. Skipping test case..."
writeBlankLines()
sdSkipTest

proc chooseReimplementsSyncDecision(testCase: ExerciseTestCase): SyncDecision =
echo &"""The following test case is missing:"
{testCase.json.pretty()}:
stderr.write &"""
The following test case is missing:
{testCase.json.pretty()}
It reimplements this test case:
{testCase.reimplements.get().json.pretty()}:
{testCase.reimplements.get().json.pretty()}
Do you want to replace the existing test case ([y]es/[n]o/[s]kip)?:
"""
Do you want to replace the existing test case ([y]es/[n]o/[s]kip)? """

case stdin.readLine().toLowerAscii()
of "y", "yes":
writeBlankLines()
sdReplaceTest
of "n", "no":
writeBlankLines()
sdExcludeTest
of "s", "skip":
writeBlankLines()
sdSkipTest
else:
echo "Unknown response. Skipping test case..."
stderr.writeLine "Unknown response. Skipping test case..."
writeBlankLines()
sdSkipTest

proc syncDecision(testCase: ExerciseTestCase, mode: Mode): SyncDecision =
Expand Down

0 comments on commit 1d6ccf1

Please sign in to comment.