From c883949642e7692551caedf36af519a35d925487 Mon Sep 17 00:00:00 2001 From: Claus Reinke Date: Sat, 16 Jun 2012 17:25:18 +0200 Subject: [PATCH] add exitCode --- estr.js | 15 +++++++++++---- tests/.gitattributes | 1 + .../out/rename-capture-existing-occurrences.error | 10 +++++++++- .../out/rename-capture-renamed-occurrences.error | 10 +++++++++- tests/out/rename-conflicting-binders.error | 10 +++++++++- tests/out/rename-function-in-catch-1.error | 9 ++++++++- tests/out/rename-function-in-catch-2.error | 9 ++++++++- tests/out/rename-function-in-catch-3.error | 9 ++++++++- tests/out/rename-global-no-binder.error | 8 +++++++- .../rename-introduce-catch-hoist-conflict.error | 10 +++++++++- tests/out/rename-invalid-newName.error | 2 +- tests/out/rename-invalid-oldName.error | 2 +- tests/out/rename-var-in-catch.error | 9 ++++++++- tests/out/rename-wrong-position.error | 8 +++++++- 14 files changed, 96 insertions(+), 16 deletions(-) diff --git a/estr.js b/estr.js index 53e87f0..c6b3766 100644 --- a/estr.js +++ b/estr.js @@ -53,6 +53,7 @@ switch (process.argv.shift()) { console.error("parse error in "+results[0].sourcefile ,results[0].parseError); + exitCode(1); } else if (results[0].decls){ @@ -67,6 +68,7 @@ switch (process.argv.shift()) { } else { console.error('unknown result',results[0]); + exitCode(1); } } @@ -112,14 +114,17 @@ switch (process.argv.shift()) { console.error("parse error in "+results[0].sourcefile ,results[0].parseError); + exitCode(1); } else if (results[0].error) { console.error(results[0].error.message); + exitCode(1); } else { console.error('unknown result',results[0]); + exitCode(1); } } @@ -170,14 +175,17 @@ switch (process.argv.shift()) { console.error("parse error in "+results[0].sourcefile ,results[0].parseError); + exitCode(1); } else if (results[0].error) { console.error(results[0].error.message); + exitCode(1); } else { console.error('unknown result',results[0]); + exitCode(1); } } @@ -207,7 +215,6 @@ function processJSfiles(paths,action) { return results; } -function updateFile(action) { return function(path,source) { - var newSource = action(path,source); - fs.writeFileSync(path,newSource); -}} +function exitCode(code) { + process.on('exit',function(){process.exit(1)}); +} diff --git a/tests/.gitattributes b/tests/.gitattributes index 7b1e576..3bc40bc 100644 --- a/tests/.gitattributes +++ b/tests/.gitattributes @@ -4,3 +4,4 @@ sample-work.js.bak -text tags -text *.stdout -text *.stderr -text +*.error -text diff --git a/tests/out/rename-capture-existing-occurrences.error b/tests/out/rename-capture-existing-occurrences.error index ec747fa..7ca357e 100644 --- a/tests/out/rename-capture-existing-occurrences.error +++ b/tests/out/rename-capture-existing-occurrences.error @@ -1 +1,9 @@ -null \ No newline at end of file +Error: Command failed: WARNING! hoisting var declaration over catch of same name: e +{ start: { line: 20, column: 8 }, + end: { line: 20, column: 16 } } +WARNING! hoisting function declaration over catch of same name: f +{ start: { line: 28, column: 4 }, + end: { line: 28, column: 24 } } +renamed binding for a would capture +existing occurrences of x +{ line: 36, column: 10 } diff --git a/tests/out/rename-capture-renamed-occurrences.error b/tests/out/rename-capture-renamed-occurrences.error index ec747fa..0b8970a 100644 --- a/tests/out/rename-capture-renamed-occurrences.error +++ b/tests/out/rename-capture-renamed-occurrences.error @@ -1 +1,9 @@ -null \ No newline at end of file +Error: Command failed: WARNING! hoisting var declaration over catch of same name: e +{ start: { line: 20, column: 8 }, + end: { line: 20, column: 16 } } +WARNING! hoisting function declaration over catch of same name: f +{ start: { line: 28, column: 4 }, + end: { line: 28, column: 24 } } +renamed occurrences of x would be captured +by existing bindings for a +x { line: 36, column: 10 } by a { line: 35, column: 38 } FunctionExpression Parameter diff --git a/tests/out/rename-conflicting-binders.error b/tests/out/rename-conflicting-binders.error index ec747fa..31b6898 100644 --- a/tests/out/rename-conflicting-binders.error +++ b/tests/out/rename-conflicting-binders.error @@ -1 +1,9 @@ -null \ No newline at end of file +Error: Command failed: WARNING! hoisting var declaration over catch of same name: e +{ start: { line: 20, column: 8 }, + end: { line: 20, column: 16 } } +WARNING! hoisting function declaration over catch of same name: f +{ start: { line: 28, column: 4 }, + end: { line: 28, column: 24 } } +renamed binding for a would conflict +with existing binding for b in the same scope +{ line: 35, column: 40 } 'FunctionExpression Parameter' diff --git a/tests/out/rename-function-in-catch-1.error b/tests/out/rename-function-in-catch-1.error index ec747fa..c72d025 100644 --- a/tests/out/rename-function-in-catch-1.error +++ b/tests/out/rename-function-in-catch-1.error @@ -1 +1,8 @@ -null \ No newline at end of file +Error: Command failed: WARNING! hoisting var declaration over catch of same name: e +{ start: { line: 20, column: 8 }, + end: { line: 20, column: 16 } } +WARNING! hoisting function declaration over catch of same name: f +{ start: { line: 28, column: 4 }, + end: { line: 28, column: 24 } } +cannot rename declaration hoisted over catch +f { line: 28, column: 13 } diff --git a/tests/out/rename-function-in-catch-2.error b/tests/out/rename-function-in-catch-2.error index ec747fa..c72d025 100644 --- a/tests/out/rename-function-in-catch-2.error +++ b/tests/out/rename-function-in-catch-2.error @@ -1 +1,8 @@ -null \ No newline at end of file +Error: Command failed: WARNING! hoisting var declaration over catch of same name: e +{ start: { line: 20, column: 8 }, + end: { line: 20, column: 16 } } +WARNING! hoisting function declaration over catch of same name: f +{ start: { line: 28, column: 4 }, + end: { line: 28, column: 24 } } +cannot rename declaration hoisted over catch +f { line: 28, column: 13 } diff --git a/tests/out/rename-function-in-catch-3.error b/tests/out/rename-function-in-catch-3.error index ec747fa..c72d025 100644 --- a/tests/out/rename-function-in-catch-3.error +++ b/tests/out/rename-function-in-catch-3.error @@ -1 +1,8 @@ -null \ No newline at end of file +Error: Command failed: WARNING! hoisting var declaration over catch of same name: e +{ start: { line: 20, column: 8 }, + end: { line: 20, column: 16 } } +WARNING! hoisting function declaration over catch of same name: f +{ start: { line: 28, column: 4 }, + end: { line: 28, column: 24 } } +cannot rename declaration hoisted over catch +f { line: 28, column: 13 } diff --git a/tests/out/rename-global-no-binder.error b/tests/out/rename-global-no-binder.error index ec747fa..d07a0f7 100644 --- a/tests/out/rename-global-no-binder.error +++ b/tests/out/rename-global-no-binder.error @@ -1 +1,7 @@ -null \ No newline at end of file +Error: Command failed: WARNING! hoisting var declaration over catch of same name: e +{ start: { line: 20, column: 8 }, + end: { line: 20, column: 16 } } +WARNING! hoisting function declaration over catch of same name: f +{ start: { line: 28, column: 4 }, + end: { line: 28, column: 24 } } +no binding scope found diff --git a/tests/out/rename-introduce-catch-hoist-conflict.error b/tests/out/rename-introduce-catch-hoist-conflict.error index ec747fa..6816a12 100644 --- a/tests/out/rename-introduce-catch-hoist-conflict.error +++ b/tests/out/rename-introduce-catch-hoist-conflict.error @@ -1 +1,9 @@ -null \ No newline at end of file +Error: Command failed: WARNING! hoisting var declaration over catch of same name: e +{ start: { line: 20, column: 8 }, + end: { line: 20, column: 16 } } +WARNING! hoisting function declaration over catch of same name: f +{ start: { line: 28, column: 4 }, + end: { line: 28, column: 24 } } +renamed occurrences of ff would be captured +by existing bindings for f +ff { line: 42, column: 6 } by f { line: 41, column: 9 } CatchClause Parameter diff --git a/tests/out/rename-invalid-newName.error b/tests/out/rename-invalid-newName.error index ec747fa..addee86 100644 --- a/tests/out/rename-invalid-newName.error +++ b/tests/out/rename-invalid-newName.error @@ -1 +1 @@ -null \ No newline at end of file +Error: Command failed: not a valid variable name >new-name< diff --git a/tests/out/rename-invalid-oldName.error b/tests/out/rename-invalid-oldName.error index ec747fa..430f29e 100644 --- a/tests/out/rename-invalid-oldName.error +++ b/tests/out/rename-invalid-oldName.error @@ -1 +1 @@ -null \ No newline at end of file +Error: Command failed: not a valid variable name >old-name< diff --git a/tests/out/rename-var-in-catch.error b/tests/out/rename-var-in-catch.error index ec747fa..a37b50b 100644 --- a/tests/out/rename-var-in-catch.error +++ b/tests/out/rename-var-in-catch.error @@ -1 +1,8 @@ -null \ No newline at end of file +Error: Command failed: WARNING! hoisting var declaration over catch of same name: e +{ start: { line: 20, column: 8 }, + end: { line: 20, column: 16 } } +WARNING! hoisting function declaration over catch of same name: f +{ start: { line: 28, column: 4 }, + end: { line: 28, column: 24 } } +cannot rename declaration hoisted over catch +e { line: 20, column: 8 } diff --git a/tests/out/rename-wrong-position.error b/tests/out/rename-wrong-position.error index ec747fa..d07a0f7 100644 --- a/tests/out/rename-wrong-position.error +++ b/tests/out/rename-wrong-position.error @@ -1 +1,7 @@ -null \ No newline at end of file +Error: Command failed: WARNING! hoisting var declaration over catch of same name: e +{ start: { line: 20, column: 8 }, + end: { line: 20, column: 16 } } +WARNING! hoisting function declaration over catch of same name: f +{ start: { line: 28, column: 4 }, + end: { line: 28, column: 24 } } +no binding scope found