<commit_before>import haxe.Json;
import sys.io.File;
import sys.io.FileOutput;
import checks.CheckTestCase;
import token.TokenTreeBuilderTest;
import mcover.coverage.client.PrintClient;
import mcover.coverage.data.CoverageResult;
import mcover.coverage.MCoverage;

using StringTools;

class TestMain {

	public function new() {
		CompileTime.importPackage("checks");

		var runner = new haxe.unit.TestRunner();
		runner.add(new TokenTreeBuilderTest());

		var tests = CompileTime.getAllClasses(CheckTestCase);
		for (testClass in tests) runner.add(Type.createInstance(testClass, []));

		var success = runner.run();
		setupCoverageReport();
		Sys.exit(success ? 0 : 1);
	}

	static function setupCoverageReport() {
		var client:PrintClient = new PrintClient();
		var logger = MCoverage.getLogger();
		logger.addClient(client);
		logger.report();

		var report = {coverage: {}};
		var classes = logger.coverage.getClasses();
		for (cls in classes) {
			var results:CoverageResult = cls.getResults();
			//trace(results);
			var c = cls.name.replace(".", "/") + ".hx";
			Reflect.setField(report.coverage, c, [null, results.l, results.lc, (results.l - results.lc), results.lp, results.b, results.m, cls.getPercentage()]);
			Sys.println(cls.name + ": " + cls.getPercentage() + "%");
		}

		//To test ci integration
		var file:FileOutput = File.write("coverage.json");
		file.writeString(Json.stringify(report));
		file.close();
	}

	static function main() {
		new TestMain();
	}
}<commit_msg>another coverage test<commit_after>import haxe.Json;
import sys.io.File;
import sys.io.FileOutput;
import checks.CheckTestCase;
import token.TokenTreeBuilderTest;
import mcover.coverage.client.PrintClient;
import mcover.coverage.data.CoverageResult;
import mcover.coverage.MCoverage;

using StringTools;

class TestMain {

	public function new() {
		CompileTime.importPackage("checks");

		var runner = new haxe.unit.TestRunner();
		runner.add(new TokenTreeBuilderTest());

		var tests = CompileTime.getAllClasses(CheckTestCase);
		for (testClass in tests) runner.add(Type.createInstance(testClass, []));

		var success = runner.run();
		setupCoverageReport();
		Sys.exit(success ? 0 : 1);
	}

	static function setupCoverageReport() {
		var client:PrintClient = new PrintClient();
		var logger = MCoverage.getLogger();
		logger.addClient(client);
		logger.report();

		var report = {coverage: {}};
		var classes = logger.coverage.getClasses();
		for (cls in classes) {
			var results:CoverageResult = cls.getResults();
			var coverageData = [null];
			var ms = cls.getMissingStatements();
			for (s in ms) {
				if (s.lines != null && s.lines.length > 0) coverageData[s.lines[s.lines.length - 1]] = 0;
			}
			for (i in 1 ... results.l) {
				if (coverageData[i] == null) coverageData[i] = 1;
			}

			//trace(cls.name + ": " + cls.itemCount + " : " + cls.getMissingStatements());
			var c = cls.name.replace(".", "/") + ".hx";
			Reflect.setField(report.coverage, c, coverageData);
		}

		//To test ci integration
		var file:FileOutput = File.write("coverage.json");
		file.writeString(Json.stringify(report));
		file.close();
	}

	static function main() {
		new TestMain();
	}
}
{'fraction_non_alphanumeric': 0.1498422712933754, 'fraction_numerical': 0.0028391167192429023, 'mean_word_length': 4.320469798657718, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '607812', 'n_tokens_mistral': 1147, 'n_tokens_neox': 1033, 'n_words': 226}