소스 검색

[tests] use explicit server/invalidate requests instead of file touching for now

see #8761
Simon Krajewski 6 년 전
부모
커밋
7e77c8af70
1개의 변경된 파일47개의 추가작업 그리고 47개의 파일을 삭제
  1. 47 47
      tests/server/src/Main.hx

+ 47 - 47
tests/server/src/Main.hx

@@ -22,10 +22,10 @@ class ServerTests extends HaxeServerTestCase {
 		vfs.putContent("HelloWorld.hx", getTemplate("HelloWorld.hx"));
 		vfs.putContent("HelloWorld.hx", getTemplate("HelloWorld.hx"));
 		var args = ["-main", "HelloWorld.hx", "--no-output", "-js", "no.js"];
 		var args = ["-main", "HelloWorld.hx", "--no-output", "-js", "no.js"];
 		runHaxe(args);
 		runHaxe(args);
-		vfs.touchFile("HelloWorld.hx");
+		runHaxeJson([], ServerMethods.Invalidate, {file: new FsPath("HelloWorld.hx")});
 		runHaxe(args);
 		runHaxe(args);
 		assertSkipping("HelloWorld");
 		assertSkipping("HelloWorld");
-		assertNotCacheModified("HelloWorld");
+		// assertNotCacheModified("HelloWorld");
 	}
 	}
 
 
 	function testDependency() {
 	function testDependency() {
@@ -33,10 +33,10 @@ class ServerTests extends HaxeServerTestCase {
 		vfs.putContent("Dependency.hx", getTemplate("Dependency.hx"));
 		vfs.putContent("Dependency.hx", getTemplate("Dependency.hx"));
 		var args = ["-main", "WithDependency.hx", "--no-output", "-js", "no.js"];
 		var args = ["-main", "WithDependency.hx", "--no-output", "-js", "no.js"];
 		runHaxe(args);
 		runHaxe(args);
-		vfs.touchFile("Dependency.hx");
+		runHaxeJson([], ServerMethods.Invalidate, {file: new FsPath("Dependency.hx")});
 		runHaxe(args);
 		runHaxe(args);
 		assertSkipping("WithDependency", "Dependency");
 		assertSkipping("WithDependency", "Dependency");
-		assertNotCacheModified("Dependency");
+		// assertNotCacheModified("Dependency");
 		runHaxe(args);
 		runHaxe(args);
 		assertReuse("Dependency");
 		assertReuse("Dependency");
 		assertReuse("WithDependency");
 		assertReuse("WithDependency");
@@ -48,17 +48,17 @@ class ServerTests extends HaxeServerTestCase {
 		var args = ["-main", "MacroMain.hx", "--no-output", "-js", "no.js"];
 		var args = ["-main", "MacroMain.hx", "--no-output", "-js", "no.js"];
 		runHaxe(args);
 		runHaxe(args);
 		assertHasPrint("1");
 		assertHasPrint("1");
-		vfs.touchFile("MacroMain.hx");
+		runHaxeJson([], ServerMethods.Invalidate, {file: new FsPath("MacroMain.hx")});
 		runHaxe(args);
 		runHaxe(args);
 		assertHasPrint("1");
 		assertHasPrint("1");
-		vfs.touchFile("Macro.hx");
+		runHaxeJson([], ServerMethods.Invalidate, {file: new FsPath("Macro.hx")});
 		runHaxe(args);
 		runHaxe(args);
 		assertHasPrint("1");
 		assertHasPrint("1");
 		vfs.putContent("Macro.hx", getTemplate("Macro.hx").replace("1", "2"));
 		vfs.putContent("Macro.hx", getTemplate("Macro.hx").replace("1", "2"));
 		runHaxeJson([], ServerMethods.Invalidate, {file: new FsPath("Macro.hx")});
 		runHaxeJson([], ServerMethods.Invalidate, {file: new FsPath("Macro.hx")});
 		runHaxe(args);
 		runHaxe(args);
 		assertHasPrint("2");
 		assertHasPrint("2");
-		vfs.touchFile("MacroMain.hx");
+		runHaxeJson([], ServerMethods.Invalidate, {file: new FsPath("MacroMain.hx")});
 		runHaxe(args);
 		runHaxe(args);
 		assertHasPrint("2");
 		assertHasPrint("2");
 	}
 	}
@@ -78,9 +78,9 @@ class ServerTests extends HaxeServerTestCase {
 		runHaxe(args);
 		runHaxe(args);
 		runHaxe(args);
 		runHaxe(args);
 		assertReuse("BuiltClass");
 		assertReuse("BuiltClass");
-		vfs.touchFile("BuildMacro.hx");
+		runHaxeJson([], ServerMethods.Invalidate, {file: new FsPath("BuildMacro.hx")});
 		runHaxe(args);
 		runHaxe(args);
-		assertNotCacheModified("BuildMacro");
+		// assertNotCacheModified("BuildMacro");
 		assertSkipping("BuiltClass", "BuildMacro");
 		assertSkipping("BuiltClass", "BuildMacro");
 		assertSkipping("BuildMacro");
 		assertSkipping("BuildMacro");
 	}
 	}
@@ -118,7 +118,7 @@ class ServerTests extends HaxeServerTestCase {
 		assertReuse("HelloWorld");
 		assertReuse("HelloWorld");
 
 
 		// make sure we still invalidate if the file does change
 		// make sure we still invalidate if the file does change
-		vfs.touchFile("HelloWorld.hx");
+		runHaxeJson([], ServerMethods.Invalidate, {file: new FsPath("HelloWorld.hx")});
 		runHaxe(args2);
 		runHaxe(args2);
 
 
 		runHaxe(args);
 		runHaxe(args);
@@ -187,7 +187,7 @@ class ServerTests extends HaxeServerTestCase {
 		vfs.putContent("VectorInliner.hx", getTemplate("VectorInliner.hx"));
 		vfs.putContent("VectorInliner.hx", getTemplate("VectorInliner.hx"));
 		var args = ["-main", "VectorInliner", "--interp"];
 		var args = ["-main", "VectorInliner", "--interp"];
 		runHaxe(args);
 		runHaxe(args);
-		vfs.touchFile("VectorInliner.hx");
+		runHaxeJson([], ServerMethods.Invalidate, {file: new FsPath("VectorInliner.hx")});
 		runHaxeJson(args, cast "typer/compiledTypes" /* TODO */, {});
 		runHaxeJson(args, cast "typer/compiledTypes" /* TODO */, {});
 		var type = getStoredType("", "VectorInliner");
 		var type = getStoredType("", "VectorInliner");
 		function moreHack(s:String) {
 		function moreHack(s:String) {
@@ -221,43 +221,43 @@ class ServerTests extends HaxeServerTestCase {
 		utest.Assert.equals('2', counter);
 		utest.Assert.equals('2', counter);
 	}
 	}
 
 
-	// function testIssue8738() {
-	// 	vfs.putContent("Base.hx", getTemplate("issues/Issue8738/Base.hx"));
-	// 	vfs.putContent("Main.hx", getTemplate("issues/Issue8738/Main1.hx"));
-	// 	var args = ["-main", "Main", "--interp"];
-	// 	runHaxe(args);
-	// 	assertSuccess();
-	// 	vfs.putContent("Main.hx", getTemplate("issues/Issue8738/Main2.hx"));
-	// 	vfs.touchFile("Main.hx");
-	// 	runHaxe(args);
-	// 	assertErrorMessage("Cannot force inline-call to test because it is overridden");
-	// 	vfs.putContent("Main.hx", getTemplate("issues/Issue8738/Main3.hx"));
-	// 	vfs.touchFile("Main.hx");
-	// 	runHaxe(args);
-	// 	assertSuccess();
-	// }
+	function testIssue8738() {
+		vfs.putContent("Base.hx", getTemplate("issues/Issue8738/Base.hx"));
+		vfs.putContent("Main.hx", getTemplate("issues/Issue8738/Main1.hx"));
+		var args = ["-main", "Main", "--interp"];
+		runHaxe(args);
+		assertSuccess();
+		vfs.putContent("Main.hx", getTemplate("issues/Issue8738/Main2.hx"));
+		runHaxeJson([], ServerMethods.Invalidate, {file: new FsPath("Main.hx")});
+		runHaxe(args);
+		assertErrorMessage("Cannot force inline-call to test because it is overridden");
+		vfs.putContent("Main.hx", getTemplate("issues/Issue8738/Main3.hx"));
+		runHaxeJson([], ServerMethods.Invalidate, {file: new FsPath("Main.hx")});
+		runHaxe(args);
+		assertSuccess();
+	}
 
 
-	// function testIssue8748() {
-	// 	vfs.putContent("Dependency.hx", getTemplate("Dependency.hx"));
-	// 	vfs.putContent("WithDependency.hx", getTemplate("WithDependency.hx"));
-	// 	vfs.putContent("res/dep.dep", "");
-	// 	var args = [
-	// 		"-main",
-	// 		"WithDependency",
-	// 		"--interp",
-	// 		"--macro",
-	// 		"haxe.macro.Context.registerModuleDependency(\"Dependency\", \"res/dep.dep\")"
-	// 	];
-	// 	runHaxeJson(args, ServerMethods.Configure, {noModuleChecks: true});
-	// 	runHaxe(args);
-	// 	runHaxeJson(args, DisplayMethods.Hover, {file: new FsPath("WithDependency.hx"), offset: 65});
-	// 	assertReuse("Dependency");
-	// 	vfs.touchFile("res/dep.dep");
-	// 	runHaxeJson(args, DisplayMethods.Hover, {file: new FsPath("WithDependency.hx"), offset: 65});
-	// 	// check messages manually because module file contains awkward absolute path
-	// 	var r = ~/skipping Dependency\(.*dep.dep\)/;
-	// 	Assert.isTrue(messages.exists(message -> r.match(message)));
-	// }
+	function testIssue8748() {
+		vfs.putContent("Dependency.hx", getTemplate("Dependency.hx"));
+		vfs.putContent("WithDependency.hx", getTemplate("WithDependency.hx"));
+		vfs.putContent("res/dep.dep", "");
+		var args = [
+			"-main",
+			"WithDependency",
+			"--interp",
+			"--macro",
+			"haxe.macro.Context.registerModuleDependency(\"Dependency\", \"res/dep.dep\")"
+		];
+		runHaxeJson(args, ServerMethods.Configure, {noModuleChecks: true});
+		runHaxe(args);
+		runHaxeJson(args, DisplayMethods.Hover, {file: new FsPath("WithDependency.hx"), offset: 65});
+		assertReuse("Dependency");
+		runHaxeJson([], ServerMethods.Invalidate, {file: new FsPath("res/dep.dep")});
+		runHaxeJson(args, DisplayMethods.Hover, {file: new FsPath("WithDependency.hx"), offset: 65});
+		// check messages manually because module file contains awkward absolute path
+		var r = ~/skipping Dependency\(.*dep.dep\)/;
+		Assert.isTrue(messages.exists(message -> r.match(message)));
+	}
 }
 }
 
 
 class Main {
 class Main {