Repository navigation
make check-windows fails and no test file under windows/ or ui/ can be compiled #59
Description
make check-windows fails its second line on master, and no test file under
windows/ or ui/ can be compiled at all. This is independent of the
chart.v type-inference breakage; I will report that separately.
What happens
$ make check-windows
$ v -enable-globals -os windows -check windows/ui_windows_test.v
windows/ui_windows_test.v:23:36: error: unknown type `ui2.KeyCode`
23 | assert windows_virtual_key(.left) == .left
windows/ui_windows_test.v:30:30: error: unknown type `ui2.Kind`
30 | assert windows_widget_kind(.screen) == .screen
...
windows/ui_windows_test.v:344:3: error: unknown function: menu_update_window
windows/ui_windows_test.v:356:10: error: unknown function: native_window_handle
Both lines fail, the first because of chart.v (reported separately) and the
second as described here. Reproduced on a clean ce4af81 with the official
0.5.2 release binaries that ci.yml pins.
Cause
V resolves a module's root directory from the directory of the input file, not
from v.mod. ui2's v.mod declares:
Module {
name: 'ui2'
subdirs: ['ui', 'appkit', 'uikit', 'windows', 'linux']
}but that does not bring the sibling directories into the compilation when the
input file is inside one of them. So:
- a test under
ui/compilesui/*.vand cannot seewindows/*.v— hence
unknown function: menu_win32_set_menu_barinui/menu_windows.c.v, which
calls intowindows/menu_windows.v; - a test under
windows/compileswindows/*.vand cannot seeui/*.v—
hence everyunknown type ui2.KeyCode/ui2.Kind/ui2.Elementabove.
Pointing at the module root instead does work:
$ v -enable-globals -shared -os windows -check . # whole module, all directories
and a test file placed at the repository root sees both sides at once. That is
why the tests in #54–#57 live in embed_test.v and menu_tray_test.v at the
root rather than beside the code.
Affected files
Every *_test.v under a subdirectory:
ui/menu_test.v— compiles on-os linux/-os android, fails on
-os windowsbecauseui/menu_windows.c.vcalls intowindows/windows/ui_windows_test.v— fails on every hostui/ui_custom_test.v— fails on every host, and separately does not parse on
0.5.2 at all:map[string]bool{ 'field': true }(line 44 onmaster) is
rejected with explicitmapinitialization does not support parameters
Note that ci.yml only runs ui/vml_menu_test.v, ui/ui_scroll_immediate_test.v
and examples/build_examples.vsh, which is why this has gone unnoticed: CI
never compiles windows/ui_windows_test.v or ui/menu_test.v, and make test
(v test .) sweeps all 138 test files including the macOS-only ones, so it is
not usable as a single green/red signal on Windows either.
Options
I don't have a strong opinion on which is right, and this is the maintainer's
call. Some possibilities:
- Move the affected test files to the module root, where they compile. This is
what Add native_window_handle for embedders, publish real NSWindow on macOS #54–Cover vails menu and tray scenarios on the Windows backend #57 do for their own tests. - Add the subdirectories to the module's compilation another way, if V has a
mechanism I have not found. - Accept it and only run these through
-checkfrom the root, as
make check-windowsalready tries to do for its first line.
Whichever way it goes, make check-windows should be green before it can be
used as a gate. I can help with any of these — just say which.
Activity