Skip to content

Commit 649e40b

Browse files
committed
Merge pull request microsoft#3820 from Microsoft/newMochaReporters
New mocha reporter
2 parents c5aa3ad + 15a8544 commit 649e40b

File tree

5 files changed

+186
-177
lines changed

5 files changed

+186
-177
lines changed

Jakefile.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,7 @@ task("runtests", ["tests", builtLocalDirectory], function() {
566566
colors = process.env.colors || process.env.color
567567
colors = colors ? ' --no-colors ' : ' --colors ';
568568
tests = tests ? ' -g ' + tests : '';
569-
reporter = process.env.reporter || process.env.r || 'dot';
569+
reporter = process.env.reporter || process.env.r || 'mocha-fivemat-progress-reporter';
570570
// timeout normally isn't necessary but Travis-CI has been timing out on compiler baselines occasionally
571571
// default timeout is 2sec which really should be enough, but maybe we just need a small amount longer
572572
var cmd = host + " -R " + reporter + tests + colors + ' -t ' + testTimeout + ' ' + run;

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
"chai": "latest",
3535
"browserify": "latest",
3636
"istanbul": "latest",
37+
"mocha-fivemat-progress-reporter": "latest",
3738
"tslint": "latest"
3839
},
3940
"scripts": {

src/harness/compilerRunner.ts

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const enum CompilerTestType {
1010

1111
class CompilerBaselineRunner extends RunnerBase {
1212
private basePath = 'tests/cases';
13+
private testSuiteName: string;
1314
private errors: boolean;
1415
private emit: boolean;
1516
private decl: boolean;
@@ -24,16 +25,17 @@ class CompilerBaselineRunner extends RunnerBase {
2425
this.decl = true;
2526
this.output = true;
2627
if (testType === CompilerTestType.Conformance) {
27-
this.basePath += '/conformance';
28+
this.testSuiteName = 'conformance';
2829
}
2930
else if (testType === CompilerTestType.Regressions) {
30-
this.basePath += '/compiler';
31+
this.testSuiteName = 'compiler';
3132
}
3233
else if (testType === CompilerTestType.Test262) {
33-
this.basePath += '/test262';
34+
this.testSuiteName = 'test262';
3435
} else {
35-
this.basePath += '/compiler'; // default to this for historical reasons
36+
this.testSuiteName = 'compiler'; // default to this for historical reasons
3637
}
38+
this.basePath += '/' + this.testSuiteName;
3739
}
3840

3941
public checkTestCodeOutput(fileName: string) {
@@ -100,7 +102,7 @@ class CompilerBaselineRunner extends RunnerBase {
100102
});
101103

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

262264
// NEWTODO: Type baselines
263265
if (result.errors.length === 0) {
264-
// The full walker simulates the types that you would get from doing a full
266+
// The full walker simulates the types that you would get from doing a full
265267
// compile. The pull walker simulates the types you get when you just do
266268
// a type query for a random node (like how the LS would do it). Most of the
267269
// time, these will be the same. However, occasionally, they can be different.
268270
// 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
271+
// things, then we may see different results because symbols can be created in a
270272
// different order with 'pull' operations, and thus can produce slightly differing
271273
// output.
272274
//
273275
// For example, with a full type check, we may see a type outputed as: number | string
274276
// But with a pull type check, we may see it as: string | number
275277
//
276-
// These types are equivalent, but depend on what order the compiler observed
278+
// These types are equivalent, but depend on what order the compiler observed
277279
// certain parts of the program.
278280

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

386388
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);
389+
describe(this.testSuiteName + ' tests', () => {
390+
describe("Setup compiler for compiler baselines", () => {
391+
var harnessCompiler = Harness.Compiler.getCompiler();
392+
this.parseOptions();
398393
});
399-
}
400-
else {
401-
this.tests.forEach(test => this.checkTestCodeOutput(test));
402-
}
403394

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

@@ -434,4 +438,4 @@ class CompilerBaselineRunner extends RunnerBase {
434438
}
435439
}
436440
}
437-
}
441+
}

src/harness/fourslashRunner.ts

Lines changed: 63 additions & 61 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-
this.tests.forEach((fn: string) => {
39-
describe(fn, () => {
40-
fn = ts.normalizeSlashes(fn);
41-
var justName = fn.replace(/^.*[\\\/]/, '');
38+
describe(this.testSuiteName + ' tests', () => {
39+
this.tests.forEach((fn: string) => {
40+
describe(fn, () => {
41+
fn = ts.normalizeSlashes(fn);
42+
var justName = fn.replace(/^.*[\\\/]/, '');
43+
44+
// Convert to relative path
45+
var testIndex = fn.indexOf('tests/');
46+
if (testIndex >= 0) fn = fn.substr(testIndex);
4247

43-
// Convert to relative path
44-
var testIndex = fn.indexOf('tests/');
45-
if (testIndex >= 0) fn = fn.substr(testIndex);
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+
});
54+
});
4655

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-
});
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+
}
5168
}
52-
});
53-
});
69+
invalidReport.sort((lhs, rhs) => lhs.count > rhs.count ? -1 : lhs.count === rhs.count ? 0 : 1);
5470

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-
}
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'));
61103
});
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] });
66-
}
67-
}
68-
invalidReport.sort((lhs, rhs) => lhs.count > rhs.count ? -1 : lhs.count === rhs.count ? 0 : 1);
69-
70-
var lines: string[] = [];
71-
lines.push('<!-- Blocked Test Report');
72-
invalidReport.forEach((reasonAndCount) => {
73-
lines.push(reasonAndCount.count + ' tests blocked by ' + reasonAndCount.reason);
74-
});
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)