Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--coverage breaks unit tests on HaxeFlixel project #138

Open
nightblade9 opened this issue Oct 14, 2017 · 5 comments
Open

--coverage breaks unit tests on HaxeFlixel project #138

nightblade9 opened this issue Oct 14, 2017 · 5 comments

Comments

@nightblade9
Copy link

nightblade9 commented Oct 14, 2017

TL;DR: Running haxelib run munit test works, but running haxelib run munit test --coverage breaks with an odd-looking HaxeFlixel error ( Class<flixel.FlxG> has no field keys).

Here's a specific version of a project I'm working on. The project is a mix of HaxeFlixel and non-HaxeFlixel code, while the tests don't touch HaxeFlixel. Thus, when I run haxelib run munit test, it compiles and runs all the tests; when I run haxelib run munit test --coverage, it fails with this error:

Massive Unit - Copyright 2017 Massive Interactive. Version 2.1.2
   haxe -main TestMain -lib munit -lib polygonal-core -lib haxesharp -lib helix -lib flixel -cp src -cp test --remap flash:openfl -neko build/neko_test.n -lib mcover -D MCOVER --macro mcover.MCover.coverage([''],['src'],[''])
HaxeWrapper.hx:73: /home/travis/haxe/lib/helix/git/src/helix/core/HelixState.hx:42: characters 15-24 : Class<flixel.FlxG> has no field keys
HaxeWrapper.hx:73: /home/travis/haxe/lib/helix/git/src/helix/core/HelixState.hx:47: characters 15-24 : Class<flixel.FlxG> has no field keys
Error: Error compiling hxml for neko
Target neko /home/travis/build/nightblade9/eman-adventures/build/neko_test.n
The command "haxelib run munit test -coverage -result-exit-code" exited with 1.

The difference --coverage makes is the addition of -lib mcover -D MCOVER --macro mcover.MCover.coverage([''],['src'],['']), which I suspect is causing the problem.

Here's a build that fails with this error.

I'm pretty sure this is not a HaxeFlixel bug, or a bug in my code, because I can compile and run the game, and compile and run the tests (without --coverage). It might be a bug in my config somewhere.

test.hxml:

## Neko
-main TestMain
-lib munit
-lib polygonal-core
-lib haxesharp
-lib helix
-lib flixel

-cp src
-cp test

--remap flash:openfl

-neko build/neko_test.n

I'm currently working around this by removing --coverage from my test execution, which works, but isn't ideal.

@Gama11 if you can confirm that this is not some sort of known issue on the HaxeFlixel side, that would be really helpful.

  • haxeflixel 4.3.0
  • munit 2.1.2
@nightblade9 nightblade9 changed the title --coverage breaks HaxeFlixel project --coverage breaks unit tests on HaxeFlixel project Oct 14, 2017
@Gama11
Copy link
Contributor

Gama11 commented Oct 14, 2017

Class<flixel.FlxG> has no field keys

FLX_KEYBOARD is likely not defined, because Flixel's initialization macro isn't being called. Try adding this to your hxml:

--macro flixel.system.macros.FlxDefines.run()

@nightblade9
Copy link
Author

@Gama11 that seems to work. The compiler error disappears, but a new one appears:

HaxeWrapper.hx:73: D:\HaxeToolkit\haxe\lib\flixel/4,3,0/flixel/input/gamepad/FlxGamepadManager.hx:419: characters 46-59 : Type not found : Joy
stickEvent

Also, it's not clear why I don't need this when running the tests without --coverage.

@Gama11
Copy link
Contributor

Gama11 commented Oct 14, 2017

Sounds like FLX_GAMEINPUT_API isn't being defined by the init macro.

https://github.com/HaxeFlixel/flixel/blob/4.3.0/flixel/system/macros/FlxDefines.hx#L161

Maybe try adding -D openfl_next?

@nightblade9
Copy link
Author

@Gama11 looks like that fixed it. Thanks!

Does anyone have any idea why this is required for --coverage but works fine without it?

nightblade9 added a commit to nightblade9/eman-adventures-haxe that referenced this issue Oct 14, 2017
@bendmorris
Copy link

Does anyone have any idea why this is required for --coverage but works fine without it?

--coverage runs a macro which includes files in the package you're measuring coverage for. They may not have been included when just running the tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants