Просмотр исходного кода

[server] track dirty dependency chains

Simon Krajewski 2 лет назад
Родитель
Сommit
ab0d7034dc
4 измененных файлов с 21 добавлено и 16 удалено
  1. 1 1
      src/compiler/server.ml
  2. 10 6
      src/core/tPrinting.ml
  3. 1 1
      src/core/tType.ml
  4. 9 8
      tests/server/src/cases/ServerTests.hx

+ 1 - 1
src/compiler/server.ml

@@ -327,7 +327,7 @@ let check_module sctx ctx m p =
 		let check_dependencies () =
 			PMap.iter (fun _ m2 -> match check m2 with
 				| None -> ()
-				| Some _ -> raise (Dirty (DependencyDirty m2.m_path))
+				| Some reason -> raise (Dirty (DependencyDirty(m2.m_path,reason)))
 			) m.m_extra.m_deps;
 		in
 		let check () =

+ 10 - 6
src/core/tPrinting.ml

@@ -632,12 +632,16 @@ module Printer = struct
 		| MExtern -> "MExtern"
 		| MImport -> "MImport"
 
-	let s_module_skip_reason = function
-		| DependencyDirty path -> "DependencyDirty " ^ (s_type_path path)
-		| Tainted cause -> "Tainted " ^ cause
-		| FileChanged file -> "FileChanged " ^ file
-		| Shadowed file -> "Shadowed " ^ file
-		| LibraryChanged -> "LibraryChanged"
+	let s_module_skip_reason reason =
+		let rec loop stack = function
+			| DependencyDirty(path,reason) ->
+				(Printf.sprintf "%s%s - %s" (if stack = [] then "DependencyDirty " else "") (s_type_path path) (if List.mem path stack then "rec" else loop (path :: stack) reason))
+			| Tainted cause -> "Tainted " ^ cause
+			| FileChanged file -> "FileChanged " ^ file
+			| Shadowed file -> "Shadowed " ^ file
+			| LibraryChanged -> "LibraryChanged"
+		in
+		loop [] reason
 
 	let s_module_cache_state = function
 		| MSGood -> "Good"

+ 1 - 1
src/core/tType.ml

@@ -33,7 +33,7 @@ type module_check_policy =
 	| Retype
 
 type module_skip_reason =
-	| DependencyDirty of path
+	| DependencyDirty of path * module_skip_reason
 	| Tainted of string
 	| FileChanged of string
 	| Shadowed of string

+ 9 - 8
tests/server/src/cases/ServerTests.hx

@@ -36,7 +36,7 @@ class ServerTests extends TestCase {
 		runHaxe(args);
 		runHaxeJson([], ServerMethods.Invalidate, {file: new FsPath("Dependency.hx")});
 		runHaxe(args);
-		assertSkipping("WithDependency", DependencyDirty("Dependency"));
+		assertSkipping("WithDependency", DependencyDirty("Dependency - Tainted server/invalidate"));
 		// assertNotCacheModified("Dependency");
 		runHaxe(args);
 		assertReuse("Dependency");
@@ -79,14 +79,15 @@ class ServerTests extends TestCase {
 		runHaxe(args);
 		runHaxe(args);
 		/* This often fails on our CI because the reported stdout is empty. I don't know why this is the case,
-		   but it's probably some obscure timing issue related to pipes which has nothing to do with that we
-		   actually want to test here. */
+			but it's probably some obscure timing issue related to pipes which has nothing to do with that we
+			actually want to test here. */
 		// trace(lastResult);
 		// assertReuse("BuiltClass");
 		runHaxeJson([], ServerMethods.Invalidate, {file: new FsPath("BuildMacro.hx")});
 		runHaxe(args);
 		// assertNotCacheModified("BuildMacro");
-		assertSkipping("BuiltClass", DependencyDirty("BuildMacro"));
+		trace(lastResult);
+		assertSkipping("BuiltClass", DependencyDirty("BuildMacro - Tainted server/invalidate"));
 		assertSkipping("BuildMacro", Tainted("server/invalidate"));
 	}
 
@@ -148,9 +149,9 @@ class ServerTests extends TestCase {
 		runHaxe(args);
 		runHaxe(args);
 		assertReuse("HelloWorld");
-	 	runHaxeJson([], ServerMethods.Invalidate, {file: new FsPath("HelloWorld.hx")});
-	 	runHaxe(args);
-	 	assertSkipping("HelloWorld", Tainted("server/invalidate"));
+		runHaxeJson([], ServerMethods.Invalidate, {file: new FsPath("HelloWorld.hx")});
+		runHaxe(args);
+		assertSkipping("HelloWorld", Tainted("server/invalidate"));
 		runHaxe(args.concat(["--display", "HelloWorld.hx@0@diagnostics"]));
 		runHaxe(args);
 		assertReuse("HelloWorld");
@@ -170,7 +171,7 @@ class ServerTests extends TestCase {
 		runHaxe(args);
 		runHaxe(args);
 		assertReuse("HelloWorld");
-	 	runHaxeJson([], ServerMethods.Invalidate, {file: new FsPath("HelloWorld.hx")});
+		runHaxeJson([], ServerMethods.Invalidate, {file: new FsPath("HelloWorld.hx")});
 		runHaxe(args.concat(["--display", "HelloWorld.hx@0@diagnostics"]));
 		runHaxe(args.concat(["--display", "HelloWorld.hx@0@hover"]));
 		assertReuse("HelloWorld");