From 9e8fbcd7f8d5f1edc91655418f74da9ce87fd525 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Thu, 8 Aug 2019 12:40:43 -0700 Subject: [PATCH] Transitively upstream blocked project should not build --- src/compiler/diagnosticMessages.json | 8 +++++++ src/compiler/tsbuild.ts | 22 ++++++++++++++---- src/testRunner/unittests/tsbuild/demo.ts | 29 ++++++++++++++++++++++++ 3 files changed, 55 insertions(+), 4 deletions(-) diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 4528d504d0..23f60c22a6 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -4172,6 +4172,14 @@ "category": "Message", "code": 6381 }, + "Skipping build of project '{0}' because its dependency '{1}' was not built": { + "category": "Message", + "code": 6382 + }, + "Project '{0}' can't be built because its dependency '{1}' was not built": { + "category": "Message", + "code": 6383 + }, "The expected type comes from property '{0}' which is declared here on type '{1}'": { "category": "Message", diff --git a/src/compiler/tsbuild.ts b/src/compiler/tsbuild.ts index 4012619a0c..0503d0a49d 100644 --- a/src/compiler/tsbuild.ts +++ b/src/compiler/tsbuild.ts @@ -116,6 +116,7 @@ namespace ts { export interface UpstreamBlocked { type: UpToDateStatusType.UpstreamBlocked; upstreamProjectName: string; + upstreamProjectBlocked: boolean; } /** @@ -1338,7 +1339,16 @@ namespace ts { if (status.type === UpToDateStatusType.UpstreamBlocked) { reportAndStoreErrors(state, projectPath, config.errors); projectPendingBuild.delete(projectPath); - if (options.verbose) reportStatus(state, Diagnostics.Skipping_build_of_project_0_because_its_dependency_1_has_errors, project, status.upstreamProjectName); + if (options.verbose) { + reportStatus( + state, + status.upstreamProjectBlocked ? + Diagnostics.Skipping_build_of_project_0_because_its_dependency_1_was_not_built : + Diagnostics.Skipping_build_of_project_0_because_its_dependency_1_has_errors, + project, + status.upstreamProjectName + ); + } continue; } @@ -1540,10 +1550,12 @@ namespace ts { } // An upstream project is blocked - if (refStatus.type === UpToDateStatusType.Unbuildable) { + if (refStatus.type === UpToDateStatusType.Unbuildable || + refStatus.type === UpToDateStatusType.UpstreamBlocked) { return { type: UpToDateStatusType.UpstreamBlocked, - upstreamProjectName: ref.path + upstreamProjectName: ref.path, + upstreamProjectBlocked: refStatus.type === UpToDateStatusType.UpstreamBlocked }; } @@ -2167,7 +2179,9 @@ namespace ts { case UpToDateStatusType.UpstreamBlocked: return reportStatus( state, - Diagnostics.Project_0_can_t_be_built_because_its_dependency_1_has_errors, + status.upstreamProjectBlocked ? + Diagnostics.Project_0_can_t_be_built_because_its_dependency_1_was_not_built : + Diagnostics.Project_0_can_t_be_built_because_its_dependency_1_has_errors, relName(state, configFileName), relName(state, status.upstreamProjectName) ); diff --git a/src/testRunner/unittests/tsbuild/demo.ts b/src/testRunner/unittests/tsbuild/demo.ts index b5cd72b2db..71e82fc533 100644 --- a/src/testRunner/unittests/tsbuild/demo.ts +++ b/src/testRunner/unittests/tsbuild/demo.ts @@ -107,5 +107,34 @@ namespace ts { notExpectedOutputs: [...coreOutputs(), ...animalOutputs(), ...zooOutputs()] }); }); + + it("in bad-ref branch reports the error about files not in rootDir at the import location", () => { + verifyBuild({ + modifyDiskLayout: fs => prependText( + fs, + "/src/core/utilities.ts", + `import * as A from '../animals'; +` + ), + expectedExitStatus: ExitStatus.DiagnosticsPresent_OutputsSkipped, + expectedDiagnostics: [ + getExpectedDiagnosticForProjectsInBuild("src/core/tsconfig.json", "src/animals/tsconfig.json", "src/zoo/tsconfig.json", "src/tsconfig.json"), + [Diagnostics.Project_0_is_out_of_date_because_output_file_1_does_not_exist, "src/core/tsconfig.json", "src/lib/core/utilities.js"], + [Diagnostics.Building_project_0, "/src/core/tsconfig.json"], + [Diagnostics.File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files, "/src/animals/animal.ts", "/src/core"], + [Diagnostics.File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files, "/src/animals/dog.ts", "/src/core"], + [Diagnostics.File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files, "/src/animals/index.ts", "/src/core"], + [Diagnostics.File_0_is_not_listed_within_the_file_list_of_project_1_Projects_must_list_all_files_or_use_an_include_pattern, "/src/animals/animal.ts", "/src/core/tsconfig.json"], + [Diagnostics.File_0_is_not_listed_within_the_file_list_of_project_1_Projects_must_list_all_files_or_use_an_include_pattern, "/src/animals/dog.ts", "/src/core/tsconfig.json"], + [Diagnostics.File_0_is_not_listed_within_the_file_list_of_project_1_Projects_must_list_all_files_or_use_an_include_pattern, "/src/animals/index.ts", "/src/core/tsconfig.json"], + [Diagnostics.Project_0_can_t_be_built_because_its_dependency_1_has_errors, "src/animals/tsconfig.json", "src/core"], + [Diagnostics.Skipping_build_of_project_0_because_its_dependency_1_has_errors, "/src/animals/tsconfig.json", "/src/core"], + [Diagnostics.Project_0_can_t_be_built_because_its_dependency_1_was_not_built, "src/zoo/tsconfig.json", "src/animals"], + [Diagnostics.Skipping_build_of_project_0_because_its_dependency_1_was_not_built, "/src/zoo/tsconfig.json", "/src/animals"], + ], + expectedOutputs: emptyArray, + notExpectedOutputs: [...coreOutputs(), ...animalOutputs(), ...zooOutputs()] + }); + }); }); }