diff --git a/bin/generate-spec b/bin/generate-spec index dc1f5f70..14bd5690 100755 --- a/bin/generate-spec +++ b/bin/generate-spec @@ -15,6 +15,24 @@ local function write_file(path, contents) f:close() end +local function included_tests_from_toml(path) + local included = {} + local last_uuid + + for line in io.lines(path) do + for uuid in line:gmatch('%[([%x%-]+)%]') do + last_uuid = uuid + included[uuid] = true + end + + if line:match('^include%s*=%s*false') then + included[last_uuid] = nil + end + end + + return included +end + local exercise_name = arg[1] local exercise_directory = 'exercises/practice/' .. exercise_name @@ -24,6 +42,7 @@ package.path = package.path .. ';' .. exercise_directory .. '/.meta/?.lua' local canonical_data_url = 'https://raw.githubusercontent.com/exercism/problem-specifications/main/exercises/' .. exercise_name .. '/canonical-data.json' local canonical_data_path = 'canonical-data/' .. exercise_name .. '.json' local spec_path = exercise_directory .. '/' .. exercise_name .. '_spec.lua' +local tests_toml_path = exercise_directory .. '/.meta/tests.toml' assert(os.execute('mkdir -p `dirname ' .. canonical_data_path .. '`')) assert(os.execute('curl ' .. canonical_data_url .. ' -s -o ' .. canonical_data_path)) @@ -33,6 +52,8 @@ local canonical_data = json.decode(canonical_data_json) local spec_generator = require('spec_generator') +local included_tests = included_tests_from_toml(tests_toml_path) + local function process(node) if node.cases then local output = {} @@ -49,7 +70,9 @@ local function process(node) local cases = {} for _, case in ipairs(node.cases) do - table.insert(cases, process(case)) + if not case.uuid or included_tests[case.uuid] then + table.insert(cases, process(case)) + end end table.insert(output, table.concat(cases, '\n\n')) diff --git a/exercises/practice/book-store/book-store_spec.lua b/exercises/practice/book-store/book-store_spec.lua index 9e75ee2b..676c9ce4 100644 --- a/exercises/practice/book-store/book-store_spec.lua +++ b/exercises/practice/book-store/book-store_spec.lua @@ -76,12 +76,11 @@ describe('book-store', function() assert.are.same(10240, book_store.total(basket)) end) - -- LuaFormatter off - it('check that groups of four are created properly even when there are more groups of three than groups of five', function() + it('check that groups of four are created properly even when there are more groups of three than groups of five', + function() local basket = { 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 5, 5 } assert.are.same(14560, book_store.total(basket)) end) - -- LuaFormatter on it('one group of one and four is cheaper than one group of two and three', function() local basket = { 1, 1, 2, 3, 4 } diff --git a/exercises/practice/state-of-tic-tac-toe/state-of-tic-tac-toe_spec.lua b/exercises/practice/state-of-tic-tac-toe/state-of-tic-tac-toe_spec.lua index 0784cf11..774613cd 100644 --- a/exercises/practice/state-of-tic-tac-toe/state-of-tic-tac-toe_spec.lua +++ b/exercises/practice/state-of-tic-tac-toe/state-of-tic-tac-toe_spec.lua @@ -65,15 +65,6 @@ describe('state-of-tic-tac-toe', function() assert.are.same('win', state_of_tic_tac_toe.gamestate(board)) end) - it('finished game where x won via middle row victory', function() - local board = { - 'O O', -- - 'XXX', -- - ' O ' -- - } - assert.are.same('win', state_of_tic_tac_toe.gamestate(board)) - end) - it('finished game where x won via middle row victory', function() local board = { 'O ', --