From e9efa6c9617c3712f01b31c085a2146e6529ae76 Mon Sep 17 00:00:00 2001 From: lethosor Date: Tue, 23 Mar 2021 21:24:57 -0400 Subject: [PATCH 1/3] Update xml, fix + improve robustness of unions.lua unit tests - unit_action_fields(): handled primitive union members correctly - unit_action_type(): added messages to make failures easier to diagnose - Also removed redundant checks that effectively checked that `enum.attrs[k] == enum.attrs[v]` - this is out of scope of union tests --- library/xml | 2 +- test/structures/unions.lua | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/library/xml b/library/xml index ad1c98cf8..9a936001d 160000 --- a/library/xml +++ b/library/xml @@ -1 +1 @@ -Subproject commit ad1c98cf852936694300eaf8d69e91c10b7ea57f +Subproject commit 9a936001d9095681d5cb6225eb18bfe0ed2bcf28 diff --git a/test/structures/unions.lua b/test/structures/unions.lua index 12de85066..be469da6f 100644 --- a/test/structures/unions.lua +++ b/test/structures/unions.lua @@ -3,7 +3,7 @@ local utils = require('utils') function test.unit_action_fields() dfhack.with_temp_object(df.unit_action:new(), function(action) for k in pairs(action.data) do - expect.eq(utils.addressof(action.data.raw_data), utils.addressof(action.data[k]), + expect.eq(utils.addressof(action.data.raw_data), utils.addressof(action.data:_field(k)), 'address of ' .. k .. ' does not match') end end) @@ -11,9 +11,12 @@ end function test.unit_action_type() dfhack.with_temp_object(df.unit_action:new(), function(action) - for k, v in ipairs(df.unit_action_type) do - expect.true_(action.data[df.unit_action_type.attrs[k].tag]) - expect.true_(action.data[df.unit_action_type.attrs[v].tag]) + for index, name in ipairs(df.unit_action_type) do + expect.true_(name, "unit_action_type entry without name: " .. tostring(index)) + local tag = df.unit_action_type.attrs[name].tag + expect.true_(tag, "unit_action_type entry missing tag: name=" .. name) + expect.pairs_contains(action.data, tag, + "unit_action_type entry missing from unit_action.data: name=" .. name) end end) end From 10a7455e8500af1603c26d21641ba7bc41e0dfd5 Mon Sep 17 00:00:00 2001 From: lethosor Date: Tue, 23 Mar 2021 21:28:14 -0400 Subject: [PATCH 2/3] Update scripts --- scripts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts b/scripts index 8200539a8..c74d5ebee 160000 --- a/scripts +++ b/scripts @@ -1 +1 @@ -Subproject commit 8200539a851623bfc8a049390633a5fa3cc55b84 +Subproject commit c74d5ebeee50e1f14758d4c389b3221ea4c556f6 From 9a29e5f1ce9a133972a79670f798dc25bdf4131a Mon Sep 17 00:00:00 2001 From: lethosor Date: Tue, 23 Mar 2021 22:11:48 -0400 Subject: [PATCH 3/3] Make "test file failed to load" errors more obvious, and make run-tests.py fail These errors could previously go undetected, since they were easy to miss at the end of the output and did not cause run-tests.py to fail. This change adds a `*` pseudo-entry to test_status.json, which is set to "failed" if any tests failed *or* failed to load. This avoids the need to change run-tests.py, which is cached on Buildmaster. See #1815 --- test/main.lua | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/test/main.lua b/test/main.lua index 6d3d09653..ac09e695e 100644 --- a/test/main.lua +++ b/test/main.lua @@ -455,10 +455,25 @@ local function run_tests(tests, status, counts) save_test_status(status) end + local function print_summary_line(ok, message) + local print_fn = print + if not ok then + status['*'] = TestStatus.FAILED + print_fn = dfhack.printerr + end + print_fn(message) + end + + status['*'] = status['*'] or TestStatus.PASSED print('\nTest summary:') - print(('%d/%d tests passed'):format(counts.tests_ok, counts.tests)) - print(('%d/%d checks passed'):format(counts.checks_ok, counts.checks)) - print(('%d test files failed to load'):format(counts.file_errors)) + print_summary_line(counts.tests_ok == counts.tests, + ('%d/%d tests passed'):format(counts.tests_ok, counts.tests)) + print_summary_line(counts.checks_ok == counts.checks, + ('%d/%d checks passed'):format(counts.checks_ok, counts.checks)) + print_summary_line(counts.file_errors == 0, + ('%d test files failed to load'):format(counts.file_errors)) + + save_test_status(status) end local function main(args)