From 8b229aaba2196d739631667f5902f61d57974854 Mon Sep 17 00:00:00 2001 From: Erik Schierboom Date: Fri, 7 May 2021 15:59:11 +0200 Subject: [PATCH 1/5] sync: output `reimplements` property With this commit, `configlet sync` will add a `reimplements` property to each relevent test case when writing the `tests.toml` file to. This helps the reader to identify re-implemented test cases. For example: ```toml [b9228bb1-465f-4141-b40f-1f99812de5a8] description = "disallow first strand longer" reimplements = "919f8ef0-b767-4d1b-8516-6379d07fcb28" ``` --- README.md | 13 ++++++++++--- src/sync/exercises.nim | 23 +++++++++++++++++------ 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index bcffac2c..679dde12 100644 --- a/README.md +++ b/README.md @@ -44,9 +44,16 @@ If a track implements an exercise for which test data exists in the [problem-spe A `tests.toml` file has this format: ```toml -# This is an auto-generated file. Regular comments will be removed when this -# file is regenerated. Regenerating will not touch any manually added keys, -# so comments can be added in a "comment" key. +# This is an auto-generated file. +# +# Regenerating this file will: +# - Update the `description` property +# - Update the `reimplements` property +# - Remove `include = true` properties +# - Preserve any other properties +# +# As regular comments will be removed when this file is regenerated, comments +# can be added in a "comment" key [1e22cceb-c5e4-4562-9afe-aef07ad1eaf4] description = "basic" diff --git a/src/sync/exercises.nim b/src/sync/exercises.nim index 3f1a2966..9dc45b21 100644 --- a/src/sync/exercises.nim +++ b/src/sync/exercises.nim @@ -118,12 +118,19 @@ proc prettyTomlString(a: openArray[TomlValueRef]): string = proc toToml(exercise: Exercise, testsPath: string): string = ## Returns the new contents of a `tests.toml` file that corresponds to an ## `exercise`. This proc reads the previous contents at `testsPath` and - ## preserves every property apart from `description` and `include = true`. + ## updates the `description` and `reimplements` properties, removes any + ## `include = true` properties and preserves any other property. result = """ -# This is an auto-generated file. Regular comments will be removed when this -# file is regenerated. Regenerating will not touch any manually added keys, -# so comments can be added in a "comment" key. - +# This is an auto-generated file. +# +# Regenerating this file will: +# - Update the `description` property +# - Update the `reimplements` property +# - Remove `include = true` properties +# - Preserve any other properties +# +# As regular comments will be removed when this file is regenerated, comments +# can be added in a "comment" key. """ for testCase in exercise.testCases: @@ -137,12 +144,16 @@ proc toToml(exercise: Exercise, testsPath: string): string = if uuid in exercise.tests.excluded: result.add "include = false\n" + # Always output the `reimplements` value, if present + if testCase.reimplements.isSome: + result.add &"reimplements = \"{testCase.reimplements.get.uuid}\"\n" + if fileExists(testsPath): let currContents = parsetoml.parseFile(testsPath) if currContents.hasKey(uuid): # Preserve custom properties for k, v in currContents[uuid].getTable(): - if k notin ["description", "include"].toHashSet(): + if k notin ["description", "include", "reimplements"].toHashSet(): let vTomlString = if v.kind == String: prettyTomlString(v.stringVal) From baffbfe7d0a88c092f48beecee4332da0c793aa8 Mon Sep 17 00:00:00 2001 From: ee7 <45465154+ee7@users.noreply.github.com> Date: Fri, 7 May 2021 16:28:01 +0200 Subject: [PATCH 2/5] tests(binary): reflect `reimplements` change --- tests/test_binary.nim | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/test_binary.nim b/tests/test_binary.nim index 9bad041f..bc5036e2 100644 --- a/tests/test_binary.nim +++ b/tests/test_binary.nim @@ -139,10 +139,12 @@ All exercises are synced! +++ exercises/practice/hamming/.meta/tests.toml +[db92e77e-7c72-499d-8fe6-9354d2bfd504] +description = "disallow left empty strand" ++reimplements = "5dce058b-28d4-4ca7-aa64-adfe4e17784c" + + +[920cd6e3-18f4-4143-b6b8-74270bb8f8a3] +description = "disallow right empty strand" ++reimplements = "38826d4b-16fb-4639-ac3e-ba027dec8b5f" --- exercises/practice/high-scores/.meta/tests.toml +++ exercises/practice/high-scores/.meta/tests.toml + From 434e42eabaf35594ed71bbc3ce9689e0a1431bd4 Mon Sep 17 00:00:00 2001 From: ee7 <45465154+ee7@users.noreply.github.com> Date: Fri, 7 May 2021 16:28:02 +0200 Subject: [PATCH 3/5] sync(exercises): clarify call vs field access --- src/sync/exercises.nim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sync/exercises.nim b/src/sync/exercises.nim index 9dc45b21..1a027a25 100644 --- a/src/sync/exercises.nim +++ b/src/sync/exercises.nim @@ -145,8 +145,8 @@ proc toToml(exercise: Exercise, testsPath: string): string = result.add "include = false\n" # Always output the `reimplements` value, if present - if testCase.reimplements.isSome: - result.add &"reimplements = \"{testCase.reimplements.get.uuid}\"\n" + if testCase.reimplements.isSome(): + result.add &"reimplements = \"{testCase.reimplements.get().uuid}\"\n" if fileExists(testsPath): let currContents = parsetoml.parseFile(testsPath) From 4b8225cb9696b860395c1cd80d2e1c373b309649 Mon Sep 17 00:00:00 2001 From: ee7 <45465154+ee7@users.noreply.github.com> Date: Fri, 7 May 2021 16:28:03 +0200 Subject: [PATCH 4/5] sync(exercises): nitpick comment --- src/sync/exercises.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sync/exercises.nim b/src/sync/exercises.nim index 1a027a25..52a68415 100644 --- a/src/sync/exercises.nim +++ b/src/sync/exercises.nim @@ -144,7 +144,7 @@ proc toToml(exercise: Exercise, testsPath: string): string = if uuid in exercise.tests.excluded: result.add "include = false\n" - # Always output the `reimplements` value, if present + # Always add the `reimplements` property, if present if testCase.reimplements.isSome(): result.add &"reimplements = \"{testCase.reimplements.get().uuid}\"\n" From 5556989c7ee8acc603627fe09f745a5dc3ca662c Mon Sep 17 00:00:00 2001 From: ee7 <45465154+ee7@users.noreply.github.com> Date: Fri, 28 May 2021 18:24:57 +0200 Subject: [PATCH 5/5] tests(binary): reflect new `tests.toml` comments --- tests/test_binary.nim | 98 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 97 insertions(+), 1 deletion(-) diff --git a/tests/test_binary.nim b/tests/test_binary.nim index bc5036e2..f37acae8 100644 --- a/tests/test_binary.nim +++ b/tests/test_binary.nim @@ -127,16 +127,58 @@ All exercises are synced! const expectedDiffOutput = """ --- exercises/practice/diffie-hellman/.meta/tests.toml +++ exercises/practice/diffie-hellman/.meta/tests.toml +-# This is an auto-generated file. Regular comments will be removed when this +-# file is regenerated. Regenerating will not touch any manually added keys, +-# so comments can be added in a "comment" key. +- ++# This is an auto-generated file. ++# ++# Regenerating this file will: ++# - Update the `description` property ++# - Update the `reimplements` property ++# - Remove `include = true` properties ++# - Preserve any other properties ++# ++# As regular comments will be removed when this file is regenerated, comments ++# can be added in a "comment" key. +[0d25f8d7-4897-4338-a033-2d3d7a9af688] +description = "can calculate public key when given a different private key" + --- exercises/practice/grade-school/.meta/tests.toml +++ exercises/practice/grade-school/.meta/tests.toml +-# This is an auto-generated file. Regular comments will be removed when this +-# file is regenerated. Regenerating will not touch any manually added keys, +-# so comments can be added in a "comment" key. +- ++# This is an auto-generated file. ++# ++# Regenerating this file will: ++# - Update the `description` property ++# - Update the `reimplements` property ++# - Remove `include = true` properties ++# - Preserve any other properties ++# ++# As regular comments will be removed when this file is regenerated, comments ++# can be added in a "comment" key. +[c125dab7-2a53-492f-a99a-56ad511940d8] +description = "A student can't be in two different grades" + --- exercises/practice/hamming/.meta/tests.toml +++ exercises/practice/hamming/.meta/tests.toml +-# This is an auto-generated file. Regular comments will be removed when this +-# file is regenerated. Regenerating will not touch any manually added keys, +-# so comments can be added in a "comment" key. +- ++# This is an auto-generated file. ++# ++# Regenerating this file will: ++# - Update the `description` property ++# - Update the `reimplements` property ++# - Remove `include = true` properties ++# - Preserve any other properties ++# ++# As regular comments will be removed when this file is regenerated, comments ++# can be added in a "comment" key. +[db92e77e-7c72-499d-8fe6-9354d2bfd504] +description = "disallow left empty strand" +reimplements = "5dce058b-28d4-4ca7-aa64-adfe4e17784c" @@ -147,6 +189,20 @@ All exercises are synced! +reimplements = "38826d4b-16fb-4639-ac3e-ba027dec8b5f" --- exercises/practice/high-scores/.meta/tests.toml +++ exercises/practice/high-scores/.meta/tests.toml +-# This is an auto-generated file. Regular comments will be removed when this +-# file is regenerated. Regenerating will not touch any manually added keys, +-# so comments can be added in a "comment" key. +- ++# This is an auto-generated file. ++# ++# Regenerating this file will: ++# - Update the `description` property ++# - Update the `reimplements` property ++# - Remove `include = true` properties ++# - Preserve any other properties ++# ++# As regular comments will be removed when this file is regenerated, comments ++# can be added in a "comment" key. + +[2df075f9-fec9-4756-8f40-98c52a11504f] +description = "Latest score after personal top scores" @@ -155,6 +211,20 @@ All exercises are synced! +description = "Scores after personal top scores" --- exercises/practice/kindergarten-garden/.meta/tests.toml +++ exercises/practice/kindergarten-garden/.meta/tests.toml +-# This is an auto-generated file. Regular comments will be removed when this +-# file is regenerated. Regenerating will not touch any manually added keys, +-# so comments can be added in a "comment" key. +- ++# This is an auto-generated file. ++# ++# Regenerating this file will: ++# - Update the `description` property ++# - Update the `reimplements` property ++# - Remove `include = true` properties ++# - Preserve any other properties ++# ++# As regular comments will be removed when this file is regenerated, comments ++# can be added in a "comment" key. -description = "first student's garden" +description = "for Alice, first student's garden" -description = "second student's garden" @@ -189,6 +259,20 @@ All exercises are synced! +description = "for Larry, last student's garden" --- exercises/practice/prime-factors/.meta/tests.toml +++ exercises/practice/prime-factors/.meta/tests.toml +-# This is an auto-generated file. Regular comments will be removed when this +-# file is regenerated. Regenerating will not touch any manually added keys, +-# so comments can be added in a "comment" key. +- ++# This is an auto-generated file. ++# ++# Regenerating this file will: ++# - Update the `description` property ++# - Update the `reimplements` property ++# - Remove `include = true` properties ++# - Preserve any other properties ++# ++# As regular comments will be removed when this file is regenerated, comments ++# can be added in a "comment" key. +[238d57c8-4c12-42ef-af34-ae4929f94789] +description = "another prime number" + @@ -206,7 +290,19 @@ All exercises are synced! + --- exercises/practice/react/.meta/tests.toml +++ exercises/practice/react/.meta/tests.toml -+ +-# This is an auto-generated file. Regular comments will be removed when this +-# file is regenerated. Regenerating will not touch any manually added keys, +-# so comments can be added in a "comment" key. ++# This is an auto-generated file. ++# ++# Regenerating this file will: ++# - Update the `description` property ++# - Update the `reimplements` property ++# - Remove `include = true` properties ++# - Preserve any other properties ++# ++# As regular comments will be removed when this file is regenerated, comments ++# can be added in a "comment" key. +[c51ee736-d001-4f30-88d1-0c8e8b43cd07] +description = "input cells have a value" +