From 1d6ccf14c912dc50967bb8d12fda57887467bbac Mon Sep 17 00:00:00 2001 From: ee7 <45465154+ee7@users.noreply.github.com> Date: Thu, 10 Jun 2021 22:26:07 +0200 Subject: [PATCH] sync: improve output for choosing tests (#352) 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 ``` --- src/sync/sync.nim | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/src/sync/sync.nim b/src/sync/sync.nim index 954cf505..6f17b8d4 100644 --- a/src/sync/sync.nim +++ b/src/sync/sync.nim @@ -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 =