Skip to content

Commit 5234b8b

Browse files
committed
Move more tests into resolutionCache and project errors
1 parent 160c73f commit 5234b8b

File tree

3 files changed

+779
-779
lines changed

3 files changed

+779
-779
lines changed

src/testRunner/unittests/projectErrors.ts

Lines changed: 83 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -481,89 +481,6 @@ namespace ts.projectSystem {
481481
});
482482
});
483483

484-
describe("tsserver:: Project Errors dont include overwrite emit error", () => {
485-
it("for inferred project", () => {
486-
const f1 = {
487-
path: "/a/b/f1.js",
488-
content: "function test1() { }"
489-
};
490-
const host = createServerHost([f1, libFile]);
491-
const session = createSession(host);
492-
openFilesForSession([f1], session);
493-
494-
const projectService = session.getProjectService();
495-
checkNumberOfProjects(projectService, { inferredProjects: 1 });
496-
const projectName = projectService.inferredProjects[0].getProjectName();
497-
498-
const diags = session.executeCommand(<server.protocol.CompilerOptionsDiagnosticsRequest>{
499-
type: "request",
500-
command: server.CommandNames.CompilerOptionsDiagnosticsFull,
501-
seq: 2,
502-
arguments: { projectFileName: projectName }
503-
}).response as ReadonlyArray<protocol.DiagnosticWithLinePosition>;
504-
assert.isTrue(diags.length === 0);
505-
506-
session.executeCommand(<server.protocol.SetCompilerOptionsForInferredProjectsRequest>{
507-
type: "request",
508-
command: server.CommandNames.CompilerOptionsForInferredProjects,
509-
seq: 3,
510-
arguments: { options: { module: ModuleKind.CommonJS } }
511-
});
512-
const diagsAfterUpdate = session.executeCommand(<server.protocol.CompilerOptionsDiagnosticsRequest>{
513-
type: "request",
514-
command: server.CommandNames.CompilerOptionsDiagnosticsFull,
515-
seq: 4,
516-
arguments: { projectFileName: projectName }
517-
}).response as ReadonlyArray<protocol.DiagnosticWithLinePosition>;
518-
assert.isTrue(diagsAfterUpdate.length === 0);
519-
});
520-
521-
it("for external project", () => {
522-
const f1 = {
523-
path: "/a/b/f1.js",
524-
content: "function test1() { }"
525-
};
526-
const host = createServerHost([f1, libFile]);
527-
const session = createSession(host);
528-
const projectService = session.getProjectService();
529-
const projectFileName = "/a/b/project.csproj";
530-
const externalFiles = toExternalFiles([f1.path]);
531-
projectService.openExternalProject(<protocol.ExternalProject>{
532-
projectFileName,
533-
rootFiles: externalFiles,
534-
options: {}
535-
});
536-
537-
checkNumberOfProjects(projectService, { externalProjects: 1 });
538-
539-
const diags = session.executeCommand(<server.protocol.CompilerOptionsDiagnosticsRequest>{
540-
type: "request",
541-
command: server.CommandNames.CompilerOptionsDiagnosticsFull,
542-
seq: 2,
543-
arguments: { projectFileName }
544-
}).response as ReadonlyArray<server.protocol.DiagnosticWithLinePosition>;
545-
assert.isTrue(diags.length === 0);
546-
547-
session.executeCommand(<server.protocol.OpenExternalProjectRequest>{
548-
type: "request",
549-
command: server.CommandNames.OpenExternalProject,
550-
seq: 3,
551-
arguments: {
552-
projectFileName,
553-
rootFiles: externalFiles,
554-
options: { module: ModuleKind.CommonJS }
555-
}
556-
});
557-
const diagsAfterUpdate = session.executeCommand(<server.protocol.CompilerOptionsDiagnosticsRequest>{
558-
type: "request",
559-
command: server.CommandNames.CompilerOptionsDiagnosticsFull,
560-
seq: 4,
561-
arguments: { projectFileName }
562-
}).response as ReadonlyArray<server.protocol.DiagnosticWithLinePosition>;
563-
assert.isTrue(diagsAfterUpdate.length === 0);
564-
});
565-
});
566-
567484
describe("tsserver:: Project Errors for Configure file diagnostics events", () => {
568485
function getUnknownCompilerOptionDiagnostic(configFile: File, prop: string): ConfigFileDiagnostic {
569486
const d = Diagnostics.Unknown_compiler_option_0;
@@ -754,6 +671,89 @@ namespace ts.projectSystem {
754671
});
755672
});
756673

674+
describe("tsserver:: Project Errors dont include overwrite emit error", () => {
675+
it("for inferred project", () => {
676+
const f1 = {
677+
path: "/a/b/f1.js",
678+
content: "function test1() { }"
679+
};
680+
const host = createServerHost([f1, libFile]);
681+
const session = createSession(host);
682+
openFilesForSession([f1], session);
683+
684+
const projectService = session.getProjectService();
685+
checkNumberOfProjects(projectService, { inferredProjects: 1 });
686+
const projectName = projectService.inferredProjects[0].getProjectName();
687+
688+
const diags = session.executeCommand(<server.protocol.CompilerOptionsDiagnosticsRequest>{
689+
type: "request",
690+
command: server.CommandNames.CompilerOptionsDiagnosticsFull,
691+
seq: 2,
692+
arguments: { projectFileName: projectName }
693+
}).response as ReadonlyArray<protocol.DiagnosticWithLinePosition>;
694+
assert.isTrue(diags.length === 0);
695+
696+
session.executeCommand(<server.protocol.SetCompilerOptionsForInferredProjectsRequest>{
697+
type: "request",
698+
command: server.CommandNames.CompilerOptionsForInferredProjects,
699+
seq: 3,
700+
arguments: { options: { module: ModuleKind.CommonJS } }
701+
});
702+
const diagsAfterUpdate = session.executeCommand(<server.protocol.CompilerOptionsDiagnosticsRequest>{
703+
type: "request",
704+
command: server.CommandNames.CompilerOptionsDiagnosticsFull,
705+
seq: 4,
706+
arguments: { projectFileName: projectName }
707+
}).response as ReadonlyArray<protocol.DiagnosticWithLinePosition>;
708+
assert.isTrue(diagsAfterUpdate.length === 0);
709+
});
710+
711+
it("for external project", () => {
712+
const f1 = {
713+
path: "/a/b/f1.js",
714+
content: "function test1() { }"
715+
};
716+
const host = createServerHost([f1, libFile]);
717+
const session = createSession(host);
718+
const projectService = session.getProjectService();
719+
const projectFileName = "/a/b/project.csproj";
720+
const externalFiles = toExternalFiles([f1.path]);
721+
projectService.openExternalProject(<protocol.ExternalProject>{
722+
projectFileName,
723+
rootFiles: externalFiles,
724+
options: {}
725+
});
726+
727+
checkNumberOfProjects(projectService, { externalProjects: 1 });
728+
729+
const diags = session.executeCommand(<server.protocol.CompilerOptionsDiagnosticsRequest>{
730+
type: "request",
731+
command: server.CommandNames.CompilerOptionsDiagnosticsFull,
732+
seq: 2,
733+
arguments: { projectFileName }
734+
}).response as ReadonlyArray<server.protocol.DiagnosticWithLinePosition>;
735+
assert.isTrue(diags.length === 0);
736+
737+
session.executeCommand(<server.protocol.OpenExternalProjectRequest>{
738+
type: "request",
739+
command: server.CommandNames.OpenExternalProject,
740+
seq: 3,
741+
arguments: {
742+
projectFileName,
743+
rootFiles: externalFiles,
744+
options: { module: ModuleKind.CommonJS }
745+
}
746+
});
747+
const diagsAfterUpdate = session.executeCommand(<server.protocol.CompilerOptionsDiagnosticsRequest>{
748+
type: "request",
749+
command: server.CommandNames.CompilerOptionsDiagnosticsFull,
750+
seq: 4,
751+
arguments: { projectFileName }
752+
}).response as ReadonlyArray<server.protocol.DiagnosticWithLinePosition>;
753+
assert.isTrue(diagsAfterUpdate.length === 0);
754+
});
755+
});
756+
757757
describe("tsserver:: Project Errors reports Options Diagnostic locations correctly with changes in configFile contents", () => {
758758
it("when options change", () => {
759759
const file = {

0 commit comments

Comments
 (0)