Sfoglia il codice sorgente

[server] test for #8254 (closes #8254)

Aleksandr Kuzmenko 6 anni fa
parent
commit
ff1e2215e2

+ 5 - 1
tests/server/src/HaxeServerTestCase.hx

@@ -103,6 +103,10 @@ class HaxeServerTestCase implements ITest {
 		return null;
 	}
 
+	function assertSuccess(?p:haxe.PosInfos) {
+		Assert.isTrue(0 == errorMessages.length, p);
+	}
+
 	function assertErrorMessage(message:String, ?p:haxe.PosInfos) {
 		Assert.isTrue(hasErrorMessage(message), p);
 	}
@@ -133,7 +137,7 @@ class HaxeServerTestCase implements ITest {
 
 	function assertHasField(typePackage:String, typeName:String, fieldName:String, isStatic:Bool, ?p:haxe.PosInfos) {
 		var type = getStoredType(typePackage, typeName);
-		Assert.isTrue(type != null);
+		Assert.isTrue(type != null, p);
 		function check<T>(type:JsonModuleType<T>) {
 			return switch [type.kind, type.args] {
 				case [Class, c]:

+ 8 - 0
tests/server/src/Main.hx

@@ -88,6 +88,14 @@ class ServerTests extends HaxeServerTestCase {
 		runHaxe(args);
 		assertErrorMessage("Expected }");
 	}
+
+	function testGlobalBuildMacro_subsequentCompilations() {
+		vfs.putContent("GlobalBuildMacro.hx", getTemplate("GlobalBuildMacro.hx"));
+		var args = ["--macro", "GlobalBuildMacro.use()", "--run", "GlobalBuildMacro"];
+		runHaxe(args);
+		runHaxe(args);
+		assertSuccess();
+	}
 }
 
 class Main {

+ 11 - 0
tests/server/test/templates/GlobalBuildMacro.hx

@@ -0,0 +1,11 @@
+class GlobalBuildMacro {
+	static function main() {}
+
+	#if macro
+	static function use()
+		haxe.macro.Compiler.addGlobalMetadata('', '@:build(GlobalBuildMacro.build())', true, true, false);
+
+	static function build():Array<haxe.macro.Expr.Field>
+		return null;
+	#end
+}