Skip to content
This repository has been archived by the owner on Jun 7, 2020. It is now read-only.

Fixed redefined tests and added redefined test detection #28

Merged
merged 3 commits into from
Nov 21, 2017
Merged
Show file tree
Hide file tree
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
16 changes: 14 additions & 2 deletions ifj2017/test/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +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 {}, 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(
Expand Down
5 changes: 0 additions & 5 deletions ifj2017/tests/01_basic/tests.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 0 additions & 2 deletions ifj2017/tests/02_functions/tests.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down