Skip to content

Commit 6405600

Browse files
committed
Create top level describe block for runners so status is reported at runner level
1 parent 8cdd59f commit 6405600

File tree

3 files changed

+175
-169
lines changed

3 files changed

+175
-169
lines changed

src/harness/compilerRunner.ts

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ class CompilerBaselineRunner extends RunnerBase {
100100
});
101101

102102
beforeEach(() => {
103-
/* The compiler doesn't handle certain flags flipping during a single compilation setting. Tests on these flags will need
103+
/* The compiler doesn't handle certain flags flipping during a single compilation setting. Tests on these flags will need
104104
a fresh compiler instance for themselves and then create a fresh one for the next test. Would be nice to get dev fixes
105105
eventually to remove this limitation. */
106106
for (var i = 0; i < tcSettings.length; ++i) {
@@ -261,19 +261,19 @@ class CompilerBaselineRunner extends RunnerBase {
261261

262262
// NEWTODO: Type baselines
263263
if (result.errors.length === 0) {
264-
// The full walker simulates the types that you would get from doing a full
264+
// The full walker simulates the types that you would get from doing a full
265265
// compile. The pull walker simulates the types you get when you just do
266266
// a type query for a random node (like how the LS would do it). Most of the
267267
// time, these will be the same. However, occasionally, they can be different.
268268
// Specifically, when the compiler internally depends on symbol IDs to order
269-
// things, then we may see different results because symbols can be created in a
269+
// things, then we may see different results because symbols can be created in a
270270
// different order with 'pull' operations, and thus can produce slightly differing
271271
// output.
272272
//
273273
// For example, with a full type check, we may see a type outputed as: number | string
274274
// But with a pull type check, we may see it as: string | number
275275
//
276-
// These types are equivalent, but depend on what order the compiler observed
276+
// These types are equivalent, but depend on what order the compiler observed
277277
// certain parts of the program.
278278

279279
let allFiles = toBeCompiled.concat(otherFiles).filter(file => !!program.getSourceFile(file.unitName));
@@ -384,25 +384,27 @@ class CompilerBaselineRunner extends RunnerBase {
384384
}
385385

386386
public initializeTests() {
387-
describe("Setup compiler for compiler baselines", () => {
388-
var harnessCompiler = Harness.Compiler.getCompiler();
389-
this.parseOptions();
390-
});
391-
392-
// this will set up a series of describe/it blocks to run between the setup and cleanup phases
393-
if (this.tests.length === 0) {
394-
var testFiles = this.enumerateFiles(this.basePath, /\.tsx?$/, { recursive: true });
395-
testFiles.forEach(fn => {
396-
fn = fn.replace(/\\/g, "/");
397-
this.checkTestCodeOutput(fn);
387+
describe('Compiler tests', () => {
388+
describe("Setup compiler for compiler baselines", () => {
389+
var harnessCompiler = Harness.Compiler.getCompiler();
390+
this.parseOptions();
398391
});
399-
}
400-
else {
401-
this.tests.forEach(test => this.checkTestCodeOutput(test));
402-
}
403392

404-
describe("Cleanup after compiler baselines", () => {
405-
var harnessCompiler = Harness.Compiler.getCompiler();
393+
// this will set up a series of describe/it blocks to run between the setup and cleanup phases
394+
if (this.tests.length === 0) {
395+
var testFiles = this.enumerateFiles(this.basePath, /\.tsx?$/, { recursive: true });
396+
testFiles.forEach(fn => {
397+
fn = fn.replace(/\\/g, "/");
398+
this.checkTestCodeOutput(fn);
399+
});
400+
}
401+
else {
402+
this.tests.forEach(test => this.checkTestCodeOutput(test));
403+
}
404+
405+
describe("Cleanup after compiler baselines", () => {
406+
var harnessCompiler = Harness.Compiler.getCompiler();
407+
});
406408
});
407409
}
408410

@@ -434,4 +436,4 @@ class CompilerBaselineRunner extends RunnerBase {
434436
}
435437
}
436438
}
437-
}
439+
}

src/harness/fourslashRunner.ts

Lines changed: 60 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
///<reference path='harness.ts'/>
33
///<reference path='runnerbase.ts' />
44

5-
const enum FourSlashTestType {
5+
const enum FourSlashTestType {
66
Native,
77
Shims,
88
Server
@@ -35,70 +35,72 @@ class FourSlashRunner extends RunnerBase {
3535
this.tests = this.enumerateFiles(this.basePath, /\.ts/i, { recursive: false });
3636
}
3737

38+
describe('Fourslash tests', () => {
3839
this.tests.forEach((fn: string) => {
39-
describe(fn, () => {
40-
fn = ts.normalizeSlashes(fn);
41-
var justName = fn.replace(/^.*[\\\/]/, '');
40+
describe(fn, () => {
41+
fn = ts.normalizeSlashes(fn);
42+
var justName = fn.replace(/^.*[\\\/]/, '');
4243

43-
// Convert to relative path
44-
var testIndex = fn.indexOf('tests/');
45-
if (testIndex >= 0) fn = fn.substr(testIndex);
44+
// Convert to relative path
45+
var testIndex = fn.indexOf('tests/');
46+
if (testIndex >= 0) fn = fn.substr(testIndex);
4647

47-
if (justName && !justName.match(/fourslash\.ts$/i) && !justName.match(/\.d\.ts$/i)) {
48-
it(this.testSuiteName + ' test ' + justName + ' runs correctly',() => {
49-
FourSlash.runFourSlashTest(this.basePath, this.testType, fn);
50-
});
51-
}
48+
if (justName && !justName.match(/fourslash\.ts$/i) && !justName.match(/\.d\.ts$/i)) {
49+
it(this.testSuiteName + ' test ' + justName + ' runs correctly',() => {
50+
FourSlash.runFourSlashTest(this.basePath, this.testType, fn);
51+
});
52+
}
53+
});
5254
});
53-
});
5455

55-
describe('Generate Tao XML', () => {
56-
var invalidReasons: any = {};
57-
FourSlash.xmlData.forEach(xml => {
58-
if (xml.invalidReason !== null) {
59-
invalidReasons[xml.invalidReason] = (invalidReasons[xml.invalidReason] || 0) + 1;
60-
}
61-
});
62-
var invalidReport: { reason: string; count: number }[] = [];
63-
for (var reason in invalidReasons) {
64-
if (invalidReasons.hasOwnProperty(reason)) {
65-
invalidReport.push({ reason: reason, count: invalidReasons[reason] });
56+
describe('Generate Tao XML', () => {
57+
var invalidReasons: any = {};
58+
FourSlash.xmlData.forEach(xml => {
59+
if (xml.invalidReason !== null) {
60+
invalidReasons[xml.invalidReason] = (invalidReasons[xml.invalidReason] || 0) + 1;
61+
}
62+
});
63+
var invalidReport: { reason: string; count: number }[] = [];
64+
for (var reason in invalidReasons) {
65+
if (invalidReasons.hasOwnProperty(reason)) {
66+
invalidReport.push({ reason: reason, count: invalidReasons[reason] });
67+
}
6668
}
67-
}
68-
invalidReport.sort((lhs, rhs) => lhs.count > rhs.count ? -1 : lhs.count === rhs.count ? 0 : 1);
69+
invalidReport.sort((lhs, rhs) => lhs.count > rhs.count ? -1 : lhs.count === rhs.count ? 0 : 1);
6970

70-
var lines: string[] = [];
71-
lines.push('<!-- Blocked Test Report');
72-
invalidReport.forEach((reasonAndCount) => {
73-
lines.push(reasonAndCount.count + ' tests blocked by ' + reasonAndCount.reason);
71+
var lines: string[] = [];
72+
lines.push('<!-- Blocked Test Report');
73+
invalidReport.forEach((reasonAndCount) => {
74+
lines.push(reasonAndCount.count + ' tests blocked by ' + reasonAndCount.reason);
75+
});
76+
lines.push('-->');
77+
lines.push('<TaoTest xmlns="http://microsoft.com/schemas/VSLanguages/TAO">');
78+
lines.push(' <InitTest>');
79+
lines.push(' <StartTarget />');
80+
lines.push(' </InitTest>');
81+
lines.push(' <ScenarioList>');
82+
FourSlash.xmlData.forEach(xml => {
83+
if (xml.invalidReason !== null) {
84+
lines.push('<!-- Skipped ' + xml.originalName + ', reason: ' + xml.invalidReason + ' -->');
85+
} else {
86+
lines.push(' <Scenario Name="' + xml.originalName + '">');
87+
xml.actions.forEach(action => {
88+
lines.push(' ' + action);
89+
});
90+
lines.push(' </Scenario>');
91+
}
92+
});
93+
lines.push(' </ScenarioList>');
94+
lines.push(' <CleanupScenario>');
95+
lines.push(' <CloseAllDocuments />');
96+
lines.push(' <CleanupCreatedFiles />');
97+
lines.push(' </CleanupScenario>');
98+
lines.push(' <CleanupTest>');
99+
lines.push(' <CloseTarget />');
100+
lines.push(' </CleanupTest>');
101+
lines.push('</TaoTest>');
102+
Harness.IO.writeFile('built/local/fourslash.xml', lines.join('\r\n'));
74103
});
75-
lines.push('-->');
76-
lines.push('<TaoTest xmlns="http://microsoft.com/schemas/VSLanguages/TAO">');
77-
lines.push(' <InitTest>');
78-
lines.push(' <StartTarget />');
79-
lines.push(' </InitTest>');
80-
lines.push(' <ScenarioList>');
81-
FourSlash.xmlData.forEach(xml => {
82-
if (xml.invalidReason !== null) {
83-
lines.push('<!-- Skipped ' + xml.originalName + ', reason: ' + xml.invalidReason + ' -->');
84-
} else {
85-
lines.push(' <Scenario Name="' + xml.originalName + '">');
86-
xml.actions.forEach(action => {
87-
lines.push(' ' + action);
88-
});
89-
lines.push(' </Scenario>');
90-
}
91-
});
92-
lines.push(' </ScenarioList>');
93-
lines.push(' <CleanupScenario>');
94-
lines.push(' <CloseAllDocuments />');
95-
lines.push(' <CleanupCreatedFiles />');
96-
lines.push(' </CleanupScenario>');
97-
lines.push(' <CleanupTest>');
98-
lines.push(' <CloseTarget />');
99-
lines.push(' </CleanupTest>');
100-
lines.push('</TaoTest>');
101-
Harness.IO.writeFile('built/local/fourslash.xml', lines.join('\r\n'));
102104
});
103105
}
104106
}
@@ -108,4 +110,4 @@ class GeneratedFourslashRunner extends FourSlashRunner {
108110
super(testType);
109111
this.basePath += '/generated/';
110112
}
111-
}
113+
}

0 commit comments

Comments
 (0)