Skip to content

Commit

Permalink
rethrow exceptions when running unittests, closes #154 (#242)
Browse files Browse the repository at this point in the history
refactored unittest for #181
  • Loading branch information
AlexHaxe committed Apr 14, 2016
1 parent 88f7eda commit 84c18f8
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 3 deletions.
1 change: 1 addition & 0 deletions build.hxml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

--next
-lib mcover:2.1.1
-D unittest
-x TestMain
--macro mcover.MCover.coverage(['checkstyle'], ['src'], ['checkstyle.reporter', 'checkstyle.Main'])

Expand Down
3 changes: 2 additions & 1 deletion checkstyle.json
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,8 @@
"checkstyle.Checker",
"checkstyle.ChecksInfo",
"checkstyle.checks.imports.UnusedImportCheck",
"TestMain"
"TestMain",
"misc.ExtensionsTest"
],
"MultipleStringLiterals": [
"checks",
Expand Down
6 changes: 6 additions & 0 deletions src/checkstyle/Checker.hx
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ class Checker {
Sys.println(e);
Sys.println("Stacktrace: " + CallStack.toString(CallStack.exceptionStack()));
#end
#if unittest
throw e;
#end
}
}

Expand Down Expand Up @@ -155,6 +158,9 @@ class Checker {
Sys.println(e);
Sys.println("Stacktrace: " + CallStack.toString(CallStack.exceptionStack()));
#end
#if unittest
throw e;
#end
}
return null;
}
Expand Down
3 changes: 3 additions & 0 deletions src/checkstyle/checks/Check.hx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ class Check {
Sys.println(e);
Sys.println("Stacktrace: " + CallStack.toString(CallStack.exceptionStack()));
#end
#if unittest
throw e;
#end
}
}
return messages;
Expand Down
2 changes: 1 addition & 1 deletion src/checkstyle/token/TokenTreeBuilder.hx
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ class TokenTreeBuilder {
if (stream.is(DblDot)) {
var dblDot:TokenTree = stream.consumeTokenDef(DblDot);
name.addChild(dblDot);
walkTypeNameDef(name);
walkTypeNameDef(dblDot);
}
walkBlock(name);
}
Expand Down
10 changes: 9 additions & 1 deletion test/misc/ExtensionsTest.hx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,15 @@ import checkstyle.checks.whitespace.IndentationCharacterCheck;
class ExtensionsTest extends CheckTestCase<ExtensionsTests> {

public function testExtensions() {
assertNoMsg(new IndentationCharacterCheck(), TEST1);
try {
assertNoMsg(new IndentationCharacterCheck(), TEST1);
// unless haxeparse bug is fixed, this code is unreachable
assertFalse(true);
}
catch (e:Dynamic) {
assertEquals("misc.ExtensionsTest", e.classname);
assertEquals("expected '' but was 'Parsing failed: Unexpected >", e.error.substr(0, 49));
}
}
}

Expand Down

0 comments on commit 84c18f8

Please sign in to comment.