Merge pull request #3625 from myk002/myk_tests

re-enable unit tests
develop
Myk 2023-08-04 12:20:11 -07:00 committed by GitHub
commit f2a56cc1e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
28 changed files with 65 additions and 21 deletions

@ -379,7 +379,7 @@ local function load_tests(file, tests)
dfhack.printerr('Skipping tests for unspecified target in ' .. file)
return true -- TODO: change to false once existing tests have targets specified
end
local targets = type(env.config.targets) == table and env.config.targets or {env.config.targets}
local targets = type(env.config.target) == 'table' and env.config.target or {env.config.target}
for _,target in ipairs(targets) do
if target == 'core' then goto continue end
if type(target) ~= 'string' or not helpdb.is_entry(target) or

@ -992,7 +992,7 @@ function Scrollbar:onInput(keys)
return false
end
if self.parent_view:getMousePos() then
if self.parent_view and self.parent_view:getMousePos() then
if keys.CONTEXT_SCROLL_UP then
self.on_scroll('up_small')
return true

@ -789,7 +789,7 @@ function ls(filter_str, skip_tags, show_dev_commands, exclude_strs)
end
if not show_dev_commands then
local dev_tags = {'dev', 'unavailable'}
if dfhack.getHideArmokTools() then
if filter_str ~= 'armok' and dfhack.getHideArmokTools() then
table.insert(dev_tags, 'armok')
end
table.insert(excludes, {tag=dev_tags})

@ -1,4 +1,4 @@
config.targets = 'core'
config.target = 'core'
local function clean_path(p)
-- todo: replace with dfhack.filesystem call?

@ -1,4 +1,4 @@
config.targets = 'core'
config.target = 'core'
function test.toSearchNormalized()
expect.eq(dfhack.toSearchNormalized(''), '')

@ -1,3 +1,5 @@
config.target = 'core'
function test.getCurViewscreen()
local scr = dfhack.gui.getCurViewscreen()
local scr2 = df.global.gview.view
@ -18,7 +20,7 @@ function test.getViewscreenByType()
local bad_type = df.viewscreen_titlest
if scr._type == bad_type then
bad_type = df.viewscreen_optionst
bad_type = df.viewscreen_dwarfmodest
end
local scr_bad = dfhack.gui.getViewscreenByType(bad_type)
expect.eq(scr_bad, nil)

@ -1,3 +1,5 @@
config.target = 'core'
local argparse = require('argparse')
local guidm = require('gui.dwarfmode')

@ -1,3 +1,5 @@
config.target = 'core'
local gui = require('gui')
function test.getKeyDisplay()
@ -10,6 +12,7 @@ end
function test.clear_pen()
expect.table_eq(gui.CLEAR_PEN, {
tile = df.global.init.texpos_border_interior,
ch = string.byte(' '),
fg = COLOR_BLACK,
bg = COLOR_BLACK,

@ -1,3 +1,5 @@
--config.target = 'core'
local gui = require('gui')
local function send_keys(...)
local keys = {...}

@ -1,3 +1,5 @@
config.target = 'core'
local widgets = require('gui.widgets')
function test.editfield_cursor()
@ -20,18 +22,18 @@ function test.editfield_cursor()
expect.eq('ones two threes', e.text)
expect.eq(5, e.cursor)
e:onInput{CURSOR_LEFT=true}
e:onInput{KEYBOARD_CURSOR_LEFT=true}
expect.eq(4, e.cursor)
e:onInput{CURSOR_RIGHT=true}
e:onInput{KEYBOARD_CURSOR_RIGHT=true}
expect.eq(5, e.cursor)
e:onInput{A_CARE_MOVE_W=true}
expect.eq(1, e.cursor, 'interpret alt-left as home')
e:onInput{A_MOVE_E_DOWN=true}
expect.eq(6, e.cursor, 'interpret ctrl-right as goto beginning of next word')
e:onInput{A_CARE_MOVE_E=true}
expect.eq(16, e.cursor, 'interpret alt-right as end')
e:onInput{A_MOVE_W_DOWN=true}
expect.eq(9, e.cursor, 'interpret ctrl-left as goto end of previous word')
-- e:onInput{A_CARE_MOVE_W=true}
-- expect.eq(1, e.cursor, 'interpret alt-left as home') -- uncomment when we have a home key
e:onInput{CUSTOM_CTRL_F=true}
expect.eq(6, e.cursor, 'interpret Ctrl-f as goto beginning of next word')
e:onInput{CUSTOM_CTRL_E=true}
expect.eq(16, e.cursor, 'interpret Ctrl-e as end')
e:onInput{CUSTOM_CTRL_B=true}
expect.eq(9, e.cursor, 'interpret Ctrl-b as goto end of previous word')
end
function test.editfield_click()

@ -1,3 +1,5 @@
config.target = 'core'
local gui = require('gui')
local widgets = require('gui.widgets')

@ -1,3 +1,5 @@
config.target = 'core'
local gui = require('gui')
local widgets = require('gui.widgets')
@ -10,7 +12,7 @@ function test.update()
expect.eq(1, s.elems_per_page)
expect.eq(1, s.num_elems)
expect.eq(0, s.bar_offset)
expect.eq(1, s.bar_height)
expect.eq(2, s.bar_height)
-- top_elem, elems_per_page, num_elems
s:update(1, 10, 0)
@ -18,7 +20,7 @@ function test.update()
expect.eq(10, s.elems_per_page)
expect.eq(0, s.num_elems)
expect.eq(0, s.bar_offset)
expect.eq(1, s.bar_height)
expect.eq(2, s.bar_height)
-- first 10 of 50 shown
s:update(1, 10, 50)

@ -1,3 +1,5 @@
config.target = 'core'
local widgets = require('gui.widgets')
function test.hotkeylabel_click()

@ -1,3 +1,5 @@
config.target = 'core'
local h = require('helpdb')
local mock_plugin_db = {

@ -1,5 +1,7 @@
-- tests misc functions added by dfhack.lua
config.target = 'core'
function test.safe_pairs()
for k,v in safe_pairs(nil) do
expect.fail('nil should not be iterable')

@ -1,5 +1,7 @@
-- tests print-related functions added by dfhack.lua
config.target = 'core'
local dfhack = dfhack
local mock_print = mock.func()

@ -1,5 +1,7 @@
-- tests string functions added by dfhack.lua
config.target = 'core'
function test.startswith()
expect.true_(('abcd'):startswith(''))
expect.true_(('abcd'):startswith('abc'))

@ -1,3 +1,5 @@
config.target = 'core'
local expect_raw = require('test_util.expect')
function test.str_find()

@ -1,3 +1,5 @@
config.target = 'core'
local mock = require('test_util.mock')
local test_table = {

@ -1,3 +1,5 @@
config.target = 'core'
local utils = require 'utils'
function test.OrderedTable()
@ -102,7 +104,7 @@ function test.df_expr_to_ref()
expect.eq(df.reinterpret_cast(df.world, utils.df_expr_to_ref('unit[0]').value), df.global.world)
expect.eq(utils.df_expr_to_ref('unit[1]'), utils.df_expr_to_ref('unit.1'))
expect.eq(df.reinterpret_cast(df.ui, utils.df_expr_to_ref('unit[1]').value), df.global.plotinfo)
expect.eq(df.reinterpret_cast(df.plotinfost, utils.df_expr_to_ref('unit[1]').value), df.global.plotinfo)
expect.error_match('index out of bounds', function() utils.df_expr_to_ref('unit.2') end)
expect.error_match('index out of bounds', function() utils.df_expr_to_ref('unit[2]') end)

@ -1,4 +1,5 @@
config.mode = 'title'
config.target = 'core'
local function clean_vec(vec)
while #vec > 0 do

@ -1,6 +1,8 @@
config.target = 'core'
function test.overlappingGlobals()
local globals = {}
for name, _ in pairs(df.global) do
for name in pairs(df.global) do
local gvar = df.global:_field(name)
local size, addr = gvar:sizeof()
table.insert(globals, {

@ -1,3 +1,5 @@
config.target = 'core'
function test.index_name()
for _, k in ipairs(df.units_other_id) do
expect.eq(df.global.world.units.other[k]._kind, 'container')

@ -1,3 +1,5 @@
config.target = 'core'
utils = require('utils')
function with_temp_ref(...)

@ -1,3 +1,5 @@
config.target = 'core'
function test.get()
dfhack.with_temp_object(df.unit:new(), function(unit)
expect.eq(unit:_field('hist_figure_id').ref_target, df.historical_figure)

@ -1,3 +1,5 @@
config.target = 'core'
function test.struct()
expect.eq(df.coord._kind, 'struct-type')
expect.eq(tostring(df.coord), '<type: coord>')

@ -1,3 +1,5 @@
config.target = 'core'
local utils = require('utils')
function test.unit_action_fields()

@ -1,4 +1,4 @@
config.targets = 'core'
config.target = 'core'
function test.internal_in_test()
expect.true_(dfhack.internal.IN_TEST)