Skip to content

Commit cd92af6

Browse files
committed
[tests] update tests
1 parent 6543e9d commit cd92af6

File tree

3 files changed

+33
-34
lines changed

3 files changed

+33
-34
lines changed

tests/server/src/cases/issues/Issue12001.hx

+15-13
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ class Issue12001 extends TestCase {
1010
runHaxe(args);
1111
assertSuccess();
1212

13+
// Nothing is loading Foo, so no redefinition issue
1314
runHaxe(args);
14-
Assert.isFalse(0 == errorMessages.length);
15-
assertErrorMessage("Cannot redefine module Foo");
15+
assertSuccess();
1616
}
1717

1818
function testDefineType1(_) {
@@ -23,8 +23,9 @@ class Issue12001 extends TestCase {
2323
assertSuccess();
2424

2525
runHaxe(args);
26-
Assert.isFalse(hasErrorMessage('HxbData.HxbFailure("Could not read static field test on Foo while hxbing Main")'));
27-
assertErrorMessage("Cannot redefine module Foo");
26+
assertSuccess();
27+
// TODO: change invalidation reason
28+
assertSkipping("Main", DependencyDirty("Foo - Tainted server/invalidate"));
2829
}
2930

3031
function testDefineModule(_) {
@@ -34,9 +35,9 @@ class Issue12001 extends TestCase {
3435
runHaxe(args);
3536
assertSuccess();
3637

38+
// Nothing is loading Bar, so no redefinition issue
3739
runHaxe(args);
38-
Assert.isFalse(0 == errorMessages.length);
39-
assertErrorMessage("Cannot redefine module Bar");
40+
assertSuccess();
4041
}
4142

4243
function testDefineModule1(_) {
@@ -47,9 +48,9 @@ class Issue12001 extends TestCase {
4748
assertSuccess();
4849

4950
runHaxe(args);
50-
Assert.isFalse(0 == errorMessages.length);
51-
Assert.isFalse(hasErrorMessage('HxbData.HxbFailure("Could not read static field test on Bar while hxbing Main")'));
52-
assertErrorMessage("Cannot redefine module Bar");
51+
assertSuccess();
52+
// TODO: change invalidation reason
53+
assertSkipping("Main", DependencyDirty("Bar - Tainted server/invalidate"));
5354
}
5455

5556
@:async
@@ -77,9 +78,9 @@ class Issue12001 extends TestCase {
7778
runHaxe(args);
7879
assertSuccess();
7980

81+
// Nothing is loading Baz, so it can be defined again
8082
runHaxe(args);
81-
Assert.isFalse(0 == errorMessages.length);
82-
assertErrorMessage("Cannot redefine module Baz");
83+
assertSuccess();
8384
}
8485

8586
@:async
@@ -92,6 +93,7 @@ class Issue12001 extends TestCase {
9293
function test() {
9394
runHaxe(args, () -> {
9495
assertSuccess();
96+
// Newest version is being included
9597
assertHasPrint("Foobaz.test() = " + i);
9698
if (++i >= 5) async.done();
9799
else test();
@@ -101,15 +103,15 @@ class Issue12001 extends TestCase {
101103
}
102104

103105
function testInvalidateError(_) {
104-
vfs.putContent("Macro.hx", getTemplate("issues/Issue12001/Macro.hx"));
106+
vfs.putContent("Macro.hx", getTemplate("issues/Issue12001/Macro1.hx"));
105107
vfs.putContent("Empty.hx", getTemplate("Empty.hx"));
106108
var args = ["-main", "Empty", "--interp", "--macro", "Macro.hookInvalidateError()"];
107109
runHaxe(args);
108110
assertErrorMessage("Cannot invalidate loaded module Empty");
109111
}
110112

111113
function testInvalidateCaughtError(_) {
112-
vfs.putContent("Macro.hx", getTemplate("issues/Issue12001/Macro.hx"));
114+
vfs.putContent("Macro.hx", getTemplate("issues/Issue12001/Macro1.hx"));
113115
vfs.putContent("Empty.hx", getTemplate("Empty.hx"));
114116
var args = ["-main", "Empty", "--interp", "--macro", "Macro.hookInvalidateCatch()"];
115117
runHaxe(args);

tests/server/test/templates/issues/Issue12001/Macro.hx

-21
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import haxe.macro.CompilationServer;
21
import haxe.macro.Context;
32

43
function defineType() {
@@ -32,8 +31,6 @@ function defineModule() {
3231
@:persistent var i = 0;
3332
function redefineModule() {
3433
Context.onAfterInitMacros(() -> {
35-
CompilationServer.invalidateModule("Foobar");
36-
3734
Context.defineModule("Foobar", [{
3835
pos: Context.currentPos(),
3936
pack: [],
@@ -71,8 +68,6 @@ function hookRedefine() {
7168
if (generated) return;
7269
generated = true;
7370

74-
CompilationServer.invalidateModule("Foobaz");
75-
7671
Context.defineModule("Foobaz", [{
7772
pos: Context.currentPos(),
7873
pack: [],
@@ -84,19 +79,3 @@ function hookRedefine() {
8479
}]);
8580
});
8681
}
87-
88-
function hookInvalidateError() {
89-
Context.onAfterTyping((_) -> {
90-
CompilationServer.invalidateModule("Empty");
91-
});
92-
}
93-
94-
function hookInvalidateCatch() {
95-
Context.onAfterTyping((_) -> {
96-
try {
97-
CompilationServer.invalidateModule("Empty");
98-
} catch (e:Dynamic) {
99-
Sys.println(Std.string(e));
100-
}
101-
});
102-
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import haxe.macro.CompilationServer;
2+
import haxe.macro.Context;
3+
4+
function hookInvalidateError() {
5+
Context.onAfterTyping((_) -> {
6+
CompilationServer.invalidateModule("Empty");
7+
});
8+
}
9+
10+
function hookInvalidateCatch() {
11+
Context.onAfterTyping((_) -> {
12+
try {
13+
CompilationServer.invalidateModule("Empty");
14+
} catch (e:Dynamic) {
15+
Sys.println(Std.string(e));
16+
}
17+
});
18+
}

0 commit comments

Comments
 (0)