Skip to content

Commit d2a11b5

Browse files
committed
merge with master
2 parents 7d09f26 + 847a074 commit d2a11b5

File tree

116 files changed

+33014
-223
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

116 files changed

+33014
-223
lines changed

Jakefile.js

+42-15
Original file line numberDiff line numberDiff line change
@@ -626,9 +626,7 @@ function deleteTemporaryProjectOutput() {
626626
}
627627
}
628628

629-
var testTimeout = 20000;
630-
desc("Runs the tests using the built run.js file. Syntax is jake runtests. Optional parameters 'host=', 'tests=[regex], reporter=[list|spec|json|<more>]', debug=true.");
631-
task("runtests", ["build-rules", "tests", builtLocalDirectory], function() {
629+
function runConsoleTests(defaultReporter, defaultSubsets, postLint) {
632630
cleanTestDirs();
633631
var debug = process.env.debug || process.env.d;
634632
tests = process.env.test || process.env.tests || process.env.t;
@@ -638,7 +636,7 @@ task("runtests", ["build-rules", "tests", builtLocalDirectory], function() {
638636
fs.unlinkSync(testConfigFile);
639637
}
640638

641-
if(tests || light) {
639+
if (tests || light) {
642640
writeTestConfigFile(tests, light, testConfigFile);
643641
}
644642

@@ -648,20 +646,48 @@ task("runtests", ["build-rules", "tests", builtLocalDirectory], function() {
648646

649647
colors = process.env.colors || process.env.color
650648
colors = colors ? ' --no-colors ' : ' --colors ';
651-
tests = tests ? ' -g ' + tests : '';
652-
reporter = process.env.reporter || process.env.r || 'mocha-fivemat-progress-reporter';
649+
reporter = process.env.reporter || process.env.r || defaultReporter;
650+
653651
// timeout normally isn't necessary but Travis-CI has been timing out on compiler baselines occasionally
654652
// default timeout is 2sec which really should be enough, but maybe we just need a small amount longer
655-
var cmd = "mocha" + (debug ? " --debug-brk" : "") + " -R " + reporter + tests + colors + ' -t ' + testTimeout + ' ' + run;
656-
console.log(cmd);
657-
exec(cmd, function() {
658-
deleteTemporaryProjectOutput();
659-
var lint = jake.Task['lint'];
660-
lint.addListener('complete', function () {
661-
complete();
653+
var subsetRegexes;
654+
if(defaultSubsets.length === 0) {
655+
subsetRegexes = [tests]
656+
}
657+
else {
658+
var subsets = tests ? tests.split("|") : defaultSubsets;
659+
subsetRegexes = subsets.map(function (sub) { return "^" + sub + ".*$"; });
660+
subsetRegexes.push("^(?!" + subsets.join("|") + ").*$");
661+
}
662+
subsetRegexes.forEach(function (subsetRegex) {
663+
tests = subsetRegex ? ' -g "' + subsetRegex + '"' : '';
664+
var cmd = "mocha" + (debug ? " --debug-brk" : "") + " -R " + reporter + tests + colors + ' -t ' + testTimeout + ' ' + run;
665+
console.log(cmd);
666+
exec(cmd, function () {
667+
deleteTemporaryProjectOutput();
668+
if (postLint) {
669+
var lint = jake.Task['lint'];
670+
lint.addListener('complete', function () {
671+
complete();
672+
});
673+
lint.invoke();
674+
}
675+
else {
676+
complete();
677+
}
662678
});
663-
lint.invoke();
664679
});
680+
}
681+
682+
var testTimeout = 20000;
683+
desc("Runs all the tests in parallel using the built run.js file. Optional arguments are: t[ests]=category1|category2|... d[ebug]=true.");
684+
task("runtests-parallel", ["build-rules", "tests", builtLocalDirectory], function() {
685+
runConsoleTests('min', ['compiler', 'conformance', 'Projects', 'fourslash']);
686+
}, {async: true});
687+
688+
desc("Runs the tests using the built run.js file. Optional arguments are: t[ests]=regex r[eporter]=[list|spec|json|<more>] d[ebug]=true color[s]=false.");
689+
task("runtests", ["build-rules", "tests", builtLocalDirectory], function() {
690+
runConsoleTests('mocha-fivemat-progress-reporter', [], /*postLint*/ true);
665691
}, {async: true});
666692

667693
desc("Generates code coverage data via instanbul");
@@ -820,7 +846,8 @@ var tslintRuleDir = "scripts/tslint";
820846
var tslintRules = ([
821847
"nextLineRule",
822848
"noNullRule",
823-
"booleanTriviaRule"
849+
"booleanTriviaRule",
850+
"typeOperatorSpacingRule"
824851
]);
825852
var tslintRulesFiles = tslintRules.map(function(p) {
826853
return path.join(tslintRuleDir, p + ".ts");

scripts/processDiagnosticMessages.ts

+38-6
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@ function main(): void {
1818
return;
1919
}
2020

21+
function writeFile(fileName: string, contents: string) {
22+
// TODO: Fix path joining
23+
var inputDirectory = inputFilePath.substr(0,inputFilePath.lastIndexOf("/"));
24+
var fileOutputPath = inputDirectory + "/" + fileName;
25+
sys.writeFile(fileOutputPath, contents);
26+
}
27+
2128
var inputFilePath = sys.args[0].replace(/\\/g, "/");
2229
var inputStr = sys.readFile(inputFilePath);
2330

@@ -28,11 +35,10 @@ function main(): void {
2835

2936
var infoFileOutput = buildInfoFileOutput(diagnosticMessages, nameMap);
3037
checkForUniqueCodes(names, diagnosticMessages);
38+
writeFile("diagnosticInformationMap.generated.ts", infoFileOutput);
3139

32-
// TODO: Fix path joining
33-
var inputDirectory = inputFilePath.substr(0,inputFilePath.lastIndexOf("/"));
34-
var fileOutputPath = inputDirectory + "/diagnosticInformationMap.generated.ts";
35-
sys.writeFile(fileOutputPath, infoFileOutput);
40+
var messageOutput = buildDiagnosticMessageOutput(diagnosticMessages, nameMap);
41+
writeFile("diagnosticMessages.generated.json", messageOutput);
3642
}
3743

3844
function checkForUniqueCodes(messages: string[], diagnosticTable: InputDiagnosticMessageTable) {
@@ -85,12 +91,14 @@ function buildInfoFileOutput(messageTable: InputDiagnosticMessageTable, nameMap:
8591
for (var i = 0; i < names.length; i++) {
8692
var name = names[i];
8793
var diagnosticDetails = messageTable[name];
94+
var propName = convertPropertyName(nameMap[name]);
8895

8996
result +=
90-
' ' + convertPropertyName(nameMap[name]) +
97+
' ' + propName +
9198
': { code: ' + diagnosticDetails.code +
9299
', category: DiagnosticCategory.' + diagnosticDetails.category +
93-
', key: "' + name.replace(/[\"]/g, '\\"') + '"' +
100+
', key: "' + createKey(propName, diagnosticDetails.code) + '"' +
101+
', message: "' + name.replace(/[\"]/g, '\\"') + '"' +
94102
' },\r\n';
95103
}
96104

@@ -99,6 +107,30 @@ function buildInfoFileOutput(messageTable: InputDiagnosticMessageTable, nameMap:
99107
return result;
100108
}
101109

110+
function buildDiagnosticMessageOutput(messageTable: InputDiagnosticMessageTable, nameMap: ts.Map<string>): string {
111+
var result =
112+
'{';
113+
var names = Utilities.getObjectKeys(messageTable);
114+
for (var i = 0; i < names.length; i++) {
115+
var name = names[i];
116+
var diagnosticDetails = messageTable[name];
117+
var propName = convertPropertyName(nameMap[name]);
118+
119+
result += '\r\n "' + createKey(propName, diagnosticDetails.code) + '"' + ' : "' + name.replace(/[\"]/g, '\\"') + '"';
120+
if (i !== names.length - 1) {
121+
result += ',';
122+
}
123+
}
124+
125+
result += '\r\n}';
126+
127+
return result;
128+
}
129+
130+
function createKey(name: string, code: number) : string {
131+
return name.slice(0, 100) + '_' + code;
132+
}
133+
102134
function convertPropertyName(origName: string): string {
103135
var result = origName.split("").map(char => {
104136
if (char === '*') { return "_Asterisk"; }
+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/// <reference path="../../node_modules/tslint/typings/typescriptServices.d.ts" />
2+
/// <reference path="../../node_modules/tslint/lib/tslint.d.ts" />
3+
4+
5+
export class Rule extends Lint.Rules.AbstractRule {
6+
public static FAILURE_STRING = "The '|' and '&' operators must be surrounded by single spaces";
7+
8+
public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] {
9+
return this.applyWithWalker(new TypeOperatorSpacingWalker(sourceFile, this.getOptions()));
10+
}
11+
}
12+
13+
class TypeOperatorSpacingWalker extends Lint.RuleWalker {
14+
public visitNode(node: ts.Node) {
15+
if (node.kind === ts.SyntaxKind.UnionType || node.kind === ts.SyntaxKind.IntersectionType) {
16+
let types = (<ts.UnionOrIntersectionTypeNode>node).types;
17+
let expectedStart = types[0].end + 2; // space, | or &
18+
for (let i = 1; i < types.length; i++) {
19+
let currentType = types[i];
20+
if (expectedStart !== currentType.pos || currentType.getLeadingTriviaWidth() !== 1) {
21+
const failure = this.createFailure(currentType.pos, currentType.getWidth(), Rule.FAILURE_STRING);
22+
this.addFailure(failure);
23+
}
24+
expectedStart = currentType.end + 2;
25+
}
26+
}
27+
super.visitNode(node);
28+
}
29+
}

0 commit comments

Comments
 (0)