From eb6b4e7affece7e0bd55a5dad7fa0ac86e846a40 Mon Sep 17 00:00:00 2001 From: Timotej Halas Date: Tue, 21 Nov 2017 20:02:37 +0100 Subject: [PATCH 1/2] Fixed redefined tests and added redefined test detection --- ifj2017/test/loader.py | 15 +++++++++++++-- ifj2017/tests/01_basic/tests.json | 5 ----- ifj2017/tests/02_functions/tests.json | 2 -- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/ifj2017/test/loader.py b/ifj2017/test/loader.py index ca90503..be8c88c 100644 --- a/ifj2017/test/loader.py +++ b/ifj2017/test/loader.py @@ -60,9 +60,20 @@ def _load_compact_tests(self, section_dir): extensions = tuple(data.get('extensions', ())) try: for i, test_case in enumerate(data.get('tests', ())): - name = test_case.get('name') or '{:03}'.format(i + 1) - code = test_case.get('code') or self._load_test_file(section_dir, name, 'code') + name = test_case.get('name') + code = test_case.get('code') + if name and code: + TestLogger.log_warning( + "Redefined test {} in file {}.".format(name, path.join(section_dir, 'tests.json')) + ) + + if not name: + name = '{:03}'.format(i + 1) + + if not code: + code = self._load_test_file(section_dir, name, 'code') + cases.append( TestInfo( name, diff --git a/ifj2017/tests/01_basic/tests.json b/ifj2017/tests/01_basic/tests.json index 60ff192..5207f96 100644 --- a/ifj2017/tests/01_basic/tests.json +++ b/ifj2017/tests/01_basic/tests.json @@ -19,32 +19,27 @@ "stdout": "? Martin Kobelka napsal tento test" }, { - "name": "13", "info": "Multi line string", "stdout": "ahoj\nsvete", "code": "scope \n print !\"ahoj\\nsvete\"; \nend scope" }, { - "name": "14", "info": "Simple integer print", "stdout": " 42", "code": "scope \n print 42; \nend scope" }, { - "name": "15", "info": "Simple double print", "stdout": " 5876.78", "code": "scope \n print 5876.78; \nend scope" }, { - "name": "16", "info": "Simple input and print", "stdin": "42", "stdout": "? 42", "code": "scope \n dim a as integer \n input a \n print a; \nend scope" }, { - "name": "17", "info": "Add two inputs", "stdin": "42\n24", "stdout": "? ? 66", diff --git a/ifj2017/tests/02_functions/tests.json b/ifj2017/tests/02_functions/tests.json index bb132a5..c0c0520 100644 --- a/ifj2017/tests/02_functions/tests.json +++ b/ifj2017/tests/02_functions/tests.json @@ -13,13 +13,11 @@ "compiler_exit_code": 4 }, { - "name": "01", "info": "Asc value", "stdout": " 104", "code": "scope \n print asc(!\"ahoj\", 2); \n end scope" }, { - "name": "02", "info": "Chr function", "stdout": "a", "code": "scope \n print chr(97); \n end scope" From 8bf24e72ee8c98567ea6292583d781ae9d7ff7ee Mon Sep 17 00:00:00 2001 From: Timotej Halas Date: Tue, 21 Nov 2017 21:12:28 +0100 Subject: [PATCH 2/2] Skip test if it is redefined. #28 --- ifj2017/test/loader.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ifj2017/test/loader.py b/ifj2017/test/loader.py index be8c88c..e8dcdd9 100644 --- a/ifj2017/test/loader.py +++ b/ifj2017/test/loader.py @@ -65,15 +65,16 @@ def _load_compact_tests(self, section_dir): if name and code: TestLogger.log_warning( - "Redefined test {} in file {}.".format(name, path.join(section_dir, 'tests.json')) + "Redefined test {} in file {}, skipping.".format(name, path.join(section_dir, 'tests.json')) ) + continue if not name: name = '{:03}'.format(i + 1) if not code: code = self._load_test_file(section_dir, name, 'code') - + cases.append( TestInfo( name,