Skip to content

Commit 46e4c63

Browse files
committed
Fix remaining debug failures.
1 parent 734f161 commit 46e4c63

11 files changed

Lines changed: 122 additions & 78 deletions

File tree

Jakefile.js

Lines changed: 57 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -675,14 +675,24 @@ function cleanTestDirs() {
675675

676676
// used to pass data from jake command line directly to run.js
677677
function writeTestConfigFile(testConfigFile, tests, light, stackTraceLimit) {
678-
console.log('Running test(s): ' + tests);
679-
var testConfig = { test: [tests], light: light };
678+
var testConfig;
679+
if (tests) {
680+
console.log('Running test(s): ' + tests);
681+
(testConfig || (testConfig = {})).tests = [tests];
682+
}
683+
684+
if (light) {
685+
(testConfig || (testConfig = {})).light = light;
686+
}
687+
680688
if (/^(\d+|full)$/.test(stackTraceLimit)) {
681-
testConfig.stackTraceLimit = stackTraceLimit;
689+
(testConfig || (testConfig = {})).stackTraceLimit = stackTraceLimit;
682690
}
683691

684-
var testConfigContents = JSON.stringify(testConfig);
685-
fs.writeFileSync('test.config', testConfigContents);
692+
if (testConfig) {
693+
var testConfigContents = JSON.stringify(testConfig);
694+
fs.writeFileSync(testConfigFile, testConfigContents);
695+
}
686696
}
687697

688698
function deleteTemporaryProjectOutput() {
@@ -700,9 +710,7 @@ function runTestsAndWriteOutput(file) {
700710
fs.unlinkSync(testConfigFile);
701711
}
702712

703-
if (tests || light) {
704-
writeTestConfigFile(testConfigFile, tests, light, 10);
705-
}
713+
writeTestConfigFile(testConfigFile, tests, light, 10);
706714

707715
if (tests && tests.toLocaleLowerCase() === "rwc") {
708716
testTimeout = 100000;
@@ -719,11 +727,16 @@ function runTestsAndWriteOutput(file) {
719727

720728
var cmd = "mocha " + args.join(" ");
721729
console.log(cmd);
722-
var ex = jake.createExec([cmd], { windowsVerbatimArguments: true });
730+
var p = child_process.spawn(
731+
process.platform === "win32" ? "cmd" : "/bin/sh",
732+
process.platform === "win32" ? ["/c", cmd] : ["-c", cmd], {
733+
windowsVerbatimArguments: true
734+
});
735+
723736
var out = fs.createWriteStream(file);
724737
var tapRange = /^(\d+)\.\.(\d+)(?:$|\r\n?|\n)/;
725738
var tapOk = /^ok\s/;
726-
var tapNotOk = /^not\sok/;
739+
var tapNotOk = /^not\sok\s/;
727740
var tapComment = /^#/;
728741
var typeError = /^\s+TypeError:/;
729742
var debugError = /^\s+Error:\sDebug\sFailure\./;
@@ -736,29 +749,46 @@ function runTestsAndWriteOutput(file) {
736749
var typeErrorCount = 0;
737750
var debugErrorCount = 0;
738751

739-
ex.addListener("stdout", function (output) {
740-
var m = tapRange.exec(output);
752+
var rl = readline.createInterface({
753+
input: p.stdout,
754+
terminal: false
755+
});
756+
757+
function updateProgress(percentComplete) {
758+
progress.update(percentComplete,
759+
/*foregroundColor*/ failureCount > 0
760+
? "red"
761+
: successCount === expectedTestCount
762+
? "green"
763+
: "cyan",
764+
/*backgroundColor*/ "gray"
765+
);
766+
}
767+
768+
rl.on("line", function (line) {
769+
var m = tapRange.exec(line);
741770
if (m) {
742771
expectedTestCount = parseInt(m[2]);
743772
return;
744773
}
745774

746-
out.write(output);
747-
748-
if (tapOk.test(output)) {
775+
if (tapOk.test(line)) {
776+
out.write(line.replace(/^ok\s+\d+\s+/, "ok ") + os.EOL);
749777
successCount++;
750778
}
751-
else if (tapNotOk.test(output)) {
779+
else if (tapNotOk.test(line)) {
780+
out.write(line.replace(/^not\s+ok\s+\d+\s+/, "not ok ") + os.EOL);
752781
failureCount++;
753782
}
754783
else {
755-
if (tapComment.test(output)) {
756-
comments.push(output.toString().trim());
784+
out.write(line + os.EOL);
785+
if (tapComment.test(line)) {
786+
comments.push(line);
757787
}
758-
else if (typeError.test(output)) {
788+
else if (typeError.test(line)) {
759789
typeErrorCount++;
760790
}
761-
else if (debugError.test(output)) {
791+
else if (debugError.test(line)) {
762792
debugErrorCount++;
763793
}
764794
return;
@@ -770,33 +800,7 @@ function runTestsAndWriteOutput(file) {
770800
updateProgress(percentComplete);
771801
});
772802

773-
function updateProgress(percentComplete) {
774-
progress.update(percentComplete,
775-
/*foregroundColor*/ failureCount > 0
776-
? "red"
777-
: successCount === expectedTestCount
778-
? "green"
779-
: "cyan",
780-
/*backgroundColor*/ "gray"
781-
);
782-
}
783-
784-
ex.addListener("stderr", function (output) {
785-
progress.hide();
786-
process.stderr.write(output.toString().trim() + os.EOL);
787-
progress.show();
788-
});
789-
ex.addListener("cmdEnd", function () {
790-
if (progress.visible) {
791-
updateProgress(100);
792-
process.stdout.write("done." + os.EOL);
793-
}
794-
795-
console.log(comments.join(os.EOL));
796-
deleteTemporaryProjectOutput();
797-
complete();
798-
});
799-
ex.addListener("error", function (e, status) {
803+
p.on("exit", function (status) {
800804
if (progress.visible) {
801805
updateProgress(100);
802806
process.stdout.write("done." + os.EOL);
@@ -813,9 +817,13 @@ function runTestsAndWriteOutput(file) {
813817
}
814818

815819
deleteTemporaryProjectOutput();
816-
fail("Process exited with code " + status);
820+
if (status) {
821+
fail("Process exited with code " + status);
822+
}
823+
else {
824+
complete();
825+
}
817826
});
818-
ex.run();
819827
}
820828

821829
function runConsoleTests(defaultReporter, defaultSubsets) {

src/compiler/transformers/es6.ts

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ namespace ts {
8888

8989
function visitJavaScript(node: Node): VisitResult<Node> {
9090
switch (node.kind) {
91+
case SyntaxKind.ExportKeyword:
92+
return node;
93+
9194
case SyntaxKind.ClassDeclaration:
9295
return visitClassDeclaration(<ClassDeclaration>node);
9396

@@ -169,12 +172,19 @@ namespace ts {
169172
case SyntaxKind.SuperKeyword:
170173
return visitSuperKeyword(<PrimaryExpression>node);
171174

175+
case SyntaxKind.YieldExpression:
176+
// `yield` will be handled by a generators transform.
177+
return visitEachChild(node, visitor, context);
178+
172179
case SyntaxKind.MethodDeclaration:
173180
return visitMethodDeclaration(<MethodDeclaration>node);
174181

175182
case SyntaxKind.SourceFile:
176183
return visitSourceFileNode(<SourceFile>node);
177184

185+
case SyntaxKind.VariableStatement:
186+
return visitEachChild(node, visitor, context);
187+
178188
default:
179189
Debug.failBadSyntaxKind(node);
180190
return visitEachChild(node, visitor, context);
@@ -437,7 +447,11 @@ namespace ts {
437447
* @param node A ParameterDeclaration node.
438448
*/
439449
function visitParameter(node: ParameterDeclaration): ParameterDeclaration {
440-
if (isBindingPattern(node.name)) {
450+
if (node.dotDotDotToken) {
451+
// rest parameters are elided
452+
return undefined;
453+
}
454+
else if (isBindingPattern(node.name)) {
441455
// Binding patterns are converted into a generated name and are
442456
// evaluated inside the function body.
443457
return createParameter(
@@ -454,10 +468,6 @@ namespace ts {
454468
/*location*/ node
455469
);
456470
}
457-
else if (node.dotDotDotToken) {
458-
// rest parameters are elided
459-
return undefined;
460-
}
461471
else {
462472
return node;
463473
}
@@ -826,7 +836,7 @@ namespace ts {
826836
}
827837

828838
const expression = createFunctionExpression(
829-
/*asteriskToken*/ undefined,
839+
node.asteriskToken,
830840
name,
831841
visitNodes(node.parameters, visitor, isParameter),
832842
transformFunctionBody(node),

src/compiler/transformers/jsx.ts

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ namespace ts {
3838
case SyntaxKind.JsxSelfClosingElement:
3939
return visitJsxSelfClosingElement(<JsxSelfClosingElement>node);
4040

41+
case SyntaxKind.JsxExpression:
42+
return visitJsxExpression(<JsxExpression>node);
43+
4144
default:
4245
Debug.failBadSyntaxKind(node);
4346
return undefined;
@@ -116,12 +119,25 @@ namespace ts {
116119

117120
function transformJsxAttributeToObjectLiteralElement(node: JsxAttribute) {
118121
const name = getAttributeName(node);
119-
const expression = node.initializer
120-
? visitNode(node.initializer, visitor, isExpression)
121-
: createLiteral(true);
122+
const expression = transformJsxAttributeInitializer(node.initializer);
122123
return createPropertyAssignment(name, expression);
123124
}
124125

126+
function transformJsxAttributeInitializer(node: StringLiteral | JsxExpression) {
127+
if (node === undefined) {
128+
return createLiteral(true);
129+
}
130+
else if (node.kind === SyntaxKind.StringLiteral) {
131+
return node;
132+
}
133+
else if (node.kind === SyntaxKind.JsxExpression) {
134+
return visitJsxExpression(<JsxExpression>node);
135+
}
136+
else {
137+
Debug.failBadSyntaxKind(node);
138+
}
139+
}
140+
125141
function visitJsxText(node: JsxText) {
126142
const text = getTextOfNode(node, /*includeTrivia*/ true);
127143
let parts: Expression[];

src/compiler/transformers/module/module.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -752,11 +752,12 @@ namespace ts {
752752

753753
function createRequireCall(importNode: ImportDeclaration | ImportEqualsDeclaration | ExportDeclaration) {
754754
const moduleName = getExternalModuleNameLiteral(importNode);
755-
Debug.assert(isDefined(moduleName));
756-
return createCall(
757-
createIdentifier("require"),
758-
[moduleName]
759-
);
755+
const args: Expression[] = [];
756+
if (isDefined(moduleName)) {
757+
args.push(moduleName);
758+
}
759+
760+
return createCall(createIdentifier("require"), args);
760761
}
761762

762763
function createExportAssignment(name: Identifier, value: Expression) {

src/compiler/transformers/ts.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -243,14 +243,16 @@ namespace ts {
243243
case SyntaxKind.StringKeyword:
244244
case SyntaxKind.NumberKeyword:
245245
case SyntaxKind.VoidKeyword:
246+
case SyntaxKind.SymbolKeyword:
246247
case SyntaxKind.ConstructorType:
247248
case SyntaxKind.FunctionType:
248249
case SyntaxKind.TypeQuery:
249250
case SyntaxKind.TypeReference:
250251
case SyntaxKind.UnionType:
251252
case SyntaxKind.IntersectionType:
252-
case SyntaxKind.StringLiteralType:
253+
case SyntaxKind.ParenthesizedType:
253254
case SyntaxKind.ThisType:
255+
case SyntaxKind.StringLiteralType:
254256
// TypeScript type nodes are elided.
255257

256258
case SyntaxKind.IndexSignature:
@@ -2048,15 +2050,18 @@ namespace ts {
20482050
*
20492051
* This function will be called when one of the following conditions are met:
20502052
* - The node has an accessibility modifier.
2053+
* - The node has a questionToken.
20512054
*
20522055
* @param node The parameter declaration node.
20532056
*/
20542057
function visitParameter(node: ParameterDeclaration) {
2055-
Debug.assert(!node.dotDotDotToken);
2056-
return createParameter(
2057-
visitNode(node.name, visitor, isBindingName),
2058-
visitNode(node.initializer, visitor, isExpression)
2059-
);
2058+
const clone = getMutableClone(node);
2059+
clone.decorators = undefined;
2060+
clone.modifiers = undefined;
2061+
clone.questionToken = undefined;
2062+
clone.type = undefined;
2063+
aggregateTransformFlags(clone);
2064+
return visitEachChild(clone, visitor, context);
20602065
}
20612066

20622067
/**

src/compiler/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1070,7 +1070,7 @@ namespace ts {
10701070
export interface JsxAttribute extends Node {
10711071
name: Identifier;
10721072
/// JSX attribute initializers are optional; <X y /> is sugar for <X y={true} />
1073-
initializer?: Expression;
1073+
initializer?: StringLiteral | JsxExpression;
10741074
}
10751075

10761076
// @kind(SyntaxKind.JsxSpreadAttribute)

src/compiler/utilities.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3408,7 +3408,8 @@ namespace ts {
34083408
|| kind === SyntaxKind.ImportDeclaration
34093409
|| kind === SyntaxKind.ImportEqualsDeclaration
34103410
|| kind === SyntaxKind.ExportDeclaration
3411-
|| kind === SyntaxKind.ExportAssignment;
3411+
|| kind === SyntaxKind.ExportAssignment
3412+
|| kind === SyntaxKind.GlobalModuleExportDeclaration;
34123413
}
34133414

34143415
function isStatementKindButNotDeclarationKind(kind: SyntaxKind) {
@@ -3495,6 +3496,12 @@ namespace ts {
34953496
return node.kind === SyntaxKind.JsxAttribute;
34963497
}
34973498

3499+
export function isStringLiteralOrJsxExpression(node: Node): node is StringLiteral | JsxExpression {
3500+
const kind = node.kind;
3501+
return kind === SyntaxKind.StringLiteral
3502+
|| kind === SyntaxKind.JsxExpression;
3503+
}
3504+
34983505
// Clauses
34993506

35003507
export function isCaseOrDefaultClause(node: Node): node is CaseOrDefaultClause {

src/compiler/visitor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ namespace ts {
400400
],
401401
[SyntaxKind.JsxAttribute]: [
402402
{ name: "name", test: isIdentifier },
403-
{ name: "initializer", test: isExpression, optional: true },
403+
{ name: "initializer", test: isStringLiteralOrJsxExpression, optional: true },
404404
],
405405
[SyntaxKind.JsxSpreadAttribute]: [
406406
{ name: "expression", test: isExpression },

tests/baselines/reference/iteratorSpreadInCall12.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ class StringIterator {
3434
//// [iteratorSpreadInCall12.js]
3535
new Foo(...[...new SymbolIterator, ...[...new StringIterator]]);
3636
class Foo {
37-
constructor(...s) {
38-
}
37+
constructor(...s) { }
3938
}
4039
class SymbolIterator {
4140
next() {

tests/baselines/reference/iteratorSpreadInCall8.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ class StringIterator {
3434
//// [iteratorSpreadInCall8.js]
3535
new Foo(...new SymbolIterator, ...new StringIterator);
3636
class Foo {
37-
constructor(...s) {
38-
}
37+
constructor(...s) { }
3938
}
4039
class SymbolIterator {
4140
next() {

0 commit comments

Comments
 (0)