Add option --try-without-tscparams support to runner.ts

This commit is contained in:
vvakame
2013-11-19 02:26:16 +09:00
committed by Masahiro Wakame
parent b771b1e256
commit c09cda4109
2 changed files with 130 additions and 8 deletions

View File

@@ -942,12 +942,67 @@ var DefinitelyTyped;
return TestEval;
})(TestSuiteBase);
/////////////////////////////////
// Try compile without .tscparams
// It may indicate that it is compatible with --noImplicitAny maybe...
/////////////////////////////////
var FindNotRequiredTscparams = (function (_super) {
__extends(FindNotRequiredTscparams, _super);
function FindNotRequiredTscparams(print) {
var _this = this;
_super.call(this, "Find not required .tscparams files", "New arrival!");
this.print = print;
this.printErrorCount = false;
this.testReporter = {
printPositiveCharacter: function (index, testResult) {
_this.print.clearCurrentLine().printTypingsWithoutTestName(testResult.targetFile.formatName);
},
printNegativeCharacter: function (index, testResult) {
}
};
}
FindNotRequiredTscparams.prototype.filterTargetFiles = function (files) {
return files.filter(function (file) {
return IO.fileExists(file.filePathWithName + '.tscparams');
});
};
FindNotRequiredTscparams.prototype.runTest = function (targetFile, callback) {
var _this = this;
this.print.clearCurrentLine().out(targetFile.formatName);
new Test(this, targetFile, { useTscParams: false, checkNoImplicitAny: true }).run(function (result) {
_this.testResults.push(result);
callback(result);
});
};
FindNotRequiredTscparams.prototype.finish = function (suiteCallback) {
this.print.clearCurrentLine();
suiteCallback(this);
};
Object.defineProperty(FindNotRequiredTscparams.prototype, "ngTests", {
get: function () {
// Do not show ng test results
return [];
},
enumerable: true,
configurable: true
});
return FindNotRequiredTscparams;
})(TestSuiteBase);
/////////////////////////////////
// The main class to kick things off
/////////////////////////////////
var TestRunner = (function () {
function TestRunner(dtPath) {
function TestRunner(dtPath, options) {
if (typeof options === "undefined") { options = {}; }
this.options = options;
this.suites = [];
this.options.findNotRequiredTscparams = !!this.options.findNotRequiredTscparams;
var filesName = IO.dir(dtPath, /.\.ts/g, { recursive: true }).sort();
// only includes .d.ts or -tests.ts or -test.ts or .ts
@@ -971,14 +1026,20 @@ var DefinitelyTyped;
var syntaxChecking = new SyntaxChecking();
var testEval = new TestEval();
this.addSuite(syntaxChecking);
this.addSuite(testEval);
if (!this.options.findNotRequiredTscparams) {
this.addSuite(syntaxChecking);
this.addSuite(testEval);
}
var typings = syntaxChecking.filterTargetFiles(this.files).length;
var testFiles = testEval.filterTargetFiles(this.files).length;
this.print = new Print('0.9.1.1', typings, testFiles, this.files.length);
this.print.printHeader();
if (this.options.findNotRequiredTscparams) {
this.addSuite(new FindNotRequiredTscparams(this.print));
}
var count = 0;
var executor = function () {
var suite = _this.suites[count];
@@ -1083,6 +1144,9 @@ var DefinitelyTyped;
})(DefinitelyTyped || (DefinitelyTyped = {}));
var dtPath = __dirname + '/../..';
var findNotRequiredTscparams = process.argv.some(function (arg) {
return arg == "--try-without-tscparams";
});
var runner = new DefinitelyTyped.TestManager.TestRunner(dtPath);
var runner = new DefinitelyTyped.TestManager.TestRunner(dtPath, { findNotRequiredTscparams: findNotRequiredTscparams });
runner.run();

View File

@@ -389,6 +389,55 @@ module DefinitelyTyped.TestManager {
}
}
/////////////////////////////////
// Try compile without .tscparams
// It may indicate that it is compatible with --noImplicitAny maybe...
/////////////////////////////////
class FindNotRequiredTscparams extends TestSuiteBase {
testReporter:ITestReporter;
printErrorCount = false;
constructor(private print:Print) {
super("Find not required .tscparams files", "New arrival!");
this.testReporter = {
printPositiveCharacter: (index:number, testResult:TestResult)=> {
this.print
.clearCurrentLine()
.printTypingsWithoutTestName(testResult.targetFile.formatName);
},
printNegativeCharacter: (index:number, testResult:TestResult)=> {
}
}
}
public filterTargetFiles(files:File[]):File[] {
return files.filter(file=> IO.fileExists(file.filePathWithName + '.tscparams'));
}
public runTest(targetFile:File, callback:(result:TestResult)=>void):void {
this.print.clearCurrentLine().out(targetFile.formatName);
new Test(this, targetFile, {useTscParams: false, checkNoImplicitAny: true}).run(result=> {
this.testResults.push(result);
callback(result);
});
}
public finish(suiteCallback:(suite:ITestSuite)=>void) {
this.print.clearCurrentLine();
suiteCallback(this);
}
public get ngTests():TestResult[] {
// Do not show ng test results
return [];
}
}
export interface ITestRunnerOptions {
findNotRequiredTscparams?:boolean;
}
/////////////////////////////////
// The main class to kick things off
/////////////////////////////////
@@ -398,7 +447,9 @@ module DefinitelyTyped.TestManager {
suites:ITestSuite[] = [];
private print:Print;
constructor(dtPath:string) {
constructor(dtPath:string, public options:ITestRunnerOptions = {}) {
this.options.findNotRequiredTscparams = !!this.options.findNotRequiredTscparams;
var filesName = IO.dir(dtPath, /.\.ts/g, { recursive: true }).sort();
// only includes .d.ts or -tests.ts or -test.ts or .ts
filesName = filesName
@@ -417,14 +468,20 @@ module DefinitelyTyped.TestManager {
var syntaxChecking = new SyntaxChecking();
var testEval = new TestEval();
this.addSuite(syntaxChecking);
this.addSuite(testEval);
if (!this.options.findNotRequiredTscparams) {
this.addSuite(syntaxChecking);
this.addSuite(testEval);
}
var typings = syntaxChecking.filterTargetFiles(this.files).length;
var testFiles = testEval.filterTargetFiles(this.files).length;
this.print = new Print('0.9.1.1', typings, testFiles, this.files.length);
this.print.printHeader();
if (this.options.findNotRequiredTscparams) {
this.addSuite(new FindNotRequiredTscparams(this.print));
}
var count = 0;
var executor = () => {
var suite = this.suites[count];
@@ -518,6 +575,7 @@ module DefinitelyTyped.TestManager {
}
var dtPath = __dirname + '/../..';
var findNotRequiredTscparams = process.argv.some(arg=>arg == "--try-without-tscparams");
var runner = new DefinitelyTyped.TestManager.TestRunner(dtPath);
var runner = new DefinitelyTyped.TestManager.TestRunner(dtPath, {findNotRequiredTscparams: findNotRequiredTscparams});
runner.run();