diff --git a/.github/workflows/formatter.yml b/.github/workflows/formatter.yml index ff4153fc..421ccfd4 100644 --- a/.github/workflows/formatter.yml +++ b/.github/workflows/formatter.yml @@ -14,7 +14,7 @@ jobs: build: strategy: matrix: - haxe-version: ['4.3.3', 'nightly'] + haxe-version: ['4.3.4', 'nightly'] platform: [ubuntu-latest, macos-latest, windows-latest] runs-on: ${{ matrix.platform }} steps: @@ -50,11 +50,12 @@ jobs: run: npx haxe buildJava.hxml - name: Build JSON schema run: npx haxe buildSchema.hxml - - name: Run eval tests - if: (matrix.haxe-version == '4.3.3') - run: npx haxe -D codecov_json test.hxml + - name: Run eval tests (without coverage) + run: npx haxe test.hxml + - name: Run eval tests (with coverage) + run: npx haxe testCoverage.hxml - name: Run Java tests - run: npx haxe -D codecov_json testJava.hxml + run: npx haxe testJava.hxml - name: Run Node version with --check run: node run.js -s . --check - name: Run Java version with --check @@ -73,5 +74,5 @@ jobs: # name: formatter.js # path: bin/formatter.js - name: Upload results to codecov - if: success() && matrix.platform == 'ubuntu-latest' && (matrix.haxe-version == '4.3.3') + if: success() && matrix.platform == 'ubuntu-latest' && (matrix.haxe-version == '4.3.4') run: bash <(curl -s https://codecov.io/bash) || echo "Codecov did not collect coverage reports" diff --git a/.haxerc b/.haxerc index 3ee99dd1..22c3a572 100644 --- a/.haxerc +++ b/.haxerc @@ -1,4 +1,4 @@ { - "version": "4.3.3", + "version": "4.3.4", "resolveLibs": "scoped" } \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index 8f54f446..3de4efd8 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -11,8 +11,5 @@ "schema", "test" ], - "haxe.importsSortOrder": "stdlib -> libs -> project", - "coverage-gutters.showLineCoverage": false, - "coverage-gutters.showRulerCoverage": false, - "coverage-gutters.partialHighlightDark": "rgba(120, 120, 120, 0.75)" + "haxe.importsSortOrder": "stdlib -> libs -> project" } diff --git a/CHANGELOG.md b/CHANGELOG.md index f425f87d..45a93194 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ ## dev branch / next version (1.x.x) +- Refactored unittests to work with utest library ([#679](https://github.com/HaxeCheckstyle/haxe-formatter/issues/679)) +- Removed munit library ([#679](https://github.com/HaxeCheckstyle/haxe-formatter/issues/679)) + ## version 1.16.0 (2024-02-10) - Added `wrapping.mapWrap`, fixes [#675](https://github.com/HaxeCheckstyle/haxe-formatter/issues/675) ([#677](https://github.com/HaxeCheckstyle/haxe-formatter/issues/677)) diff --git a/buildCommon.hxml b/buildCommon.hxml index a4e24679..2d3cd5c0 100644 --- a/buildCommon.hxml +++ b/buildCommon.hxml @@ -7,6 +7,7 @@ -dce full -D analyzer-optimize +-D haxe-next -cp src diff --git a/display.hxml b/display.hxml index df3d2642..b9ebb940 100644 --- a/display.hxml +++ b/display.hxml @@ -7,8 +7,7 @@ -lib hxparse -lib json2object -lib hxargs --lib mcover --lib munit -lib safety --lib test-adapter -lib instrument +-lib utest +-lib test-adapter diff --git a/haxe_libraries/mconsole.hxml b/haxe_libraries/mconsole.hxml deleted file mode 100644 index 993fd0f5..00000000 --- a/haxe_libraries/mconsole.hxml +++ /dev/null @@ -1,3 +0,0 @@ -# @install: lix --silent download "haxelib:/mconsole#1.6.0" into mconsole/1.6.0/haxelib --cp ${HAXE_LIBCACHE}/mconsole/1.6.0/haxelib/ --D mconsole=1.6.0 \ No newline at end of file diff --git a/haxe_libraries/mcover.hxml b/haxe_libraries/mcover.hxml deleted file mode 100644 index 6e520355..00000000 --- a/haxe_libraries/mcover.hxml +++ /dev/null @@ -1,3 +0,0 @@ -# @install: lix --silent download "gh://github.com/AlexHaxe/mcover#fdbdbc11938eabf068b40e30e8b8b16912f8da6c" into mcover/0.0.0/github/fdbdbc11938eabf068b40e30e8b8b16912f8da6c --cp ${HAXE_LIBCACHE}/mcover/0.0.0/github/fdbdbc11938eabf068b40e30e8b8b16912f8da6c/src --D mcover=0.0.0 \ No newline at end of file diff --git a/haxe_libraries/mlib.hxml b/haxe_libraries/mlib.hxml deleted file mode 100644 index a6d19592..00000000 --- a/haxe_libraries/mlib.hxml +++ /dev/null @@ -1,4 +0,0 @@ -# @install: lix --silent download "haxelib:/mlib#2.0.3" into mlib/2.0.3/haxelib -# @run: haxelib run-dir mlib ${HAXE_LIBCACHE}/mlib/2.0.3/haxelib --cp ${HAXE_LIBCACHE}/mlib/2.0.3/haxelib/ --D mlib=2.0.3 \ No newline at end of file diff --git a/haxe_libraries/munit.hxml b/haxe_libraries/munit.hxml deleted file mode 100644 index a9a00aeb..00000000 --- a/haxe_libraries/munit.hxml +++ /dev/null @@ -1,4 +0,0 @@ -# @install: lix --silent download "gh://github.com/AlexHaxe/MassiveUnit#81e9d431ac92ff1c81f72369dde5d582f8078fd5" into MassiveUnit/0.0.0/github/81e9d431ac92ff1c81f72369dde5d582f8078fd5 --lib mlib --cp ${HAXE_LIBCACHE}/MassiveUnit/0.0.0/github/81e9d431ac92ff1c81f72369dde5d582f8078fd5/src --D munit=2.3.5 diff --git a/haxe_libraries/test-adapter.hxml b/haxe_libraries/test-adapter.hxml index bf0c653c..2551a21a 100644 --- a/haxe_libraries/test-adapter.hxml +++ b/haxe_libraries/test-adapter.hxml @@ -1,5 +1,5 @@ -# @install: lix --silent download "haxelib:/test-adapter#2.0.6" into test-adapter/2.0.6/haxelib +# @install: lix --silent download "haxelib:/test-adapter#2.0.7" into test-adapter/2.0.7/haxelib -lib json2object --cp ${HAXE_LIBCACHE}/test-adapter/2.0.6/haxelib/ --D test-adapter=2.0.6 +-cp ${HAXE_LIBCACHE}/test-adapter/2.0.7/haxelib/ +-D test-adapter=2.0.7 --macro _testadapter.Macro.init() \ No newline at end of file diff --git a/haxe_libraries/utest.hxml b/haxe_libraries/utest.hxml new file mode 100644 index 00000000..f0776850 --- /dev/null +++ b/haxe_libraries/utest.hxml @@ -0,0 +1,4 @@ +# @install: lix --silent download "gh://github.com/haxe-utest/utest#bdb5fec4b8e77d9a3c079d9cfb108f29f153721a" into utest/2.0.0-alpha/github/bdb5fec4b8e77d9a3c079d9cfb108f29f153721a +-cp ${HAXE_LIBCACHE}/utest/2.0.0-alpha/github/bdb5fec4b8e77d9a3c079d9cfb108f29f153721a/src +-D utest=2.0.0-alpha +--macro utest.utils.Macro.importEnvSettings() diff --git a/test.hxml b/test.hxml index 2f7a0f6a..1f0fabcc 100644 --- a/test.hxml +++ b/test.hxml @@ -6,9 +6,7 @@ -lib hxparse -lib json2object -lib hxargs --lib mcover --lib munit -# -lib safety +-lib utest -lib test-adapter # -D debugLog @@ -16,6 +14,9 @@ # -D detailed_coverage # -D debugWrapping -D unittest +-D haxe-next -x TestMain ---macro mcover.MCover.coverage(['formatter'], ['src'], ['formatter.Cli']) +-D UTEST_PRINT_TESTS + +# -D dump=pretty diff --git a/test/GoldBaseTest.hx b/test/GoldBaseTest.hx index f0974dee..bea6bd02 100644 --- a/test/GoldBaseTest.hx +++ b/test/GoldBaseTest.hx @@ -3,12 +3,13 @@ import haxe.Template; import sys.io.File; import formatter.Formatter; import formatter.config.Config; -import massive.munit.Assert; import tokentree.TokenTreeBuilder.TokenTreeEntryPoint; class GoldBaseTest { var entryPoint:TokenTreeEntryPoint = null; + public function new() {} + function goldCheck(fileName:String, unformatted:String, goldCode:String, lineSeparator:String, ?configString:String, ?pos:PosInfos) { var config = new Config(); config.readConfigFromString(configString, "goldhxformat.json"); @@ -41,14 +42,16 @@ class GoldBaseTest { if (goldCode != formattedCode) { File.saveContent("test/formatter-result.txt", '$goldCode\n---\n$formattedCode'); } - Assert.areEqual(goldCode, formattedCode, pos); + Assert.equals(goldCode, formattedCode, pos); case Failure(errorMessage): if (isFailing) { + Assert.isTrue(isFailing, "testcase is expected to fail"); return; } Assert.fail(errorMessage, pos); case Disabled: if (isDisabled) { + Assert.isTrue(isDisabled, "testcase is disabled"); return; } Assert.fail("Formatting is disabled", pos); diff --git a/test/SelfTest.hx b/test/SelfTest.hx index c0a1f9af..f04e121f 100644 --- a/test/SelfTest.hx +++ b/test/SelfTest.hx @@ -1,14 +1,12 @@ import haxe.PosInfos; -import haxe.io.Bytes; import haxe.io.Path; -import massive.munit.Assert; -import formatter.Formatter; -import formatter.codedata.ParseFile; -import sys.io.File; import sys.FileSystem; +import sys.io.File; +import formatter.Formatter; + +class SelfTest implements ITest { + public function new() {} -class SelfTest { - @Test public function testSelfSrc() { var files:Array = collectAllFileNames("src"); for (file in files) { @@ -16,7 +14,6 @@ class SelfTest { } } - @Test public function testSelfTest() { var files:Array = collectAllFileNames("test"); for (file in files) { @@ -24,7 +21,6 @@ class SelfTest { } } - @Test public function testSelfSchema() { var files:Array = collectAllFileNames("schema"); for (file in files) { @@ -40,7 +36,7 @@ class SelfTest { if (code != formattedCode) { File.saveContent("test/formatter-result.txt", '$code\n---\n$formattedCode'); } - Assert.areEqual(code, formattedCode, 'Format failed for $fileName', pos); + Assert.equals(code, formattedCode, 'Format failed for $fileName', pos); case Failure(errorMessage): Assert.fail(errorMessage); case Disabled: diff --git a/test/TestCaseMacro.hx b/test/TestCaseMacro.hx index 5b2e8ad2..be3be8bb 100644 --- a/test/TestCaseMacro.hx +++ b/test/TestCaseMacro.hx @@ -1,19 +1,35 @@ import haxe.io.Path; import haxe.macro.Context; import haxe.macro.Expr; +import haxe.macro.PositionTools; import haxe.macro.Type.ClassType; import sys.FileSystem; import sys.io.File; +using haxe.macro.ExprTools; + class TestCaseMacro { #if macro public macro static function build(folder:String):Array { var fields:Array = Context.getBuildFields(); var cls:ClassType = Context.getLocalClass().get(); - if (!shouldApply(cls, ":testcases")) { return fields; } + cls.meta.add(":testcases", [], cls.pos); + + // revert the effects of implementing ITest interface + // + // unfortunately utest initialises before this macro runs, making our testcases invisible to utest. + // additionally test-adapter needs ITest interface to be able to collect position info of testcases + // which means we have to implement utests ITest interface to keep test explorer working. + // + // solution: + // we remove the field and meta info added by @:autoBuild (through ITest), add our testcases and + // then re-apply utest's test builder macro a second time + fields = fields.filter(f -> f.name != "__initializeUtest__"); + cls.meta.remove(":utestProcessed"); + var testCases:Array = collectAllFileNames(folder); var singleRun:TestSingleRun = new TestSingleRun(); for (testCase in testCases) { @@ -52,14 +68,29 @@ class TestCaseMacro { var unformatted:String = segments[1]; var gold:String = segments[2]; var fieldName:String = new haxe.io.Path(fileName).file; + fieldName = 'test_$fieldName'; var lineSeparator:String = detectLineSeparator(content); - return (macro class { - @Test + var field = (macro class { public function $fieldName() { goldCheck($v{fileName}, $v{unformatted}, $v{gold}, $v{lineSeparator}, $v{config}); }; }).fields[0]; + + // make assertion failures show up in testfile + field.pos = PositionTools.make({file: fileName, min: content.length, max: content.length}); + switch (field.kind) { + case FFun(f): + relocateExpr(f.expr, field.pos); + default: + } + + return field; + } + + static function relocateExpr(expr:Expr, pos:Position):Expr { + expr.pos = pos; + return expr.map((e) -> relocateExpr(e, pos)); } static function collectAllFileNames(path:String):Array { diff --git a/test/TestMain.hx b/test/TestMain.hx index 56904461..2417a8ee 100644 --- a/test/TestMain.hx +++ b/test/TestMain.hx @@ -1,42 +1,67 @@ -import haxe.EntryPoint; import sys.io.File; -import massive.munit.TestRunner; -import mcover.coverage.MCoverage; -import mcover.coverage.munit.client.MCoverPrintClient; -#if codecov_json -import mcover.coverage.client.CodecovJsonPrintClient; -#else -import mcover.coverage.client.LcovPrintClient; -#end +import formatter.EmptyLinesTest; +import formatter.FormatStatsTest; +import formatter.codedata.TokenListTest; +import testcases.EmptyLinesTestCases; +import testcases.ExpressionLevelTestCases; +import testcases.FormatRangeTestCases; +import testcases.IndentationTestCases; +import testcases.LineEndsTestCases; +import testcases.MissingTestCases; +import testcases.Other; +import testcases.SameLineTestCases; +import testcases.WhitespaceTestCases; +import testcases.WrappingTestCases; +import utest.Runner; +import utest.ui.text.DiagnosticsReport; class TestMain { public function new() { - var suites:Array> = [TestSuite]; - var client:MCoverPrintClient = new MCoverPrintClient(); - #if codecov_json - MCoverage.getLogger().addClient(new CodecovJsonPrintClient()); - #else - MCoverage.getLogger().addClient(new LcovPrintClient("Formatter Unittests")); - #end + var tests:Array<() -> ITest> = []; - #if detailed_coverage - client.includeClassAndPackageBreakdowns = true; - client.includeMissingBlocks = true; - #end - var runner = new TestRunner(client); - runner.completionHandler = completionHandler; - #if (neko || cpp || hl || java) - EntryPoint.addThread(function() { - while (true) { - Sys.sleep(1.0); + var singleRun:TestSingleRun = new TestSingleRun(); + if (!singleRun.isSingleRun()) { + tests.push(SelfTest.new); + tests.push(FormatStatsTest.new); + tests.push(TokenListTest.new); + tests.push(EmptyLinesTest.new); + } + + tests.push(cast EmptyLinesTestCases.new); + tests.push(cast ExpressionLevelTestCases.new); + tests.push(cast FormatRangeTestCases.new); + tests.push(cast IndentationTestCases.new); + tests.push(cast LineEndsTestCases.new); + tests.push(cast MissingTestCases.new); + tests.push(cast Other.new); + tests.push(cast SameLineTestCases.new); + tests.push(cast WhitespaceTestCases.new); + tests.push(cast WrappingTestCases.new); + + var runner:Runner = new Runner(); + + var failed = false; + runner.onProgress.add(r -> { + if (!r.result.allOk()) { + failed = true; } }); - #end - runner.run(suites); - EntryPoint.run(); + runner.onComplete.add(_ -> { + completionHandler(!failed); + }); + + new DiagnosticsReport(runner); + for (test in tests) { + runner.addCase(test()); + } + runner.run(); } function completionHandler(success:Bool) { + #if instrument + instrument.coverage.Coverage.endCoverage(); + #end + if (success) { File.saveContent("test/formatter-result.txt", "\n---\n"); } diff --git a/test/formatter/EmptyLinesTest.hx b/test/formatter/EmptyLinesTest.hx index 9a838b67..9c8f0ea1 100644 --- a/test/formatter/EmptyLinesTest.hx +++ b/test/formatter/EmptyLinesTest.hx @@ -2,12 +2,12 @@ package formatter; import haxe.PosInfos; import haxe.io.BytesBuffer; -import massive.munit.Assert; import formatter.Formatter; import formatter.config.Config; -class EmptyLinesTest { - @Test +class EmptyLinesTest implements ITest { + public function new() {} + public function testEmptyLines() { var lines:Array = (EmptyLinesText1 : String).split("\n").map(function(s) return s.trim()); var formatted:String = format(lines.join("\n")); @@ -34,7 +34,6 @@ class EmptyLinesTest { compareLines(lines, formattedLines); } - @Test public function testBOMEmptyLines() { var lines:Array = (EmptyLinesText1 : String).split("\n").map(function(s) return s.trim()); @@ -63,7 +62,6 @@ class EmptyLinesTest { compareLines(lines, formattedLines); } - @Test public function testCommentEmptyLines() { var lines:Array = (EmptyLinesText1 : String).split("\n").map(function(s) return s.trim()); lines.unshift("// äääääääääääääääääääööööööööööööööööööööüüüüüüüüüüüüüüüüüüüüüüßßßßßßßßßßßßßßßßßææææææææææææææææðððððððððððð€€€€€€€€€€€€€€¶¶¶¶¶¶¶¶¶¶¶đđđđđđđłł"); @@ -80,10 +78,10 @@ class EmptyLinesTest { } function compareLines(lines:Array, formattedLines:Array, ?pos:PosInfos) { - Assert.areEqual(lines.length, formattedLines.length, pos); + Assert.equals(lines.length, formattedLines.length, pos); var index:Int = 0; for (i in 0...lines.length) { - Assert.areEqual(lines[i], formattedLines[i], pos); + Assert.equals(lines[i], formattedLines[i], pos); } } diff --git a/test/formatter/FormatStatsTest.hx b/test/formatter/FormatStatsTest.hx index 5afe9ee2..12e4c2a8 100644 --- a/test/formatter/FormatStatsTest.hx +++ b/test/formatter/FormatStatsTest.hx @@ -1,42 +1,38 @@ package formatter; -import massive.munit.Assert; import formatter.FormatStats; -class FormatStatsTest { - @Before +class FormatStatsTest implements ITest { + public function new() {} + public function setup() { FormatStats.reset(); } - @Test public function testSuccessStats() { for (i in 0...100) { FormatStats.incSuccess(); } - Assert.areEqual(100, FormatStats.totalFiles); - Assert.areEqual(100, FormatStats.successFiles); + Assert.equals(100, FormatStats.totalFiles); + Assert.equals(100, FormatStats.successFiles); } - @Test public function testFailedStats() { for (i in 0...100) { FormatStats.incFailed(); } - Assert.areEqual(100, FormatStats.totalFiles); - Assert.areEqual(100, FormatStats.failedFiles); + Assert.equals(100, FormatStats.totalFiles); + Assert.equals(100, FormatStats.failedFiles); } - @Test public function testDisabledStats() { for (i in 0...100) { FormatStats.incDisabled(); } - Assert.areEqual(100, FormatStats.totalFiles); - Assert.areEqual(100, FormatStats.disabledFiles); + Assert.equals(100, FormatStats.totalFiles); + Assert.equals(100, FormatStats.disabledFiles); } - @Test public function testMixedStats() { for (i in 0...100) { FormatStats.incSuccess(); @@ -46,35 +42,32 @@ class FormatStatsTest { FormatStats.incFailed(); FormatStats.incDisabled(); } - Assert.areEqual(600, FormatStats.totalFiles); - Assert.areEqual(300, FormatStats.successFiles); - Assert.areEqual(200, FormatStats.failedFiles); - Assert.areEqual(100, FormatStats.disabledFiles); + Assert.equals(600, FormatStats.totalFiles); + Assert.equals(300, FormatStats.successFiles); + Assert.equals(200, FormatStats.failedFiles); + Assert.equals(100, FormatStats.disabledFiles); } - @Test public function testOrigLines() { for (i in 0...100) { FormatStats.addOrigLines(25); } - Assert.areEqual(2500, FormatStats.totalLinesOrig); + Assert.equals(2500, FormatStats.totalLinesOrig); } - @Test public function testFormattedLines() { for (i in 0...100) { FormatStats.addFormattedLines(25); } - Assert.areEqual(2500, FormatStats.totalLinesFormatted); + Assert.equals(2500, FormatStats.totalLinesFormatted); } - @Test public function testLines() { for (i in 0...100) { FormatStats.addOrigLines(23); FormatStats.addFormattedLines(13); } - Assert.areEqual(2300, FormatStats.totalLinesOrig); - Assert.areEqual(1300, FormatStats.totalLinesFormatted); + Assert.equals(2300, FormatStats.totalLinesOrig); + Assert.equals(1300, FormatStats.totalLinesFormatted); } } diff --git a/test/formatter/codedata/TokenListTest.hx b/test/formatter/codedata/TokenListTest.hx index e265650e..22357b1e 100644 --- a/test/formatter/codedata/TokenListTest.hx +++ b/test/formatter/codedata/TokenListTest.hx @@ -2,10 +2,10 @@ package formatter.codedata; import haxe.PosInfos; import haxe.io.Bytes; -import massive.munit.Assert; -class TokenListTest { - @Test +class TokenListTest implements ITest { + public function new() {} + public function testGetTokenAt() { var tokenList:TokenList = makeTokenList(FormatStatsTestCode.CodeSample); checkToken(tokenList, 0, 0, "class"); @@ -17,30 +17,27 @@ class TokenListTest { checkToken(tokenList, 41, 9, "trace"); } - @Test public function testInvalidGetTokenAt() { var tokenList:TokenList = makeTokenList(FormatStatsTestCode.CodeSample); - try { + Assert.raises(function() { tokenList.getTokenAtOffset(-1); - Assert.fail("previous call should not succeed"); - } catch (e:Any) {} - try { + }, String); + Assert.raises(function() { tokenList.getTokenAtOffset(64); - Assert.fail("previous call should not succeed"); - } catch (e:Any) {} + }, String); + tokenList = makeTokenList(""); - try { + Assert.raises(function() { tokenList.getTokenAtOffset(1); - Assert.fail("previous call should not succeed"); - } catch (e:Any) {} + }, String); } function checkToken(tokenList:TokenList, offset:Int, expectedIndex:Int, expectedText:String, ?pos:PosInfos) { var tokenInfo:Null = tokenList.getTokenAtOffset(offset); - Assert.isNotNull(tokenInfo, pos); - Assert.isNotNull(tokenInfo.token, pos); - Assert.areEqual(expectedIndex, tokenInfo.token.index, pos); - Assert.areEqual(expectedText, tokenInfo.token.toString()); + Assert.notNull(tokenInfo, pos); + Assert.notNull(tokenInfo.token, pos); + Assert.equals(expectedIndex, tokenInfo.token.index, pos); + Assert.equals(expectedText, tokenInfo.token.toString()); } function makeTokenList(code:String):TokenList { diff --git a/test/import.hx b/test/import.hx index 267fd0e2..bd885f7e 100644 --- a/test/import.hx +++ b/test/import.hx @@ -1,3 +1,4 @@ -import massive.munit.Assert; +import utest.Assert; +import utest.ITest; using StringTools; diff --git a/test/testcases/EmptyLinesTestCases.hx b/test/testcases/EmptyLinesTestCases.hx index de5ade52..4f496340 100644 --- a/test/testcases/EmptyLinesTestCases.hx +++ b/test/testcases/EmptyLinesTestCases.hx @@ -1,4 +1,5 @@ package testcases; @:build(TestCaseMacro.build("test/testcases/emptylines")) -class EmptyLinesTestCases extends GoldBaseTest {} +@:build(utest.utils.TestBuilder.build()) +class EmptyLinesTestCases extends GoldBaseTest implements ITest {} diff --git a/test/testcases/ExpressionLevelTestCases.hx b/test/testcases/ExpressionLevelTestCases.hx index 85a32c10..300ff2d8 100644 --- a/test/testcases/ExpressionLevelTestCases.hx +++ b/test/testcases/ExpressionLevelTestCases.hx @@ -1,8 +1,10 @@ package testcases; @:build(TestCaseMacro.build("test/testcases/expressionlevel")) -class ExpressionLevelTestCases extends GoldBaseTest { +@:build(utest.utils.TestBuilder.build()) +class ExpressionLevelTestCases extends GoldBaseTest implements ITest { public function new() { + super(); entryPoint = ExpressionLevel; } } diff --git a/test/testcases/FormatRangeTestCases.hx b/test/testcases/FormatRangeTestCases.hx index 5b1c626e..583dd22c 100644 --- a/test/testcases/FormatRangeTestCases.hx +++ b/test/testcases/FormatRangeTestCases.hx @@ -1,12 +1,12 @@ package testcases; import haxe.PosInfos; -import massive.munit.Assert; import formatter.Formatter; import formatter.config.Config; @:build(TestCaseMacro.build("test/testcases/formatrange")) -class FormatRangeTestCases extends GoldBaseTest { +@:build(utest.utils.TestBuilder.build()) +class FormatRangeTestCases extends GoldBaseTest implements ITest { override public function goldCheck(fileName:String, unformatted:String, goldCode:String, lineSeparator:String, ?configString:String, ?pos:PosInfos) { var config = new Config(); config.readConfigFromString(configString, "goldhxformat.json"); diff --git a/test/testcases/IndentationTestCases.hx b/test/testcases/IndentationTestCases.hx index 777c91ba..c1d1217a 100644 --- a/test/testcases/IndentationTestCases.hx +++ b/test/testcases/IndentationTestCases.hx @@ -1,4 +1,5 @@ package testcases; @:build(TestCaseMacro.build("test/testcases/indentation")) -class IndentationTestCases extends GoldBaseTest {} +@:build(utest.utils.TestBuilder.build()) +class IndentationTestCases extends GoldBaseTest implements ITest {} diff --git a/test/testcases/LineEndsTestCases.hx b/test/testcases/LineEndsTestCases.hx index 2ff864f4..d16bf27d 100644 --- a/test/testcases/LineEndsTestCases.hx +++ b/test/testcases/LineEndsTestCases.hx @@ -1,4 +1,5 @@ package testcases; @:build(TestCaseMacro.build("test/testcases/lineends")) -class LineEndsTestCases extends GoldBaseTest {} +@:build(utest.utils.TestBuilder.build()) +class LineEndsTestCases extends GoldBaseTest implements ITest {} diff --git a/test/testcases/MissingTestCases.hx b/test/testcases/MissingTestCases.hx index ac654baf..db0fb631 100644 --- a/test/testcases/MissingTestCases.hx +++ b/test/testcases/MissingTestCases.hx @@ -1,4 +1,5 @@ package testcases; @:build(TestCaseMacro.build("test/testcases/missing")) -class MissingTestCases extends GoldBaseTest {} +@:build(utest.utils.TestBuilder.build()) +class MissingTestCases extends GoldBaseTest implements ITest {} diff --git a/test/testcases/Other.hx b/test/testcases/Other.hx index 5dccc51f..72c85ce5 100644 --- a/test/testcases/Other.hx +++ b/test/testcases/Other.hx @@ -1,4 +1,5 @@ package testcases; @:build(TestCaseMacro.build("test/testcases/other")) -class Other extends GoldBaseTest {} +@:build(utest.utils.TestBuilder.build()) +class Other extends GoldBaseTest implements ITest {} diff --git a/test/testcases/SameLineTestCases.hx b/test/testcases/SameLineTestCases.hx index 6f1532eb..a376b61c 100644 --- a/test/testcases/SameLineTestCases.hx +++ b/test/testcases/SameLineTestCases.hx @@ -1,4 +1,5 @@ package testcases; @:build(TestCaseMacro.build("test/testcases/sameline")) -class SameLineTestCases extends GoldBaseTest {} +@:build(utest.utils.TestBuilder.build()) +class SameLineTestCases extends GoldBaseTest implements ITest {} diff --git a/test/testcases/WhitespaceTestCases.hx b/test/testcases/WhitespaceTestCases.hx index bf90e66d..eec4878a 100644 --- a/test/testcases/WhitespaceTestCases.hx +++ b/test/testcases/WhitespaceTestCases.hx @@ -1,4 +1,5 @@ package testcases; @:build(TestCaseMacro.build("test/testcases/whitespace")) -class WhitespaceTestCases extends GoldBaseTest {} +@:build(utest.utils.TestBuilder.build()) +class WhitespaceTestCases extends GoldBaseTest implements ITest {} diff --git a/test/testcases/WrappingTestCases.hx b/test/testcases/WrappingTestCases.hx index da3a71a3..16150290 100644 --- a/test/testcases/WrappingTestCases.hx +++ b/test/testcases/WrappingTestCases.hx @@ -1,4 +1,5 @@ package testcases; @:build(TestCaseMacro.build("test/testcases/wrapping")) -class WrappingTestCases extends GoldBaseTest {} +@:build(utest.utils.TestBuilder.build()) +class WrappingTestCases extends GoldBaseTest implements ITest {} diff --git a/testCoverage.hxml b/testCoverage.hxml new file mode 100644 index 00000000..d5d772bd --- /dev/null +++ b/testCoverage.hxml @@ -0,0 +1,41 @@ +-cp src +-cp test + +-lib tokentree +-lib haxeparser +-lib hxparse +-lib json2object +-lib hxargs +-lib utest +-lib test-adapter + +# -D debugLog +# -D debugIndent +# -D detailed_coverage +# -D debugWrapping +-D unittest +-D haxe-next +-x TestMain + +-D UTEST_PRINT_TESTS + +# -D profiler-console-detail-reporter +# -D profiler-console-missing-reporter +# -D profiler-console-summary-reporter +# -D profiler-console-hierarchy-reporter +# -D profiler-csv-reporter +# -D profiler-d3-reporter + +# -D coverage-console-missing-reporter +-D coverage-console-summary-reporter +-D coverage-console-file-summary-reporter +-D coverage-console-package-summary-reporter +-D coverage-lcov-reporter +-D coverage-codecov-reporter + +-lib instrument +--macro instrument.Instrumentation.coverage(['formatter'], ['src'], ['formatter.Cli', 'formatter.debug.PosInfosMacro']) + +# -D dump=pretty + +# --macro instrument.Instrumentation.profiling(['formatter'], ['src'], []) diff --git a/testJava.hxml b/testJava.hxml index 1e347f7a..e8642246 100644 --- a/testJava.hxml +++ b/testJava.hxml @@ -6,9 +6,7 @@ -lib hxparse -lib json2object -lib hxargs --lib mcover --lib munit -# -lib safety +-lib utest -lib test-adapter # -D debugLog @@ -16,24 +14,31 @@ # -D detailed_coverage # -D debugWrapping -D unittest +-D haxe-next --jvm out/TestMain.jar -main TestMain ---macro mcover.MCover.coverage(['formatter'], ['src'], ['formatter.Cli']) - -# -lib instrument -# # -D profiler-console-detail-reporter -# # -D profiler-console-missing-reporter -# # -D profiler-console-summary-reporter -# # -D profiler-console-hierarchy-reporter -# # -D profiler-csv-reporter -# # -D profiler-d3-reporter -# # -D coverage-console-summary-reporter -# -D coverage-console-package-summary-reporter -# # -D coverage-console-detail-reporter -# -D coverage-lcov-reporter -# -D coverage-codecov-reporter - -# --macro instrument.Instrumentation.coverage(['formatter'], ['src'], ['formatter.Cli', 'formatter.debug.PosInfosMacro']) +-D UTEST_PRINT_TESTS + +# -D profiler-console-detail-reporter +# -D profiler-console-missing-reporter +# -D profiler-console-summary-reporter +# -D profiler-console-hierarchy-reporter +# -D profiler-csv-reporter +# -D profiler-d3-reporter + +# -D coverage-console-missing-reporter +-D coverage-console-summary-reporter +-D coverage-console-file-summary-reporter +-D coverage-console-package-summary-reporter +-D coverage-lcov-reporter +-D coverage-codecov-reporter + +-lib instrument +--macro instrument.Instrumentation.coverage(['formatter'], ['src'], ['formatter.Cli', 'formatter.debug.PosInfosMacro']) + +# -D dump=pretty + +# --macro instrument.Instrumentation.profiling(['formatter'], ['src'], []) -cmd java -jar out/TestMain.jar