Skip to content
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

sync: improve output for choosing tests #352

Merged
merged 4 commits into from
Jun 10, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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