Mirror for Friday Night Funkin
at main 94 lines 3.0 kB view raw
1package; 2 3import openfl.Lib; 4import flixel.FlxGame; 5import flixel.FlxState; 6import massive.munit.TestRunner; 7import massive.munit.client.HTTPClient; 8import massive.munit.client.SummaryReportClient; 9import funkin.util.logging.CrashHandler; 10import funkin.util.FileUtil; 11 12/** 13 * Auto generated Test Application. 14 * Refer to munit command line tool for more information (haxelib run munit) 15 */ 16@:nullSafety 17class TestMain 18{ 19 /** 20 * If true, include a report with each ignored test and their descriptions. 21 */ 22 static final INCLUDE_IGNORED_REPORT:Bool = false; 23 24 static final COVERAGE_FOLDER:String = "../../../report"; 25 26 static function main() 27 { 28 new TestMain(); 29 } 30 31 public function new() 32 { 33 try 34 { 35 CrashHandler.initialize(); 36 37 // Flixel was not designed for unit testing so we can only have one instance for now. 38 Lib.current.stage.addChild(new FlxGame(640, 480, FlxState, 60, 60, true)); 39 40 var suites = new Array<Class<massive.munit.TestSuite>>(); 41 suites.push(TestSuite); 42 43 #if MCOVER 44 // Print individual test results alongside coverage results for each test class, 45 // as well as a final coverage report for the entire test suite. 46 var innerClient = new massive.munit.client.RichPrintClient(INCLUDE_IGNORED_REPORT); 47 var client = new mcover.coverage.munit.client.MCoverPrintClient(innerClient); 48 // Print final test results alongside detailed coverage results for the test suite. 49 var httpClient = new HTTPClient(new mcover.coverage.munit.client.MCoverSummaryReportClient()); 50 // NOTE: You can also create a custom ICoverageTestResultClient implementation 51 52 // Output coverage in LCOV format. 53 FileUtil.createDirIfNotExists(COVERAGE_FOLDER); 54 mcover.coverage.MCoverage.getLogger().addClient(new mcover.coverage.client.LcovPrintClient("Funkin' Coverage Report", '${COVERAGE_FOLDER}/lcov.info')); 55 #else 56 // Print individual test results. 57 var client = new massive.munit.client.RichPrintClient(INCLUDE_IGNORED_REPORT); 58 // Print final test suite results. 59 var httpClient = new HTTPClient(new SummaryReportClient()); 60 #end 61 62 var runner = new TestRunner(client); 63 runner.addResultClient(httpClient); 64 65 runner.completionHandler = completionHandler; 66 runner.run(suites); 67 } 68 catch (e) 69 { 70 trace('UNCAUGHT EXCEPTION'); 71 trace(e); 72 } 73 } 74 75 /** 76 * updates the background color and closes the current browser 77 * for flash and html targets (useful for continuos integration servers) 78 */ 79 function completionHandler(successful:Bool):Void 80 { 81 try 82 { 83 #if flash 84 openfl.external.ExternalInterface.call("testResult", successful); 85 #elseif js 86 js.Lib.eval("testResult(" + successful + ");"); 87 #elseif sys 88 Sys.exit(successful ? 0 : 1); 89 #end 90 } 91 // if run from outside browser can get error which we can ignore 92 catch (e:Dynamic) {} 93 } 94}