mirror of
https://github.com/FunkinCrew/Funkin.git
synced 2024-11-14 19:25:16 -05:00
279277b18c
* Initial test suite * Fix some build warnings * Implemented working unit tests with coverage * Reduced some warnings * Fix a mac-specific issue * Add 2 additional unit test classes. * Multiple new unit tests * Some fixins * Remove auto-generated file * WIP on hiding ignored tests * Added list of debug hotkeys * Remove old website * Remove empty file * Add more unit tests * Fix bug where arrows would nudge BF * Fix bug where ctrl/alt would flash capsules * Fixed bug where bf-old easter egg broke * Remove duplicate lines * More test-related stuff * Some code cleanup * Add mocking and a test assets folder * More TESTS! * Update Hmm... * Update artist on Monster * More minor fixes to individual functions * 1.38% unit test coverage! * Even more tests? :O * More unit test work * Rework migration for BaseRegistry * gameover fix * Fix an issue with Lime * Fix issues with version parsing on data files * 100 total unit tests! * Added even MORE unit tests! * Additional test tweaks :3 * Fixed tests on windows by updating libraries. * A bunch of smaller syntax tweaks. * New crash handler catches and logs critical errors! * Chart editor now has null safety enabled. * Null safety on all tests * New Level data test * Generate proper code coverage reports! * Disable null safety on ChartEditorState for unit testing * Update openfl to use latest fixes for crash reporting * Added unit test to Github Workflow * Updated unit tests to compile with null safety enabled by inlining assertions. * Added coverage gutters as a recommended extension * Impreovements to tests involving exceptions * Disable a few incomplete tests. * Add scripts for building unit coverage reports on linux --------- Co-authored-by: Cameron Taylor <cameron.taylor.ninja@gmail.com>
94 lines
2.9 KiB
Haxe
94 lines
2.9 KiB
Haxe
package;
|
|
|
|
import openfl.Lib;
|
|
import flixel.FlxGame;
|
|
import flixel.FlxState;
|
|
import massive.munit.TestRunner;
|
|
import massive.munit.client.HTTPClient;
|
|
import massive.munit.client.SummaryReportClient;
|
|
import funkin.util.logging.CrashHandler;
|
|
import funkin.util.FileUtil;
|
|
|
|
/**
|
|
* Auto generated Test Application.
|
|
* Refer to munit command line tool for more information (haxelib run munit)
|
|
*/
|
|
@:nullSafety
|
|
class TestMain
|
|
{
|
|
/**
|
|
* If true, include a report with each ignored test and their descriptions.
|
|
*/
|
|
static final INCLUDE_IGNORED_REPORT:Bool = false;
|
|
|
|
static final COVERAGE_FOLDER:String = "../../../report";
|
|
|
|
static function main()
|
|
{
|
|
new TestMain();
|
|
}
|
|
|
|
public function new()
|
|
{
|
|
try
|
|
{
|
|
CrashHandler.initialize();
|
|
|
|
// Flixel was not designed for unit testing so we can only have one instance for now.
|
|
Lib.current.stage.addChild(new FlxGame(640, 480, FlxState, 60, 60, true));
|
|
|
|
var suites = new Array<Class<massive.munit.TestSuite>>();
|
|
suites.push(TestSuite);
|
|
|
|
#if MCOVER
|
|
// Print individual test results alongside coverage results for each test class,
|
|
// as well as a final coverage report for the entire test suite.
|
|
var innerClient = new massive.munit.client.RichPrintClient(INCLUDE_IGNORED_REPORT);
|
|
var client = new mcover.coverage.munit.client.MCoverPrintClient(innerClient);
|
|
// Print final test results alongside detailed coverage results for the test suite.
|
|
var httpClient = new HTTPClient(new mcover.coverage.munit.client.MCoverSummaryReportClient());
|
|
// NOTE: You can also create a custom ICoverageTestResultClient implementation
|
|
|
|
// Output coverage in LCOV format.
|
|
FileUtil.createDirIfNotExists(COVERAGE_FOLDER);
|
|
mcover.coverage.MCoverage.getLogger().addClient(new mcover.coverage.client.LcovPrintClient("Funkin' Coverage Report", '${COVERAGE_FOLDER}/lcov.info'));
|
|
#else
|
|
// Print individual test results.
|
|
var client = new massive.munit.client.RichPrintClient(INCLUDE_IGNORED_REPORT);
|
|
// Print final test suite results.
|
|
var httpClient = new HTTPClient(new SummaryReportClient());
|
|
#end
|
|
|
|
var runner = new TestRunner(client);
|
|
runner.addResultClient(httpClient);
|
|
|
|
runner.completionHandler = completionHandler;
|
|
runner.run(suites);
|
|
}
|
|
catch (e)
|
|
{
|
|
trace('UNCAUGHT EXCEPTION');
|
|
trace(e);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* updates the background color and closes the current browser
|
|
* for flash and html targets (useful for continuos integration servers)
|
|
*/
|
|
function completionHandler(successful:Bool):Void
|
|
{
|
|
try
|
|
{
|
|
#if flash
|
|
openfl.external.ExternalInterface.call("testResult", successful);
|
|
#elseif js
|
|
js.Lib.eval("testResult(" + successful + ");");
|
|
#elseif sys
|
|
Sys.exit(successful ? 0 : 1);
|
|
#end
|
|
}
|
|
// if run from outside browser can get error which we can ignore
|
|
catch (e:Dynamic) {}
|
|
}
|
|
}
|