Jelajahi Sumber

exit if an onGenerate optimization check failed

Simon Krajewski 9 tahun lalu
induk
melakukan
9dd57f209e
1 mengubah file dengan 8 tambahan dan 0 penghapusan
  1. 8 0
      tests/optimization/src/TestBaseMacro.hx

+ 8 - 0
tests/optimization/src/TestBaseMacro.hx

@@ -6,6 +6,8 @@ using StringTools;
 using haxe.macro.Tools;
 using haxe.macro.Tools;
 
 
 class TestBaseMacro {
 class TestBaseMacro {
+	static var numFailures = 0;
+
 	macro static public function run() {
 	macro static public function run() {
 		var c = Context.getLocalClass();
 		var c = Context.getLocalClass();
 		var fields = c.get().fields.get();
 		var fields = c.get().fields.get();
@@ -31,6 +33,9 @@ class TestBaseMacro {
 				case _:
 				case _:
 			}
 			}
 		}
 		}
+		if (numFailures > 0) {
+			Sys.exit(1);
+		}
 	}
 	}
 
 
 	static function checkClass(c:ClassType) {
 	static function checkClass(c:ClassType) {
@@ -45,9 +50,11 @@ class TestBaseMacro {
 				switch [el[0].expr, el[1].expr] {
 				switch [el[0].expr, el[1].expr] {
 					case [TConst(tc1), TConst(tc2)]:
 					case [TConst(tc1), TConst(tc2)]:
 						if (!constEquals(tc1, tc2)) {
 						if (!constEquals(tc1, tc2)) {
+							++numFailures;
 							Context.warning('$tc2 should be $tc1', e.pos);
 							Context.warning('$tc2 should be $tc1', e.pos);
 						}
 						}
 					case [e1, e2]:
 					case [e1, e2]:
+						++numFailures;
 						Context.warning('$e2 should be $e1', e.pos);
 						Context.warning('$e2 should be $e1', e.pos);
 				}
 				}
 			case TCall({ expr: TField(_, FInstance(_, _, _.get() => {name: "assertEquals"}))}, el):
 			case TCall({ expr: TField(_, FInstance(_, _, _.get() => {name: "assertEquals"}))}, el):
@@ -56,6 +63,7 @@ class TestBaseMacro {
 				}
 				}
 				switch (el[1].expr) {
 				switch (el[1].expr) {
 					case (TConst(tc)):
 					case (TConst(tc)):
+						++numFailures;
 						Context.warning('Unexpected constant $tc in assertEquals, use assertEqualsConst if this is intended', e.pos);
 						Context.warning('Unexpected constant $tc in assertEquals, use assertEqualsConst if this is intended', e.pos);
 					case _:
 					case _:
 				}
 				}