diff --git a/Makefile b/Makefile index 4a48585..f030379 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -dirs := $(wildcard exercises/*) +dirs := $(wildcard exercises/practice/*) all-tests := $(addprefix test-, $(notdir $(dirs))) COMMIT_RANGE := HEAD @@ -25,20 +25,20 @@ gha: @$(MAKE) -s debug $(eval tests := $(shell \ git diff-tree --name-only -r --diff-filter=AM $(COMMIT_RANGE) | \ - perl -n -e '/exercises\/practice/([a-z-_]+)\/.+\.sml/ && print "test-$$1\n"' | uniq)) + perl -n -e '/exercises\/practice\/([a-z-_]+)\/.+\.sml/ && print "test-$$1\n"' | uniq)) $(if $(tests), @echo Tests: $(tests), @echo 'Nothing to test.') $(if $(tests), @$(MAKE) -s $(tests)) test-%: $(eval exercise := $(patsubst test-%, %, $@)) @echo - @ls ./exercises/practice/$(exercise)/README.md > /dev/null + @ls ./exercises/practice/$(exercise)/.docs/instructions.md > /dev/null @# check stub type @cd ./exercises/practice/$(exercise) && \ poly -q --use test | grep 'error: Type error' | \ wc -l | xargs -I @ expr @ = 0 > /dev/null || \ { echo '$(exercise).sml is faulty'; exit 1; } - @cd ./exercises/practice/$(exercise) && cat test.sml | sed 's/$(exercise).sml/.meta/example.sml/' | poly -q + @cd ./exercises/practice/$(exercise) && cat test.sml | sed 's/$(exercise).sml/.meta\/example.sml/' | poly -q @echo .PHONY: test diff --git a/bin/generate b/bin/generate index 73d04b2..0302a9b 100755 --- a/bin/generate +++ b/bin/generate @@ -100,11 +100,10 @@ def sml_value(value, smltype='', force=False): def get_fn_args(case): - reserved_keys = {'property', 'expected', 'description', 'comments'} + case_input = case["input"] return OrderedDict( - (k, case[k]) - for k in sorted(case.keys()) - if k not in reserved_keys + (k, case_input[k]) + for k in sorted(case_input.keys()) ) @@ -157,7 +156,8 @@ def extract_signatures(data, force=False): def expectation(signature, fn, args, expected, force=False): tmpl = '(fn _ => %s |> Expect.%s)' output = sml_value(expected, signature['output'], force=force) - invocation = '%s (%s)' % ( + invocation_tmpl = '%s %s' if len(args) == 1 else '%s (%s)' + invocation = invocation_tmpl % ( fn, ', '.join(( sml_value(val, signature['args'][arg], force=force) @@ -213,8 +213,6 @@ def generate_test_content(data, signature, force=False): return acc return '\n'.join([ - '(* version %s *)' % data['version'], - '', 'use "testlib.sml";', 'use "%s.sml";' % data['exercise'], '', @@ -260,7 +258,7 @@ FLAGS = TEST | STUB | EXAMPLE def generate(exercise, flags, force=False): root = Path(__file__).parent.parent.absolute() - path = root / 'exercises' / exercise + path = root / 'exercises' / 'practice' / exercise if not path.exists(): path.mkdir()