Skip to content

Commit 116fa78

Browse files
Merge pull request #64 from Microsoft/master
Update upstream
2 parents 8ce880d + a277664 commit 116fa78

9 files changed

+341
-42
lines changed

scripts/mocha-parallel.js

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ function runTests(taskConfigsFolder, run, options, cb) {
7272
current: undefined,
7373
start: undefined,
7474
end: undefined,
75+
catastrophicError: "",
7576
failures: []
7677
};
7778
partitions[index] = partition;
@@ -86,9 +87,20 @@ function runTests(taskConfigsFolder, run, options, cb) {
8687
input: p.stdout,
8788
terminal: false
8889
});
90+
91+
var rlError = readline.createInterface({
92+
input: p.stderr,
93+
terminal: false
94+
});
95+
8996
rl.on("line", onmessage);
97+
rlError.on("line", onErrorMessage);
9098
p.on("exit", onexit)
9199

100+
function onErrorMessage(line) {
101+
partition.catastrophicError += line + os.EOL;
102+
}
103+
92104
function onmessage(line) {
93105
if (partition.start === undefined) {
94106
partition.start = Date.now();
@@ -153,15 +165,17 @@ function runTests(taskConfigsFolder, run, options, cb) {
153165
}
154166
}
155167

156-
function onexit() {
168+
function onexit(code) {
157169
if (partition.end === undefined) {
158170
partition.end = Date.now();
159171
}
160172

161173
partition.duration = partition.end - partition.start;
162-
var summaryColor = partition.failed ? "fail" : "green";
163-
var summarySymbol = partition.failed ? Base.symbols.err : Base.symbols.ok;
164-
var summaryTests = (partition.passed === partition.tests ? partition.passed : partition.passed + "/" + partition.tests) + " passing";
174+
var isPartitionFail = partition.failed || code !== 0;
175+
var summaryColor = isPartitionFail ? "fail" : "green";
176+
var summarySymbol = isPartitionFail ? Base.symbols.err : Base.symbols.ok;
177+
178+
var summaryTests = (isPartitionFail ? partition.passed + "/" + partition.tests : partition.passed) + " passing";
165179
var summaryDuration = "(" + ms(partition.duration) + ")";
166180
var savedUseColors = Base.useColors;
167181
Base.useColors = !options.noColors;
@@ -198,12 +212,34 @@ function runTests(taskConfigsFolder, run, options, cb) {
198212
failures = reporter.failures;
199213

200214
var duration = 0;
215+
var catastrophicError = "";
201216
for (var i = 0; i < numPartitions; i++) {
202217
var partition = partitions[i];
203218
stats.passes += partition.passed;
204219
stats.failures += partition.failed;
205220
stats.tests += partition.tests;
206221
duration += partition.duration;
222+
if (partition.catastrophicError !== "") {
223+
// Partition is written out to a temporary file as a JSON object.
224+
// Below is an example of how the partition JSON object looks like
225+
// {
226+
// "light":false,
227+
// "tasks":[
228+
// {
229+
// "runner":"compiler",
230+
// "files":["tests/cases/compiler/es6ImportNamedImportParsingError.ts"]
231+
// }
232+
// ],
233+
// "runUnitTests":false
234+
// }
235+
var jsonText = fs.readFileSync(partition.file);
236+
var configObj = JSON.parse(jsonText);
237+
if (configObj.tasks && configObj.tasks[0]) {
238+
catastrophicError += "Error from one or more of these files: " + configObj.tasks[0].files + os.EOL;
239+
catastrophicError += partition.catastrophicError;
240+
catastrophicError += os.EOL;
241+
}
242+
}
207243
for (var j = 0; j < partition.failures.length; j++) {
208244
var failure = partition.failures[j];
209245
failures.push(makeMochaTest(failure));
@@ -223,6 +259,9 @@ function runTests(taskConfigsFolder, run, options, cb) {
223259
reporter.epilogue();
224260
}
225261

262+
if (catastrophicError !== "") {
263+
return cb(new Error(catastrophicError));
264+
}
226265
if (stats.failures) {
227266
return cb(new Error("Test failures reported: " + stats.failures));
228267
}

src/harness/fourslash.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -694,7 +694,7 @@ namespace FourSlash {
694694

695695
public verifyCompletionListItemsCountIsGreaterThan(count: number, negative: boolean) {
696696
const completions = this.getCompletionListAtCaret();
697-
const itemsCount = completions.entries.length;
697+
const itemsCount = completions ? completions.entries.length : 0;
698698

699699
if (negative) {
700700
if (itemsCount > count) {
@@ -3521,6 +3521,12 @@ namespace FourSlashInterface {
35213521
"constructor",
35223522
"async"
35233523
];
3524+
public allowedConstructorParameterKeywords = [
3525+
"public",
3526+
"private",
3527+
"protected",
3528+
"readonly",
3529+
];
35243530

35253531
constructor(protected state: FourSlash.TestState, private negative = false) {
35263532
if (!negative) {
@@ -3563,6 +3569,12 @@ namespace FourSlashInterface {
35633569
}
35643570
}
35653571

3572+
public completionListContainsConstructorParameterKeywords() {
3573+
for (const keyword of this.allowedConstructorParameterKeywords) {
3574+
this.completionListContains(keyword, keyword, /*documentation*/ undefined, "keyword");
3575+
}
3576+
}
3577+
35663578
public completionListIsGlobal(expected: boolean) {
35673579
this.state.verifyCompletionListIsGlobal(expected);
35683580
}

src/server/builder.ts

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,10 @@ namespace ts.server {
9393
return this.fileInfos_doNotAccessDirectly || (this.fileInfos_doNotAccessDirectly = createFileMap<T>());
9494
}
9595

96+
protected hasFileInfos() {
97+
return !!this.fileInfos_doNotAccessDirectly;
98+
}
99+
96100
public clear() {
97101
// drop the existing list - it will be re-created as necessary
98102
this.fileInfos_doNotAccessDirectly = undefined;
@@ -130,11 +134,13 @@ namespace ts.server {
130134

131135
abstract getFilesAffectedBy(scriptInfo: ScriptInfo): string[];
132136
abstract onProjectUpdateGraph(): void;
137+
protected abstract ensureFileInfoIfInProject(scriptInfo: ScriptInfo): void;
133138

134139
/**
135140
* @returns {boolean} whether the emit was conducted or not
136141
*/
137142
emitFile(scriptInfo: ScriptInfo, writeFile: (path: string, data: string, writeByteOrderMark?: boolean) => void): boolean {
143+
this.ensureFileInfoIfInProject(scriptInfo);
138144
const fileInfo = this.getFileInfo(scriptInfo.path);
139145
if (!fileInfo) {
140146
return false;
@@ -158,7 +164,21 @@ namespace ts.server {
158164
super(project, BuilderFileInfo);
159165
}
160166

167+
protected ensureFileInfoIfInProject(scriptInfo: ScriptInfo) {
168+
if (this.project.containsScriptInfo(scriptInfo)) {
169+
this.getOrCreateFileInfo(scriptInfo.path);
170+
}
171+
}
172+
161173
onProjectUpdateGraph() {
174+
if (this.hasFileInfos()) {
175+
this.forEachFileInfo(fileInfo => {
176+
if (!this.project.containsScriptInfo(fileInfo.scriptInfo)) {
177+
// This file was deleted from this project
178+
this.removeFileInfo(fileInfo.scriptInfo.path);
179+
}
180+
});
181+
}
162182
}
163183

164184
/**
@@ -262,10 +282,17 @@ namespace ts.server {
262282
return [];
263283
}
264284

265-
onProjectUpdateGraph() {
285+
protected ensureFileInfoIfInProject(_scriptInfo: ScriptInfo) {
266286
this.ensureProjectDependencyGraphUpToDate();
267287
}
268288

289+
onProjectUpdateGraph() {
290+
// Update the graph only if we have computed graph earlier
291+
if (this.hasFileInfos()) {
292+
this.ensureProjectDependencyGraphUpToDate();
293+
}
294+
}
295+
269296
private ensureProjectDependencyGraphUpToDate() {
270297
if (!this.projectVersionForDependencyGraph || this.project.getProjectVersion() !== this.projectVersionForDependencyGraph) {
271298
const currentScriptInfos = this.project.getScriptInfos();
@@ -386,4 +413,4 @@ namespace ts.server {
386413
return new ModuleBuilder(project);
387414
}
388415
}
389-
}
416+
}

0 commit comments

Comments
 (0)