2023-08-22 08:27:30 +00:00
|
|
|
package;
|
|
|
|
|
|
|
|
import openfl.Lib;
|
|
|
|
import flixel.FlxGame;
|
|
|
|
import flixel.FlxState;
|
|
|
|
import massive.munit.TestRunner;
|
|
|
|
import massive.munit.client.HTTPClient;
|
|
|
|
import massive.munit.client.SummaryReportClient;
|
2023-08-30 22:31:59 +00:00
|
|
|
import funkin.util.logging.CrashHandler;
|
|
|
|
import funkin.util.FileUtil;
|
2023-08-22 08:27:30 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Auto generated Test Application.
|
|
|
|
* Refer to munit command line tool for more information (haxelib run munit)
|
|
|
|
*/
|
2023-08-30 22:31:59 +00:00
|
|
|
@:nullSafety
|
2023-08-22 08:27:30 +00:00
|
|
|
class TestMain
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* If true, include a report with each ignored test and their descriptions.
|
|
|
|
*/
|
|
|
|
static final INCLUDE_IGNORED_REPORT:Bool = false;
|
|
|
|
|
2023-08-30 22:31:59 +00:00
|
|
|
static final COVERAGE_FOLDER:String = "../../../report";
|
|
|
|
|
2023-08-22 08:27:30 +00:00
|
|
|
static function main()
|
|
|
|
{
|
|
|
|
new TestMain();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function new()
|
|
|
|
{
|
2023-08-30 22:31:59 +00:00
|
|
|
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));
|
2023-08-22 08:27:30 +00:00
|
|
|
|
2023-08-30 22:31:59 +00:00
|
|
|
var suites = new Array<Class<massive.munit.TestSuite>>();
|
|
|
|
suites.push(TestSuite);
|
2023-08-22 08:27:30 +00:00
|
|
|
|
2023-08-30 22:31:59 +00:00
|
|
|
#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
|
2023-08-22 08:27:30 +00:00
|
|
|
|
2023-08-30 22:31:59 +00:00
|
|
|
// 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
|
2023-08-22 08:27:30 +00:00
|
|
|
|
2023-08-30 22:31:59 +00:00
|
|
|
var runner = new TestRunner(client);
|
|
|
|
runner.addResultClient(httpClient);
|
2023-08-22 08:27:30 +00:00
|
|
|
|
2023-08-30 22:31:59 +00:00
|
|
|
runner.completionHandler = completionHandler;
|
|
|
|
runner.run(suites);
|
|
|
|
}
|
|
|
|
catch (e)
|
|
|
|
{
|
|
|
|
trace('UNCAUGHT EXCEPTION');
|
|
|
|
trace(e);
|
|
|
|
}
|
2023-08-22 08:27:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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) {}
|
|
|
|
}
|
|
|
|
}
|