diff --git a/.gitignore b/.gitignore
index b09429865e..d4bc5dd91f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -23,12 +23,7 @@ Properties
*~
# test folder
-!_infrastructure/*.js
-!_infrastructure/tests/*
-!_infrastructure/tests/*.js
-!_infrastructure/tests/*/*.js
-!_infrastructure/tests/*/*/*.js
-!_infrastructure/tests/*/*/*/*.js
+_infrastructure/tests/build
.idea
*.iml
diff --git a/_infrastructure/runner.js b/_infrastructure/runner.js
new file mode 100644
index 0000000000..b9b9446ecf
--- /dev/null
+++ b/_infrastructure/runner.js
@@ -0,0 +1 @@
+require('definition-tester');
diff --git a/_infrastructure/tests/_ref.d.ts b/_infrastructure/tests/_ref.d.ts
deleted file mode 100644
index 5a0809f3b8..0000000000
--- a/_infrastructure/tests/_ref.d.ts
+++ /dev/null
@@ -1 +0,0 @@
-///
diff --git a/_infrastructure/tests/compile-runner.bat b/_infrastructure/tests/compile-runner.bat
deleted file mode 100644
index 49f737c5d2..0000000000
--- a/_infrastructure/tests/compile-runner.bat
+++ /dev/null
@@ -1 +0,0 @@
-tsc runner.ts --target ES5 --out runner.js --module commonjs --sourcemap
diff --git a/_infrastructure/tests/runner.js b/_infrastructure/tests/runner.js
deleted file mode 100644
index 171efe87dd..0000000000
--- a/_infrastructure/tests/runner.js
+++ /dev/null
@@ -1,1321 +0,0 @@
-var DT;
-(function (DT) {
- 'use strict';
-
- var Promise = require('bluebird');
- var nodeExec = require('child_process').exec;
-
- var ExecResult = (function () {
- function ExecResult() {
- this.stdout = '';
- this.stderr = '';
- }
- return ExecResult;
- })();
- DT.ExecResult = ExecResult;
-
- function exec(filename, cmdLineArgs) {
- return new Promise(function (resolve) {
- var result = new ExecResult();
- result.exitCode = null;
-
- var cmdLine = filename + ' ' + cmdLineArgs.join(' ');
-
- nodeExec(cmdLine, { maxBuffer: 1 * 1024 * 1024 }, function (error, stdout, stderr) {
- result.error = error;
- result.stdout = stdout;
- result.stderr = stderr;
- result.exitCode = error ? error.code : 0;
- resolve(result);
- });
- });
- }
- DT.exec = exec;
-})(DT || (DT = {}));
-///
-var DT;
-(function (DT) {
- 'use strict';
-
- var path = require('path');
-
- /////////////////////////////////
- // Given a document root + ts file pattern this class returns:
- // all the TS files OR just tests OR just definition files
- /////////////////////////////////
- var File = (function () {
- function File(baseDir, filePathWithName) {
- this.references = [];
- // why choose?
- this.baseDir = baseDir;
- this.filePathWithName = filePathWithName;
- this.ext = path.extname(this.filePathWithName);
- this.file = path.basename(this.filePathWithName, this.ext);
- this.dir = path.dirname(this.filePathWithName);
- this.fullPath = path.join(this.baseDir, this.dir, this.file + this.ext);
- // lock it (shallow) (needs `use strict` in each file to work)
- // Object.freeze(this);
- }
- File.prototype.toString = function () {
- return '[File ' + this.filePathWithName + ']';
- };
- return File;
- })();
- DT.File = File;
-})(DT || (DT = {}));
-///
-///
-///
-var DT;
-(function (DT) {
- 'use strict';
-
- var fs = require('fs');
-
- var Promise = require('bluebird');
-
- var Tsc = (function () {
- function Tsc() {
- }
- Tsc.run = function (tsfile, options) {
- var tscPath;
- return new Promise.attempt(function () {
- options = options || {};
- options.tscVersion = options.tscVersion || DT.DEFAULT_TSC_VERSION;
- if (typeof options.checkNoImplicitAny === 'undefined') {
- options.checkNoImplicitAny = true;
- }
- if (typeof options.useTscParams === 'undefined') {
- options.useTscParams = true;
- }
- return DT.fileExists(tsfile);
- }).then(function (exists) {
- if (!exists) {
- throw new Error(tsfile + ' not exists');
- }
- tscPath = './_infrastructure/tests/typescript/' + options.tscVersion + '/tsc.js';
- return DT.fileExists(tscPath);
- }).then(function (exists) {
- if (!exists) {
- throw new Error(tscPath + ' is not exists');
- }
- return DT.fileExists(tsfile + '.tscparams');
- }).then(function (exists) {
- var command = 'node ' + tscPath + ' --module commonjs ';
- if (options.useTscParams && exists) {
- command += '@' + tsfile + '.tscparams';
- } else if (options.checkNoImplicitAny) {
- command += '--noImplicitAny';
- }
- return DT.exec(command, [tsfile]);
- });
- };
- return Tsc;
- })();
- DT.Tsc = Tsc;
-})(DT || (DT = {}));
-///
-///
-var DT;
-(function (DT) {
- 'use strict';
-
- /////////////////////////////////
- // Timer.start starts a timer
- // Timer.end stops the timer and sets asString to the pretty print value
- /////////////////////////////////
- var Timer = (function () {
- function Timer() {
- this.time = 0;
- this.asString = '';
- }
- Timer.prototype.start = function () {
- this.time = 0;
- this.startTime = this.now();
- this.asString = '';
- };
-
- Timer.prototype.now = function () {
- return Date.now();
- };
-
- Timer.prototype.end = function () {
- this.time = (this.now() - this.startTime) / 1000;
- this.asString = Timer.prettyDate(this.startTime, this.now());
- };
-
- Timer.prettyDate = function (date1, date2) {
- var diff = ((date2 - date1) / 1000);
- var day_diff = Math.floor(diff / 86400);
-
- if (isNaN(day_diff) || day_diff < 0 || day_diff >= 31) {
- return null;
- }
-
- return (day_diff == 0 && (diff < 60 && (diff + ' seconds') || diff < 120 && '1 minute' || diff < 3600 && Math.floor(diff / 60) + ' minutes' || diff < 7200 && '1 hour' || diff < 86400 && Math.floor(diff / 3600) + ' hours') || day_diff == 1 && 'Yesterday' || day_diff < 7 && day_diff + ' days' || day_diff < 31 && Math.ceil(day_diff / 7) + ' weeks');
- };
- return Timer;
- })();
- DT.Timer = Timer;
-})(DT || (DT = {}));
-///
-var DT;
-(function (DT) {
- 'use strict';
-
- var fs = require('fs');
- var Lazy = require('lazy.js');
- var Promise = require('bluebird');
-
- var referenceTagExp = //g;
-
- function endsWith(str, suffix) {
- return str.indexOf(suffix, str.length - suffix.length) !== -1;
- }
- DT.endsWith = endsWith;
-
- function extractReferenceTags(source) {
- var ret = [];
- var match;
-
- if (!referenceTagExp.global) {
- throw new Error('referenceTagExp RegExp must have global flag');
- }
- referenceTagExp.lastIndex = 0;
-
- while ((match = referenceTagExp.exec(source))) {
- if (match.length > 0 && match[1].length > 0) {
- ret.push(match[1]);
- }
- }
- return ret;
- }
- DT.extractReferenceTags = extractReferenceTags;
-
- function fileExists(target) {
- return new Promise(function (resolve, reject) {
- fs.exists(target, function (bool) {
- resolve(bool);
- });
- });
- }
- DT.fileExists = fileExists;
-})(DT || (DT = {}));
-///
-///
-///
-var DT;
-(function (DT) {
- 'use strict';
-
- var fs = require('fs');
- var path = require('path');
- var glob = require('glob');
- var Lazy = require('lazy.js');
- var Promise = require('bluebird');
-
- var readFile = Promise.promisify(fs.readFile);
-
- /////////////////////////////////
- // Track all files in the repo: map full path to File objects
- /////////////////////////////////
- var FileIndex = (function () {
- function FileIndex(runner, options) {
- this.runner = runner;
- this.options = options;
- }
- FileIndex.prototype.hasFile = function (target) {
- return target in this.fileMap;
- };
-
- FileIndex.prototype.getFile = function (target) {
- if (target in this.fileMap) {
- return this.fileMap[target];
- }
- return null;
- };
-
- FileIndex.prototype.setFile = function (file) {
- if (file.fullPath in this.fileMap) {
- throw new Error('cannot overwrite file');
- }
- this.fileMap[file.fullPath] = file;
- };
-
- FileIndex.prototype.readIndex = function () {
- var _this = this;
- this.fileMap = Object.create(null);
-
- return Promise.promisify(glob).call(glob, '**/*.ts', {
- cwd: this.runner.dtPath
- }).then(function (filesNames) {
- _this.files = Lazy(filesNames).filter(function (fileName) {
- return _this.runner.checkAcceptFile(fileName);
- }).map(function (fileName) {
- var file = new DT.File(_this.runner.dtPath, fileName);
- _this.fileMap[file.fullPath] = file;
- return file;
- }).toArray();
- });
- };
-
- FileIndex.prototype.collectDiff = function (changes) {
- var _this = this;
- return new Promise(function (resolve) {
- // filter changes and bake map for easy lookup
- _this.changed = Object.create(null);
- _this.removed = Object.create(null);
-
- Lazy(changes).filter(function (full) {
- return _this.runner.checkAcceptFile(full);
- }).uniq().each(function (local) {
- var full = path.resolve(_this.runner.dtPath, local);
- var file = _this.getFile(full);
- if (!file) {
- // TODO figure out what to do here
- // what does it mean? deleted?ss
- file = new DT.File(_this.runner.dtPath, local);
- _this.setFile(file);
- _this.removed[full] = file;
- // console.log('not in index? %', file.fullPath);
- } else {
- _this.changed[full] = file;
- }
- });
-
- // console.log('changed:\n' + Object.keys(this.changed).join('\n'));
- // console.log('removed:\n' + Object.keys(this.removed).join('\n'));
- resolve();
- });
- };
-
- FileIndex.prototype.parseFiles = function () {
- var _this = this;
- return this.loadReferences(this.files).then(function () {
- return _this.getMissingReferences();
- });
- };
-
- FileIndex.prototype.getMissingReferences = function () {
- var _this = this;
- return Promise.attempt(function () {
- _this.missing = Object.create(null);
- Lazy(_this.removed).keys().each(function (removed) {
- if (removed in _this.refMap) {
- _this.missing[removed] = _this.refMap[removed];
- }
- });
- });
- };
-
- FileIndex.prototype.loadReferences = function (files) {
- var _this = this;
- return new Promise(function (resolve, reject) {
- var queue = files.slice(0);
- var active = [];
- var max = 50;
- var next = function () {
- if (queue.length === 0 && active.length === 0) {
- resolve();
- return;
- }
-
- while (queue.length > 0 && active.length < max) {
- var file = queue.pop();
- active.push(file);
- _this.parseFile(file).then(function (file) {
- active.splice(active.indexOf(file), 1);
- next();
- }).catch(function (err) {
- queue = [];
- active = [];
- reject(err);
- });
- }
- };
- next();
- }).then(function () {
- // bake reverse reference map (referenced to referrers)
- _this.refMap = Object.create(null);
-
- Lazy(files).each(function (file) {
- Lazy(file.references).each(function (ref) {
- if (ref.fullPath in _this.refMap) {
- _this.refMap[ref.fullPath].push(file);
- } else {
- _this.refMap[ref.fullPath] = [file];
- }
- });
- });
- });
- };
-
- // TODO replace with a stream?
- FileIndex.prototype.parseFile = function (file) {
- var _this = this;
- return readFile(file.filePathWithName, {
- encoding: 'utf8',
- flag: 'r'
- }).then(function (content) {
- file.references = Lazy(DT.extractReferenceTags(content)).map(function (ref) {
- return path.resolve(path.dirname(file.fullPath), ref);
- }).reduce(function (memo, ref) {
- if (ref in _this.fileMap) {
- memo.push(_this.fileMap[ref]);
- } else {
- console.log('not mapped? -> ' + ref);
- }
- return memo;
- }, []);
-
- // return the object
- return file;
- });
- };
-
- FileIndex.prototype.collectTargets = function () {
- var _this = this;
- return new Promise(function (resolve) {
- // map out files linked to changes
- // - queue holds files touched by a change
- // - pre-fill with actually changed files
- // - loop queue, if current not seen:
- // - add to result
- // - from refMap queue all files referring to current
- var result = Object.create(null);
- var queue = Lazy(_this.changed).values().toArray();
-
- while (queue.length > 0) {
- var next = queue.shift();
- var fp = next.fullPath;
- if (result[fp]) {
- continue;
- }
- result[fp] = next;
- if (fp in _this.refMap) {
- var arr = _this.refMap[fp];
- for (var i = 0, ii = arr.length; i < ii; i++) {
- // just add it and skip expensive checks
- queue.push(arr[i]);
- }
- }
- }
- resolve(Lazy(result).values().toArray());
- });
- };
- return FileIndex;
- })();
- DT.FileIndex = FileIndex;
-})(DT || (DT = {}));
-///
-///
-var DT;
-(function (DT) {
- 'use strict';
-
- var fs = require('fs');
- var path = require('path');
- var Git = require('git-wrapper');
- var Promise = require('bluebird');
-
- var GitChanges = (function () {
- function GitChanges(runner) {
- this.runner = runner;
- this.options = {};
- var dir = path.join(this.runner.dtPath, '.git');
- if (!fs.existsSync(dir)) {
- throw new Error('cannot locate git-dir: ' + dir);
- }
- this.options['git-dir'] = dir;
-
- this.git = new Git(this.options);
- this.git.exec = Promise.promisify(this.git.exec);
- }
- GitChanges.prototype.readChanges = function () {
- var opts = {};
- var args = ['--name-only HEAD~1'];
- return this.git.exec('diff', opts, args).then(function (msg) {
- return msg.replace(/^\s+/, '').replace(/\s+$/, '').split(/\r?\n/g);
- });
- };
- return GitChanges;
- })();
- DT.GitChanges = GitChanges;
-})(DT || (DT = {}));
-///
-///
-var DT;
-(function (DT) {
- var os = require('os');
-
- /////////////////////////////////
- // All the common things that we print are functions of this class
- /////////////////////////////////
- var Print = (function () {
- function Print(version) {
- this.version = version;
- this.WIDTH = 77;
- }
- Print.prototype.init = function (typings, tests, tsFiles) {
- this.typings = typings;
- this.tests = tests;
- this.tsFiles = tsFiles;
- };
-
- Print.prototype.out = function (s) {
- process.stdout.write(s);
- return this;
- };
-
- Print.prototype.repeat = function (s, times) {
- return new Array(times + 1).join(s);
- };
-
- Print.prototype.printChangeHeader = function () {
- this.out('=============================================================================\n');
- this.out(' \33[36m\33[1mDefinitelyTyped Diff Detector 0.1.0\33[0m \n');
- this.out('=============================================================================\n');
- };
-
- Print.prototype.printHeader = function (options) {
- var totalMem = Math.round(os.totalmem() / 1024 / 1024) + ' mb';
- var freemem = Math.round(os.freemem() / 1024 / 1024) + ' mb';
-
- this.out('=============================================================================\n');
- this.out(' \33[36m\33[1mDefinitelyTyped Test Runner 0.5.0\33[0m\n');
- this.out('=============================================================================\n');
- this.out(' \33[36m\33[1mTypescript version:\33[0m ' + this.version + '\n');
- this.out(' \33[36m\33[1mTypings :\33[0m ' + this.typings + '\n');
- this.out(' \33[36m\33[1mTests :\33[0m ' + this.tests + '\n');
- this.out(' \33[36m\33[1mTypeScript files :\33[0m ' + this.tsFiles + '\n');
- this.out(' \33[36m\33[1mTotal Memory :\33[0m ' + totalMem + '\n');
- this.out(' \33[36m\33[1mFree Memory :\33[0m ' + freemem + '\n');
- this.out(' \33[36m\33[1mCores :\33[0m ' + os.cpus().length + '\n');
- this.out(' \33[36m\33[1mConcurrent :\33[0m ' + options.concurrent + '\n');
- };
-
- Print.prototype.printSuiteHeader = function (title) {
- var left = Math.floor((this.WIDTH - title.length) / 2) - 1;
- var right = Math.ceil((this.WIDTH - title.length) / 2) - 1;
- this.out(this.repeat('=', left)).out(' \33[34m\33[1m');
- this.out(title);
- this.out('\33[0m ').out(this.repeat('=', right)).printBreak();
- };
-
- Print.prototype.printDiv = function () {
- this.out('-----------------------------------------------------------------------------\n');
- };
-
- Print.prototype.printBoldDiv = function () {
- this.out('=============================================================================\n');
- };
-
- Print.prototype.printErrorsHeader = function () {
- this.out('=============================================================================\n');
- this.out(' \33[34m\33[1mErrors in files\33[0m \n');
- this.out('=============================================================================\n');
- };
-
- Print.prototype.printErrorsForFile = function (testResult) {
- this.out('----------------- For file:' + testResult.targetFile.filePathWithName);
- this.printBreak().out(testResult.stderr).printBreak();
- };
-
- Print.prototype.printBreak = function () {
- this.out('\n');
- return this;
- };
-
- Print.prototype.clearCurrentLine = function () {
- this.out('\r\33[K');
- return this;
- };
-
- Print.prototype.printSuccessCount = function (current, total) {
- var arb = (total === 0) ? 0 : (current / total);
- this.out(' \33[36m\33[1mSuccessful :\33[0m \33[32m\33[1m' + (arb * 100).toFixed(2) + '% (' + current + '/' + total + ')\33[0m\n');
- };
-
- Print.prototype.printFailedCount = function (current, total) {
- var arb = (total === 0) ? 0 : (current / total);
- this.out(' \33[36m\33[1mFailure :\33[0m \33[31m\33[1m' + (arb * 100).toFixed(2) + '% (' + current + '/' + total + ')\33[0m\n');
- };
-
- Print.prototype.printTypingsWithoutTestsMessage = function () {
- this.out(' \33[36m\33[1mTyping without tests\33[0m\n');
- };
-
- Print.prototype.printTotalMessage = function () {
- this.out(' \33[36m\33[1mTotal\33[0m\n');
- };
-
- Print.prototype.printElapsedTime = function (time, s) {
- this.out(' \33[36m\33[1mElapsed time :\33[0m ~' + time + ' (' + s + 's)\n');
- };
-
- Print.prototype.printSuiteErrorCount = function (errorHeadline, current, total, warn) {
- if (typeof warn === "undefined") { warn = false; }
- var arb = (total === 0) ? 0 : (current / total);
- this.out(' \33[36m\33[1m').out(errorHeadline).out(this.repeat(' ', 16 - errorHeadline.length));
- if (warn) {
- this.out(': \33[31m\33[1m' + (arb * 100).toFixed(2) + '% (' + current + '/' + total + ')\33[0m\n');
- } else {
- this.out(': \33[33m\33[1m' + (arb * 100).toFixed(2) + '% (' + current + '/' + total + ')\33[0m\n');
- }
- };
-
- Print.prototype.printSubHeader = function (file) {
- this.out(' \33[36m\33[1m' + file + '\33[0m\n');
- };
-
- Print.prototype.printWarnCode = function (str) {
- this.out(' \33[31m\33[1m<' + str.toLowerCase().replace(/ +/g, '-') + '>\33[0m\n');
- };
-
- Print.prototype.printLine = function (file) {
- this.out(file + '\n');
- };
-
- Print.prototype.printElement = function (file) {
- this.out(' - ' + file + '\n');
- };
-
- Print.prototype.printElement2 = function (file) {
- this.out(' - ' + file + '\n');
- };
-
- Print.prototype.printTypingsWithoutTestName = function (file) {
- this.out(' - \33[33m\33[1m' + file + '\33[0m\n');
- };
-
- Print.prototype.printTypingsWithoutTest = function (withoutTestTypings) {
- var _this = this;
- if (withoutTestTypings.length > 0) {
- this.printTypingsWithoutTestsMessage();
-
- this.printDiv();
- withoutTestTypings.forEach(function (t) {
- _this.printTypingsWithoutTestName(t);
- });
- }
- };
-
- Print.prototype.printTestComplete = function (testResult) {
- var reporter = testResult.hostedBy.testReporter;
- if (testResult.success) {
- reporter.printPositiveCharacter(testResult);
- } else {
- reporter.printNegativeCharacter(testResult);
- }
- };
-
- Print.prototype.printSuiteComplete = function (suite) {
- this.printBreak();
-
- this.printDiv();
- this.printElapsedTime(suite.timer.asString, suite.timer.time);
- this.printSuccessCount(suite.okTests.length, suite.testResults.length);
- this.printFailedCount(suite.ngTests.length, suite.testResults.length);
- };
-
- Print.prototype.printTests = function (adding) {
- var _this = this;
- this.printDiv();
- this.printSubHeader('Testing');
- this.printDiv();
-
- Object.keys(adding).sort().map(function (src) {
- _this.printLine(adding[src].filePathWithName);
- return adding[src];
- });
- };
-
- Print.prototype.printQueue = function (files) {
- var _this = this;
- this.printDiv();
- this.printSubHeader('Queued for testing');
- this.printDiv();
-
- files.forEach(function (file) {
- _this.printLine(file.filePathWithName);
- });
- };
-
- Print.prototype.printTestAll = function () {
- this.printDiv();
- this.printSubHeader('Ignoring changes, testing all files');
- };
-
- Print.prototype.printFiles = function (files) {
- var _this = this;
- this.printDiv();
- this.printSubHeader('Files');
- this.printDiv();
-
- files.forEach(function (file) {
- _this.printLine(file.filePathWithName);
- file.references.forEach(function (file) {
- _this.printElement(file.filePathWithName);
- });
- });
- };
-
- Print.prototype.printMissing = function (index, refMap) {
- var _this = this;
- this.printDiv();
- this.printSubHeader('Missing references');
- this.printDiv();
-
- Object.keys(refMap).sort().forEach(function (src) {
- var ref = index.getFile(src);
- _this.printLine('\33[31m\33[1m' + ref.filePathWithName + '\33[0m');
- refMap[src].forEach(function (file) {
- _this.printElement(file.filePathWithName);
- });
- });
- };
-
- Print.prototype.printAllChanges = function (paths) {
- var _this = this;
- this.printSubHeader('All changes');
- this.printDiv();
-
- paths.sort().forEach(function (line) {
- _this.printLine(line);
- });
- };
-
- Print.prototype.printRelChanges = function (changeMap) {
- var _this = this;
- this.printDiv();
- this.printSubHeader('Interesting files');
- this.printDiv();
-
- Object.keys(changeMap).sort().forEach(function (src) {
- _this.printLine(changeMap[src].filePathWithName);
- });
- };
-
- Print.prototype.printRemovals = function (changeMap) {
- var _this = this;
- this.printDiv();
- this.printSubHeader('Removed files');
- this.printDiv();
-
- Object.keys(changeMap).sort().forEach(function (src) {
- _this.printLine(changeMap[src].filePathWithName);
- });
- };
-
- Print.prototype.printRefMap = function (index, refMap) {
- var _this = this;
- this.printDiv();
- this.printSubHeader('Referring');
- this.printDiv();
-
- Object.keys(refMap).sort().forEach(function (src) {
- var ref = index.getFile(src);
- _this.printLine(ref.filePathWithName);
- refMap[src].forEach(function (file) {
- _this.printLine(' - ' + file.filePathWithName);
- });
- });
- };
- return Print;
- })();
- DT.Print = Print;
-})(DT || (DT = {}));
-///
-///
-var DT;
-(function (DT) {
-
-
- /////////////////////////////////
- // Default test reporter
- /////////////////////////////////
- var DefaultTestReporter = (function () {
- function DefaultTestReporter(print) {
- this.print = print;
- this.index = 0;
- }
- DefaultTestReporter.prototype.printPositiveCharacter = function (testResult) {
- this.print.out('\33[36m\33[1m' + '.' + '\33[0m');
- this.index++;
- this.printBreakIfNeeded(this.index);
- };
-
- DefaultTestReporter.prototype.printNegativeCharacter = function (testResult) {
- this.print.out('x');
- this.index++;
- this.printBreakIfNeeded(this.index);
- };
-
- DefaultTestReporter.prototype.printBreakIfNeeded = function (index) {
- if (index % this.print.WIDTH === 0) {
- this.print.printBreak();
- }
- };
- return DefaultTestReporter;
- })();
- DT.DefaultTestReporter = DefaultTestReporter;
-})(DT || (DT = {}));
-///
-var DT;
-(function (DT) {
- 'use strict';
-
- var Promise = require('bluebird');
-
-
-
- /////////////////////////////////
- // Base class for test suite
- /////////////////////////////////
- var TestSuiteBase = (function () {
- function TestSuiteBase(options, testSuiteName, errorHeadline) {
- this.options = options;
- this.testSuiteName = testSuiteName;
- this.errorHeadline = errorHeadline;
- this.timer = new DT.Timer();
- this.testResults = [];
- this.printErrorCount = true;
- this.queue = new DT.TestQueue(options.concurrent);
- }
- TestSuiteBase.prototype.filterTargetFiles = function (files) {
- throw new Error('please implement this method');
- };
-
- TestSuiteBase.prototype.start = function (targetFiles, testCallback) {
- var _this = this;
- this.timer.start();
-
- return this.filterTargetFiles(targetFiles).then(function (targetFiles) {
- // tests get queued for multi-threading
- return Promise.all(targetFiles.map(function (targetFile) {
- return _this.runTest(targetFile).then(function (result) {
- testCallback(result);
- });
- }));
- }).then(function () {
- _this.timer.end();
- return _this;
- });
- };
-
- TestSuiteBase.prototype.runTest = function (targetFile) {
- var _this = this;
- return this.queue.run(new DT.Test(this, targetFile, {
- tscVersion: this.options.tscVersion
- })).then(function (result) {
- _this.testResults.push(result);
- return result;
- });
- };
-
- Object.defineProperty(TestSuiteBase.prototype, "okTests", {
- get: function () {
- return this.testResults.filter(function (r) {
- return r.success;
- });
- },
- enumerable: true,
- configurable: true
- });
-
- Object.defineProperty(TestSuiteBase.prototype, "ngTests", {
- get: function () {
- return this.testResults.filter(function (r) {
- return !r.success;
- });
- },
- enumerable: true,
- configurable: true
- });
- return TestSuiteBase;
- })();
- DT.TestSuiteBase = TestSuiteBase;
-})(DT || (DT = {}));
-///
-///
-var __extends = this.__extends || function (d, b) {
- for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
- function __() { this.constructor = d; }
- __.prototype = b.prototype;
- d.prototype = new __();
-};
-var DT;
-(function (DT) {
- 'use strict';
-
- var Promise = require('bluebird');
-
- var endDts = /\w\.d\.ts$/i;
-
- /////////////////////////////////
- // .d.ts syntax inspection
- /////////////////////////////////
- var SyntaxChecking = (function (_super) {
- __extends(SyntaxChecking, _super);
- function SyntaxChecking(options) {
- _super.call(this, options, 'Syntax checking', 'Syntax error');
- }
- SyntaxChecking.prototype.filterTargetFiles = function (files) {
- return Promise.cast(files.filter(function (file) {
- return endDts.test(file.filePathWithName);
- }));
- };
- return SyntaxChecking;
- })(DT.TestSuiteBase);
- DT.SyntaxChecking = SyntaxChecking;
-})(DT || (DT = {}));
-///
-///
-var DT;
-(function (DT) {
- 'use strict';
-
- var Promise = require('bluebird');
-
- var endTestDts = /\w-tests?\.ts$/i;
-
- /////////////////////////////////
- // Compile with *-tests.ts
- /////////////////////////////////
- var TestEval = (function (_super) {
- __extends(TestEval, _super);
- function TestEval(options) {
- _super.call(this, options, 'Typing tests', 'Failed tests');
- }
- TestEval.prototype.filterTargetFiles = function (files) {
- return Promise.cast(files.filter(function (file) {
- return endTestDts.test(file.filePathWithName);
- }));
- };
- return TestEval;
- })(DT.TestSuiteBase);
- DT.TestEval = TestEval;
-})(DT || (DT = {}));
-///
-///
-var DT;
-(function (DT) {
- 'use strict';
-
- var fs = require('fs');
- var Promise = require('bluebird');
-
- /////////////////////////////////
- // Try compile without .tscparams
- // It may indicate that it is compatible with --noImplicitAny maybe...
- /////////////////////////////////
- var FindNotRequiredTscparams = (function (_super) {
- __extends(FindNotRequiredTscparams, _super);
- function FindNotRequiredTscparams(options, print) {
- var _this = this;
- _super.call(this, options, 'Find not required .tscparams files', 'New arrival!');
- this.print = print;
- this.printErrorCount = false;
-
- this.testReporter = {
- printPositiveCharacter: function (testResult) {
- _this.print.clearCurrentLine().printTypingsWithoutTestName(testResult.targetFile.filePathWithName);
- },
- printNegativeCharacter: function (testResult) {
- }
- };
- }
- FindNotRequiredTscparams.prototype.filterTargetFiles = function (files) {
- return Promise.filter(files, function (file) {
- return new Promise(function (resolve) {
- fs.exists(file.filePathWithName + '.tscparams', resolve);
- });
- });
- };
-
- FindNotRequiredTscparams.prototype.runTest = function (targetFile) {
- var _this = this;
- this.print.clearCurrentLine().out(targetFile.filePathWithName);
-
- return this.queue.run(new DT.Test(this, targetFile, {
- tscVersion: this.options.tscVersion,
- useTscParams: false,
- checkNoImplicitAny: true
- })).then(function (result) {
- _this.testResults.push(result);
- _this.print.clearCurrentLine();
- return result;
- });
- };
-
- Object.defineProperty(FindNotRequiredTscparams.prototype, "ngTests", {
- get: function () {
- // Do not show ng test results
- return [];
- },
- enumerable: true,
- configurable: true
- });
- return FindNotRequiredTscparams;
- })(DT.TestSuiteBase);
- DT.FindNotRequiredTscparams = FindNotRequiredTscparams;
-})(DT || (DT = {}));
-///
-///
-///
-///
-///
-///
-///
-///
-///
-///
-///
-///
-///
-///
-var DT;
-(function (DT) {
- require('source-map-support').install();
-
- // hacky typing
- var Lazy = require('lazy.js');
- var Promise = require('bluebird');
-
- var os = require('os');
- var fs = require('fs');
- var path = require('path');
- var assert = require('assert');
-
- var tsExp = /\.ts$/;
-
- DT.DEFAULT_TSC_VERSION = '0.9.7';
-
- /////////////////////////////////
- // Single test
- /////////////////////////////////
- var Test = (function () {
- function Test(suite, tsfile, options) {
- this.suite = suite;
- this.tsfile = tsfile;
- this.options = options;
- }
- Test.prototype.run = function () {
- var _this = this;
- return DT.Tsc.run(this.tsfile.filePathWithName, this.options).then(function (execResult) {
- var testResult = new TestResult();
- testResult.hostedBy = _this.suite;
- testResult.targetFile = _this.tsfile;
- testResult.options = _this.options;
-
- testResult.stdout = execResult.stdout;
- testResult.stderr = execResult.stderr;
- testResult.exitCode = execResult.exitCode;
-
- return testResult;
- });
- };
- return Test;
- })();
- DT.Test = Test;
-
- /////////////////////////////////
- // Parallel execute Tests
- /////////////////////////////////
- var TestQueue = (function () {
- function TestQueue(concurrent) {
- this.queue = [];
- this.active = [];
- this.concurrent = Math.max(1, concurrent);
- }
- // add to queue and return a promise
- TestQueue.prototype.run = function (test) {
- var _this = this;
- var defer = Promise.defer();
-
- // add a closure to queue
- this.queue.push(function () {
- // run it
- var p = test.run();
- p.then(defer.resolve.bind(defer), defer.reject.bind(defer));
- p.finally(function () {
- var i = _this.active.indexOf(test);
- if (i > -1) {
- _this.active.splice(i, 1);
- }
- _this.step();
- });
-
- // return it
- return test;
- });
- this.step();
-
- // defer it
- return defer.promise;
- };
-
- TestQueue.prototype.step = function () {
- while (this.queue.length > 0 && this.active.length < this.concurrent) {
- this.active.push(this.queue.pop().call(null));
- }
- };
- return TestQueue;
- })();
- DT.TestQueue = TestQueue;
-
- /////////////////////////////////
- // Test results
- /////////////////////////////////
- var TestResult = (function () {
- function TestResult() {
- }
- Object.defineProperty(TestResult.prototype, "success", {
- get: function () {
- return this.exitCode === 0;
- },
- enumerable: true,
- configurable: true
- });
- return TestResult;
- })();
- DT.TestResult = TestResult;
-
- /////////////////////////////////
- // The main class to kick things off
- /////////////////////////////////
- var TestRunner = (function () {
- function TestRunner(dtPath, options) {
- if (typeof options === "undefined") { options = { tscVersion: DT.DEFAULT_TSC_VERSION }; }
- this.dtPath = dtPath;
- this.options = options;
- this.suites = [];
- this.options.findNotRequiredTscparams = !!this.options.findNotRequiredTscparams;
-
- this.index = new DT.FileIndex(this, this.options);
- this.changes = new DT.GitChanges(this);
-
- this.print = new DT.Print(this.options.tscVersion);
- }
- TestRunner.prototype.addSuite = function (suite) {
- this.suites.push(suite);
- };
-
- TestRunner.prototype.checkAcceptFile = function (fileName) {
- var ok = tsExp.test(fileName);
- ok = ok && fileName.indexOf('_infrastructure') < 0;
- ok = ok && fileName.indexOf('node_modules/') < 0;
- ok = ok && /^[a-z]/i.test(fileName);
- return ok;
- };
-
- TestRunner.prototype.run = function () {
- var _this = this;
- this.timer = new DT.Timer();
- this.timer.start();
-
- this.print.printChangeHeader();
-
- // only includes .d.ts or -tests.ts or -test.ts or .ts
- return this.index.readIndex().then(function () {
- return _this.changes.readChanges();
- }).then(function (changes) {
- _this.print.printAllChanges(changes);
- return _this.index.collectDiff(changes);
- }).then(function () {
- _this.print.printRemovals(_this.index.removed);
- _this.print.printRelChanges(_this.index.changed);
- return _this.index.parseFiles();
- }).then(function () {
- if (_this.options.printRefMap) {
- _this.print.printRefMap(_this.index, _this.index.refMap);
- }
- if (Lazy(_this.index.missing).some(function (arr) {
- return arr.length > 0;
- })) {
- _this.print.printMissing(_this.index, _this.index.missing);
- _this.print.printBoldDiv();
-
- // bail
- return Promise.cast(false);
- }
- if (_this.options.printFiles) {
- _this.print.printFiles(_this.index.files);
- }
- return _this.index.collectTargets().then(function (files) {
- if (_this.options.testChanges) {
- _this.print.printQueue(files);
- return _this.runTests(files);
- } else {
- _this.print.printTestAll();
- return _this.runTests(_this.index.files);
- }
- }).then(function () {
- return !_this.suites.some(function (suite) {
- return suite.ngTests.length !== 0;
- });
- });
- });
- };
-
- TestRunner.prototype.runTests = function (files) {
- var _this = this;
- return Promise.attempt(function () {
- assert(Array.isArray(files), 'files must be array');
-
- var syntaxChecking = new DT.SyntaxChecking(_this.options);
- var testEval = new DT.TestEval(_this.options);
-
- if (!_this.options.findNotRequiredTscparams) {
- _this.addSuite(syntaxChecking);
- _this.addSuite(testEval);
- }
-
- return Promise.all([
- syntaxChecking.filterTargetFiles(files),
- testEval.filterTargetFiles(files)
- ]);
- }).spread(function (syntaxFiles, testFiles) {
- _this.print.init(syntaxFiles.length, testFiles.length, files.length);
- _this.print.printHeader(_this.options);
-
- if (_this.options.findNotRequiredTscparams) {
- _this.addSuite(new DT.FindNotRequiredTscparams(_this.options, _this.print));
- }
-
- return Promise.reduce(_this.suites, function (count, suite) {
- suite.testReporter = suite.testReporter || new DT.DefaultTestReporter(_this.print);
-
- _this.print.printSuiteHeader(suite.testSuiteName);
-
- if (_this.options.skipTests) {
- _this.print.printWarnCode('skipped test');
- return Promise.cast(count++);
- }
-
- return suite.start(files, function (testResult) {
- _this.print.printTestComplete(testResult);
- }).then(function (suite) {
- _this.print.printSuiteComplete(suite);
- return count++;
- });
- }, 0);
- }).then(function (count) {
- _this.timer.end();
- _this.finaliseTests(files);
- });
- };
-
- TestRunner.prototype.finaliseTests = function (files) {
- var _this = this;
- var testEval = Lazy(this.suites).filter(function (suite) {
- return suite instanceof DT.TestEval;
- }).first();
-
- if (testEval) {
- var existsTestTypings = Lazy(testEval.testResults).map(function (testResult) {
- return testResult.targetFile.dir;
- }).reduce(function (a, b) {
- return a.indexOf(b) < 0 ? a.concat([b]) : a;
- }, []);
-
- var typings = Lazy(files).map(function (file) {
- return file.dir;
- }).reduce(function (a, b) {
- return a.indexOf(b) < 0 ? a.concat([b]) : a;
- }, []);
-
- var withoutTestTypings = typings.filter(function (typing) {
- return existsTestTypings.indexOf(typing) < 0;
- });
-
- this.print.printDiv();
- this.print.printTypingsWithoutTest(withoutTestTypings);
- }
-
- this.print.printDiv();
- this.print.printTotalMessage();
-
- this.print.printDiv();
- this.print.printElapsedTime(this.timer.asString, this.timer.time);
-
- this.suites.filter(function (suite) {
- return suite.printErrorCount;
- }).forEach(function (suite) {
- _this.print.printSuiteErrorCount(suite.errorHeadline, suite.ngTests.length, suite.testResults.length);
- });
- if (testEval) {
- this.print.printSuiteErrorCount('Without tests', withoutTestTypings.length, typings.length, true);
- }
-
- this.print.printDiv();
-
- if (this.suites.some(function (suite) {
- return suite.ngTests.length !== 0;
- })) {
- this.print.printErrorsHeader();
-
- this.suites.filter(function (suite) {
- return suite.ngTests.length !== 0;
- }).forEach(function (suite) {
- suite.ngTests.forEach(function (testResult) {
- _this.print.printErrorsForFile(testResult);
- });
- _this.print.printBoldDiv();
- });
- }
- };
- return TestRunner;
- })();
- DT.TestRunner = TestRunner;
-
- var optimist = require('optimist')(process.argv);
- optimist.default('try-without-tscparams', false);
- optimist.default('single-thread', false);
- optimist.default('tsc-version', DT.DEFAULT_TSC_VERSION);
-
- optimist.default('test-changes', false);
- optimist.default('skip-tests', false);
- optimist.default('print-files', false);
- optimist.default('print-refmap', false);
-
- optimist.boolean('help');
- optimist.describe('help', 'print help');
- optimist.alias('h', 'help');
-
- var argv = optimist.argv;
-
- var dtPath = path.resolve(path.dirname((module).filename), '..', '..');
- var cpuCores = os.cpus().length;
-
- if (argv.help) {
- optimist.showHelp();
- var pkg = require('../../package.json');
- console.log('Scripts:');
- console.log('');
- Lazy(pkg.scripts).keys().each(function (key) {
- console.log(' $ npm run ' + key);
- });
- process.exit(0);
- }
-
- var testFull = process.env['TRAVIS_BRANCH'] ? /\w\/full$/.test(process.env['TRAVIS_BRANCH']) : false;
-
- new TestRunner(dtPath, {
- concurrent: argv['single-thread'] ? 1 : Math.max(Math.min(24, cpuCores), 2),
- tscVersion: argv['tsc-version'],
- testChanges: testFull ? false : argv['test-changes'],
- skipTests: argv['skip-tests'],
- printFiles: argv['print-files'],
- printRefMap: argv['print-refmap'],
- findNotRequiredTscparams: argv['try-without-tscparam']
- }).run().then(function (success) {
- if (!success) {
- process.exit(1);
- }
- }).catch(function (err) {
- throw err;
- process.exit(2);
- });
-})(DT || (DT = {}));
-//# sourceMappingURL=runner.js.map
diff --git a/_infrastructure/tests/runner.ts b/_infrastructure/tests/runner.ts
deleted file mode 100644
index 1f75aca7a8..0000000000
--- a/_infrastructure/tests/runner.ts
+++ /dev/null
@@ -1,367 +0,0 @@
-///
-
-///
-
-///
-///
-///
-///
-
-///
-///
-
-///
-///
-
-///
-///
-///
-///
-
-module DT {
- require('source-map-support').install();
-
- // hacky typing
- var Lazy: LazyJS.LazyStatic = require('lazy.js');
- var Promise: typeof Promise = require('bluebird');
-
- var os = require('os');
- var fs = require('fs');
- var path = require('path');
- var assert = require('assert');
-
- var tsExp = /\.ts$/;
-
- export var DEFAULT_TSC_VERSION = '0.9.7';
-
- interface PackageJSON {
- scripts: {[key:string]: string};
- }
-
- /////////////////////////////////
- // Single test
- /////////////////////////////////
- export class Test {
- constructor(public suite: ITestSuite, public tsfile: File, public options?: TscExecOptions) {
- }
-
- public run(): Promise {
- return Tsc.run(this.tsfile.filePathWithName, this.options).then((execResult: ExecResult) => {
- var testResult = new TestResult();
- testResult.hostedBy = this.suite;
- testResult.targetFile = this.tsfile;
- testResult.options = this.options;
-
- testResult.stdout = execResult.stdout;
- testResult.stderr = execResult.stderr;
- testResult.exitCode = execResult.exitCode;
-
- return testResult;
- });
- }
- }
-
- /////////////////////////////////
- // Parallel execute Tests
- /////////////////////////////////
- export class TestQueue {
-
- private queue: Function[] = [];
- private active: Test[] = [];
- private concurrent: number;
-
- constructor(concurrent: number) {
- this.concurrent = Math.max(1, concurrent);
- }
-
- // add to queue and return a promise
- run(test: Test): Promise {
- var defer = Promise.defer();
- // add a closure to queue
- this.queue.push(() => {
- // run it
- var p = test.run();
- p.then(defer.resolve.bind(defer), defer.reject.bind(defer));
- p.finally(() => {
- var i = this.active.indexOf(test);
- if (i > -1) {
- this.active.splice(i, 1);
- }
- this.step();
- });
- // return it
- return test;
- });
- this.step();
- // defer it
- return defer.promise;
- }
-
- private step(): void {
- while (this.queue.length > 0 && this.active.length < this.concurrent) {
- this.active.push(this.queue.pop().call(null));
- }
- }
- }
-
- /////////////////////////////////
- // Test results
- /////////////////////////////////
- export class TestResult {
- hostedBy: ITestSuite;
- targetFile: File;
- options: TscExecOptions;
-
- stdout: string;
- stderr: string;
- exitCode: number;
-
- public get success(): boolean {
- return this.exitCode === 0;
- }
- }
-
- export interface ITestRunnerOptions {
- tscVersion:string;
- concurrent?:number;
- testChanges?:boolean;
- skipTests?:boolean;
- printFiles?:boolean;
- printRefMap?:boolean;
- findNotRequiredTscparams?:boolean;
- }
-
- /////////////////////////////////
- // The main class to kick things off
- /////////////////////////////////
- export class TestRunner {
- private timer: Timer;
- private suites: ITestSuite[] = [];
-
- public changes: GitChanges;
- public index: FileIndex;
- public print: Print;
-
- constructor(public dtPath: string, public options: ITestRunnerOptions = {tscVersion: DT.DEFAULT_TSC_VERSION}) {
- this.options.findNotRequiredTscparams = !!this.options.findNotRequiredTscparams;
-
- this.index = new FileIndex(this, this.options);
- this.changes = new GitChanges(this);
-
- this.print = new Print(this.options.tscVersion);
- }
-
- public addSuite(suite: ITestSuite): void {
- this.suites.push(suite);
- }
-
- public checkAcceptFile(fileName: string): boolean {
- var ok = tsExp.test(fileName);
- ok = ok && fileName.indexOf('_infrastructure') < 0;
- ok = ok && fileName.indexOf('node_modules/') < 0;
- ok = ok && /^[a-z]/i.test(fileName);
- return ok;
- }
-
- public run(): Promise {
- this.timer = new Timer();
- this.timer.start();
-
- this.print.printChangeHeader();
-
- // only includes .d.ts or -tests.ts or -test.ts or .ts
- return this.index.readIndex().then(() => {
- return this.changes.readChanges();
- }).then((changes: string[]) => {
- this.print.printAllChanges(changes);
- return this.index.collectDiff(changes);
- }).then(() => {
- this.print.printRemovals(this.index.removed);
- this.print.printRelChanges(this.index.changed);
- return this.index.parseFiles();
- }).then(() => {
- if (this.options.printRefMap) {
- this.print.printRefMap(this.index, this.index.refMap);
- }
- if (Lazy(this.index.missing).some((arr: any[]) => arr.length > 0)) {
- this.print.printMissing(this.index, this.index.missing);
- this.print.printBoldDiv();
- // bail
- return Promise.cast(false);
- }
- if (this.options.printFiles) {
- this.print.printFiles(this.index.files);
- }
- return this.index.collectTargets().then((files) => {
- if (this.options.testChanges) {
- this.print.printQueue(files);
- return this.runTests(files);
- }
- else {
- this.print.printTestAll();
- return this.runTests(this.index.files)
- }
- }).then(() => {
- return !this.suites.some((suite) => {
- return suite.ngTests.length !== 0
- });
- });
- });
- }
-
- private runTests(files: File[]): Promise {
- return Promise.attempt(() => {
- assert(Array.isArray(files), 'files must be array');
-
- var syntaxChecking = new SyntaxChecking(this.options);
- var testEval = new TestEval(this.options);
-
- if (!this.options.findNotRequiredTscparams) {
- this.addSuite(syntaxChecking);
- this.addSuite(testEval);
- }
-
- return Promise.all([
- syntaxChecking.filterTargetFiles(files),
- testEval.filterTargetFiles(files)
- ]);
- }).spread((syntaxFiles, testFiles) => {
- this.print.init(syntaxFiles.length, testFiles.length, files.length);
- this.print.printHeader(this.options);
-
- if (this.options.findNotRequiredTscparams) {
- this.addSuite(new FindNotRequiredTscparams(this.options, this.print));
- }
-
- return Promise.reduce(this.suites, (count, suite: ITestSuite) => {
- suite.testReporter = suite.testReporter || new DefaultTestReporter(this.print);
-
- this.print.printSuiteHeader(suite.testSuiteName);
-
- if (this.options.skipTests) {
- this.print.printWarnCode('skipped test');
- return Promise.cast(count++);
- }
-
- return suite.start(files, (testResult) => {
- this.print.printTestComplete(testResult);
- }).then((suite) => {
- this.print.printSuiteComplete(suite);
- return count++;
- });
- }, 0);
- }).then((count) => {
- this.timer.end();
- this.finaliseTests(files);
- });
- }
-
- private finaliseTests(files: File[]): void {
- var testEval: TestEval = Lazy(this.suites).filter((suite) => {
- return suite instanceof TestEval;
- }).first();
-
- if (testEval) {
- var existsTestTypings: string[] = Lazy(testEval.testResults).map((testResult) => {
- return testResult.targetFile.dir;
- }).reduce((a: string[], b: string) => {
- return a.indexOf(b) < 0 ? a.concat([b]) : a;
- }, []);
-
- var typings: string[] = Lazy(files).map((file) => {
- return file.dir;
- }).reduce((a: string[], b: string) => {
- return a.indexOf(b) < 0 ? a.concat([b]) : a;
- }, []);
-
- var withoutTestTypings: string[] = typings.filter((typing) => {
- return existsTestTypings.indexOf(typing) < 0;
- });
-
- this.print.printDiv();
- this.print.printTypingsWithoutTest(withoutTestTypings);
- }
-
- this.print.printDiv();
- this.print.printTotalMessage();
-
- this.print.printDiv();
- this.print.printElapsedTime(this.timer.asString, this.timer.time);
-
- this.suites.filter((suite: ITestSuite) => {
- return suite.printErrorCount;
- }).forEach((suite: ITestSuite) => {
- this.print.printSuiteErrorCount(suite.errorHeadline, suite.ngTests.length, suite.testResults.length);
- });
- if (testEval) {
- this.print.printSuiteErrorCount('Without tests', withoutTestTypings.length, typings.length, true);
- }
-
- this.print.printDiv();
-
- if (this.suites.some((suite) => {
- return suite.ngTests.length !== 0
- })) {
- this.print.printErrorsHeader();
-
- this.suites.filter((suite) => {
- return suite.ngTests.length !== 0;
- }).forEach((suite) => {
- suite.ngTests.forEach((testResult) => {
- this.print.printErrorsForFile(testResult);
- });
- this.print.printBoldDiv();
- });
- }
- }
- }
-
- var optimist: Optimist = require('optimist')(process.argv);
- optimist.default('try-without-tscparams', false);
- optimist.default('single-thread', false);
- optimist.default('tsc-version', DEFAULT_TSC_VERSION);
-
- optimist.default('test-changes', false);
- optimist.default('skip-tests', false);
- optimist.default('print-files', false);
- optimist.default('print-refmap', false);
-
- optimist.boolean('help');
- optimist.describe('help', 'print help');
- optimist.alias('h', 'help');
-
- var argv: any = optimist.argv;
-
- var dtPath = path.resolve(path.dirname((module).filename), '..', '..');
- var cpuCores = os.cpus().length;
-
- if (argv.help) {
- optimist.showHelp();
- var pkg: PackageJSON = require('../../package.json');
- console.log('Scripts:');
- console.log('');
- Lazy(pkg.scripts).keys().each((key) => {
- console.log(' $ npm run ' + key);
- });
- process.exit(0);
- }
-
- var testFull = process.env['TRAVIS_BRANCH'] ? /\w\/full$/.test(process.env['TRAVIS_BRANCH']) : false;
-
- new TestRunner(dtPath, {
- concurrent: argv['single-thread'] ? 1 : Math.max(Math.min(24, cpuCores), 2),
- tscVersion: argv['tsc-version'],
- testChanges: testFull ? false : argv['test-changes'], // allow magic branch
- skipTests: argv['skip-tests'],
- printFiles: argv['print-files'],
- printRefMap: argv['print-refmap'],
- findNotRequiredTscparams: argv['try-without-tscparam']
- }).run().then((success) => {
- if (!success) {
- process.exit(1);
- }
- }).catch((err) => {
- throw err;
- process.exit(2);
- });
-}
diff --git a/_infrastructure/tests/src/changes.ts b/_infrastructure/tests/src/changes.ts
deleted file mode 100644
index a56c4029eb..0000000000
--- a/_infrastructure/tests/src/changes.ts
+++ /dev/null
@@ -1,36 +0,0 @@
-///
-///
-
-module DT {
- 'use strict';
-
- var fs = require('fs');
- var path = require('path');
- var Git = require('git-wrapper');
- var Promise: typeof Promise = require('bluebird');
-
- export class GitChanges {
-
- git;
- options = {};
-
- constructor(private runner: TestRunner) {
- var dir = path.join(this.runner.dtPath, '.git');
- if (!fs.existsSync(dir)) {
- throw new Error('cannot locate git-dir: ' + dir);
- }
- this.options['git-dir'] = dir;
-
- this.git = new Git(this.options);
- this.git.exec = Promise.promisify(this.git.exec);
- }
-
- public readChanges(): Promise {
- var opts = {};
- var args = ['--name-only HEAD~1'];
- return this.git.exec('diff', opts, args).then((msg: string) => {
- return msg.replace(/^\s+/, '').replace(/\s+$/, '').split(/\r?\n/g);
- });
- }
- }
-}
diff --git a/_infrastructure/tests/src/exec.ts b/_infrastructure/tests/src/exec.ts
deleted file mode 100644
index 3c3f3c0e02..0000000000
--- a/_infrastructure/tests/src/exec.ts
+++ /dev/null
@@ -1,30 +0,0 @@
-module DT {
- 'use strict';
-
- var Promise: typeof Promise = require('bluebird');
- var nodeExec = require('child_process').exec;
-
- export class ExecResult {
- error;
- stdout = '';
- stderr = '';
- exitCode: number;
- }
-
- export function exec(filename: string, cmdLineArgs: string[]): Promise {
- return new Promise((resolve) => {
- var result = new ExecResult();
- result.exitCode = null;
-
- var cmdLine = filename + ' ' + cmdLineArgs.join(' ');
-
- nodeExec(cmdLine, {maxBuffer: 1 * 1024 * 1024}, (error, stdout, stderr) => {
- result.error = error;
- result.stdout = stdout;
- result.stderr = stderr;
- result.exitCode = error ? error.code : 0;
- resolve(result);
- });
- });
- }
-}
diff --git a/_infrastructure/tests/src/file.ts b/_infrastructure/tests/src/file.ts
deleted file mode 100644
index 2c69f8f885..0000000000
--- a/_infrastructure/tests/src/file.ts
+++ /dev/null
@@ -1,46 +0,0 @@
-///
-
-module DT {
- 'use strict';
-
- var path = require('path');
-
- export interface FileDict {
- [fullPath:string]: File;
- }
-
- export interface FileArrDict {
- [fullPath:string]: File[];
- }
-
- /////////////////////////////////
- // Given a document root + ts file pattern this class returns:
- // all the TS files OR just tests OR just definition files
- /////////////////////////////////
- export class File {
- baseDir: string;
- filePathWithName: string;
- dir: string;
- file: string;
- ext: string;
- fullPath: string;
- references: File[] = [];
-
- constructor(baseDir: string, filePathWithName: string) {
- // why choose?
- this.baseDir = baseDir;
- this.filePathWithName = filePathWithName;
- this.ext = path.extname(this.filePathWithName);
- this.file = path.basename(this.filePathWithName, this.ext);
- this.dir = path.dirname(this.filePathWithName);
- this.fullPath = path.join(this.baseDir, this.dir, this.file + this.ext);
-
- // lock it (shallow) (needs `use strict` in each file to work)
- // Object.freeze(this);
- }
-
- toString(): string {
- return '[File ' + this.filePathWithName + ']';
- }
- }
-}
diff --git a/_infrastructure/tests/src/index.ts b/_infrastructure/tests/src/index.ts
deleted file mode 100644
index 7f5878dcb3..0000000000
--- a/_infrastructure/tests/src/index.ts
+++ /dev/null
@@ -1,208 +0,0 @@
-///
-///
-///
-
-module DT {
- 'use strict';
-
- var fs = require('fs');
- var path = require('path');
- var glob = require('glob');
- var Lazy: LazyJS.LazyStatic = require('lazy.js');
- var Promise: typeof Promise = require('bluebird');
-
- var readFile = Promise.promisify(fs.readFile);
-
- /////////////////////////////////
- // Track all files in the repo: map full path to File objects
- /////////////////////////////////
- export class FileIndex {
-
- files: File[];
- fileMap: FileDict;
- refMap: FileArrDict;
- options: ITestRunnerOptions;
- changed: FileDict;
- removed: FileDict;
- missing: FileArrDict;
-
- constructor(private runner: TestRunner, options: ITestRunnerOptions) {
- this.options = options;
- }
-
- public hasFile(target: string): boolean {
- return target in this.fileMap;
- }
-
- public getFile(target: string): File {
- if (target in this.fileMap) {
- return this.fileMap[target];
- }
- return null;
- }
-
- public setFile(file: File): void {
- if (file.fullPath in this.fileMap) {
- throw new Error('cannot overwrite file');
- }
- this.fileMap[file.fullPath] = file;
- }
-
- public readIndex(): Promise {
- this.fileMap = Object.create(null);
-
- return Promise.promisify(glob).call(glob, '**/*.ts', {
- cwd: this.runner.dtPath
- }).then((filesNames: string[]) => {
- this.files = Lazy(filesNames).filter((fileName) => {
- return this.runner.checkAcceptFile(fileName);
- }).map((fileName: string) => {
- var file = new File(this.runner.dtPath, fileName);
- this.fileMap[file.fullPath] = file;
- return file;
- }).toArray();
- });
- }
-
- public collectDiff(changes: string[]): Promise {
- return new Promise((resolve) => {
- // filter changes and bake map for easy lookup
- this.changed = Object.create(null);
- this.removed = Object.create(null);
-
- Lazy(changes).filter((full) => {
- return this.runner.checkAcceptFile(full);
- }).uniq().each((local) => {
- var full = path.resolve(this.runner.dtPath, local);
- var file = this.getFile(full);
- if (!file) {
- // TODO figure out what to do here
- // what does it mean? deleted?ss
- file = new File(this.runner.dtPath, local);
- this.setFile(file);
- this.removed[full] = file;
- // console.log('not in index? %', file.fullPath);
- }
- else {
- this.changed[full] = file;
- }
- });
- // console.log('changed:\n' + Object.keys(this.changed).join('\n'));
- // console.log('removed:\n' + Object.keys(this.removed).join('\n'));
- resolve();
- });
- }
-
- public parseFiles(): Promise {
- return this.loadReferences(this.files).then(() => {
- return this.getMissingReferences();
- });
- }
-
- private getMissingReferences(): Promise {
- return Promise.attempt(() => {
- this.missing = Object.create(null);
- Lazy(this.removed).keys().each((removed) => {
- if (removed in this.refMap) {
- this.missing[removed] = this.refMap[removed];
- }
- });
- });
- }
-
- private loadReferences(files: File[]): Promise {
- return new Promise((resolve, reject) => {
- var queue = files.slice(0);
- var active = [];
- var max = 50;
- var next = () => {
- if (queue.length === 0 && active.length === 0) {
- resolve();
- return;
- }
- // queue paralel
- while (queue.length > 0 && active.length < max) {
- var file = queue.pop();
- active.push(file);
- this.parseFile(file).then((file) => {
- active.splice(active.indexOf(file), 1);
- next();
- }).catch((err) => {
- queue = [];
- active = [];
- reject(err);
- });
- }
- };
- next();
- }).then(() => {
- // bake reverse reference map (referenced to referrers)
- this.refMap = Object.create(null);
-
- Lazy(files).each((file) => {
- Lazy(file.references).each((ref) => {
- if (ref.fullPath in this.refMap) {
- this.refMap[ref.fullPath].push(file);
- }
- else {
- this.refMap[ref.fullPath] = [file];
- }
- });
- });
- });
- }
-
- // TODO replace with a stream?
- private parseFile(file: File): Promise {
- return readFile(file.filePathWithName, {
- encoding: 'utf8',
- flag: 'r'
- }).then((content) => {
- file.references = Lazy(extractReferenceTags(content)).map((ref) => {
- return path.resolve(path.dirname(file.fullPath), ref);
- }).reduce((memo: File[], ref) => {
- if (ref in this.fileMap) {
- memo.push(this.fileMap[ref]);
- }
- else {
- console.log('not mapped? -> ' + ref);
- }
- return memo;
- }, []);
- // return the object
- return file;
- });
- }
-
- public collectTargets(): Promise {
- return new Promise((resolve) => {
- // map out files linked to changes
- // - queue holds files touched by a change
- // - pre-fill with actually changed files
- // - loop queue, if current not seen:
- // - add to result
- // - from refMap queue all files referring to current
-
- var result: FileDict = Object.create(null);
- var queue = Lazy(this.changed).values().toArray();
-
- while (queue.length > 0) {
- var next = queue.shift();
- var fp = next.fullPath;
- if (result[fp]) {
- continue;
- }
- result[fp] = next;
- if (fp in this.refMap) {
- var arr = this.refMap[fp];
- for (var i = 0, ii = arr.length; i < ii; i++) {
- // just add it and skip expensive checks
- queue.push(arr[i]);
- }
- }
- }
- resolve(Lazy(result).values().toArray());
- });
- }
- }
-}
diff --git a/_infrastructure/tests/src/printer.ts b/_infrastructure/tests/src/printer.ts
deleted file mode 100644
index 9ee01f3c6d..0000000000
--- a/_infrastructure/tests/src/printer.ts
+++ /dev/null
@@ -1,281 +0,0 @@
-///
-///
-
-module DT {
-
- var os = require('os');
-
- /////////////////////////////////
- // All the common things that we print are functions of this class
- /////////////////////////////////
- export class Print {
-
- WIDTH = 77;
-
- typings: number;
- tests: number;
- tsFiles: number
-
- constructor(public version: string){
-
- }
-
- public init(typings: number, tests: number, tsFiles: number) {
- this.typings = typings;
- this.tests = tests;
- this.tsFiles = tsFiles;
- }
-
- public out(s: any): Print {
- process.stdout.write(s);
- return this;
- }
-
- public repeat(s: string, times: number): string {
- return new Array(times + 1).join(s);
- }
-
- public printChangeHeader() {
- this.out('=============================================================================\n');
- this.out(' \33[36m\33[1mDefinitelyTyped Diff Detector 0.1.0\33[0m \n');
- this.out('=============================================================================\n');
- }
-
- public printHeader(options: ITestRunnerOptions) {
- var totalMem = Math.round(os.totalmem() / 1024 / 1024) + ' mb';
- var freemem = Math.round(os.freemem() / 1024 / 1024) + ' mb';
-
- this.out('=============================================================================\n');
- this.out(' \33[36m\33[1mDefinitelyTyped Test Runner 0.5.0\33[0m\n');
- this.out('=============================================================================\n');
- this.out(' \33[36m\33[1mTypescript version:\33[0m ' + this.version + '\n');
- this.out(' \33[36m\33[1mTypings :\33[0m ' + this.typings + '\n');
- this.out(' \33[36m\33[1mTests :\33[0m ' + this.tests + '\n');
- this.out(' \33[36m\33[1mTypeScript files :\33[0m ' + this.tsFiles + '\n');
- this.out(' \33[36m\33[1mTotal Memory :\33[0m ' + totalMem + '\n');
- this.out(' \33[36m\33[1mFree Memory :\33[0m ' + freemem + '\n');
- this.out(' \33[36m\33[1mCores :\33[0m ' + os.cpus().length + '\n');
- this.out(' \33[36m\33[1mConcurrent :\33[0m ' + options.concurrent + '\n');
- }
-
- public printSuiteHeader(title: string) {
- var left = Math.floor((this.WIDTH - title.length ) / 2) - 1;
- var right = Math.ceil((this.WIDTH - title.length ) / 2) - 1;
- this.out(this.repeat('=', left)).out(' \33[34m\33[1m');
- this.out(title);
- this.out('\33[0m ').out(this.repeat('=', right)).printBreak();
- }
-
- public printDiv() {
- this.out('-----------------------------------------------------------------------------\n');
- }
-
- public printBoldDiv() {
- this.out('=============================================================================\n');
- }
-
- public printErrorsHeader() {
- this.out('=============================================================================\n');
- this.out(' \33[34m\33[1mErrors in files\33[0m \n');
- this.out('=============================================================================\n');
- }
-
- public printErrorsForFile(testResult: TestResult) {
- this.out('----------------- For file:' + testResult.targetFile.filePathWithName);
- this.printBreak().out(testResult.stderr).printBreak();
- }
-
- public printBreak(): Print {
- this.out('\n');
- return this;
- }
-
- public clearCurrentLine(): Print {
- this.out('\r\33[K');
- return this;
- }
-
- public printSuccessCount(current: number, total: number) {
- var arb = (total === 0) ? 0 : (current / total);
- this.out(' \33[36m\33[1mSuccessful :\33[0m \33[32m\33[1m' + (arb * 100).toFixed(2) + '% (' + current + '/' + total + ')\33[0m\n');
- }
-
- public printFailedCount(current: number, total: number) {
- var arb = (total === 0) ? 0 : (current / total);
- this.out(' \33[36m\33[1mFailure :\33[0m \33[31m\33[1m' + (arb * 100).toFixed(2) + '% (' + current + '/' + total + ')\33[0m\n');
- }
-
- public printTypingsWithoutTestsMessage() {
- this.out(' \33[36m\33[1mTyping without tests\33[0m\n');
- }
-
- public printTotalMessage() {
- this.out(' \33[36m\33[1mTotal\33[0m\n');
- }
-
- public printElapsedTime(time: string, s: number) {
- this.out(' \33[36m\33[1mElapsed time :\33[0m ~' + time + ' (' + s + 's)\n');
- }
-
- public printSuiteErrorCount(errorHeadline: string, current: number, total: number, warn: boolean = false) {
- var arb = (total === 0) ? 0 : (current / total);
- this.out(' \33[36m\33[1m').out(errorHeadline).out(this.repeat(' ', 16 - errorHeadline.length));
- if (warn) {
- this.out(': \33[31m\33[1m' + (arb * 100).toFixed(2) + '% (' + current + '/' + total + ')\33[0m\n');
- }
- else {
- this.out(': \33[33m\33[1m' + (arb * 100).toFixed(2) + '% (' + current + '/' + total + ')\33[0m\n');
- }
- }
-
- public printSubHeader(file: string) {
- this.out(' \33[36m\33[1m' + file + '\33[0m\n');
- }
-
- public printWarnCode(str: string) {
- this.out(' \33[31m\33[1m<' + str.toLowerCase().replace(/ +/g, '-') + '>\33[0m\n');
- }
-
- public printLine(file: string) {
- this.out(file + '\n');
- }
-
- public printElement(file: string) {
- this.out(' - ' + file + '\n');
- }
-
- public printElement2(file: string) {
- this.out(' - ' + file + '\n');
- }
-
- public printTypingsWithoutTestName(file: string) {
- this.out(' - \33[33m\33[1m' + file + '\33[0m\n');
- }
-
- public printTypingsWithoutTest(withoutTestTypings: string[]) {
- if (withoutTestTypings.length > 0) {
- this.printTypingsWithoutTestsMessage();
-
- this.printDiv();
- withoutTestTypings.forEach((t) => {
- this.printTypingsWithoutTestName(t);
- });
- }
- }
-
- public printTestComplete(testResult: TestResult): void {
- var reporter = testResult.hostedBy.testReporter;
- if (testResult.success) {
- reporter.printPositiveCharacter(testResult);
- }
- else {
- reporter.printNegativeCharacter(testResult);
- }
- }
-
- public printSuiteComplete(suite: ITestSuite): void {
- this.printBreak();
-
- this.printDiv();
- this.printElapsedTime(suite.timer.asString, suite.timer.time);
- this.printSuccessCount(suite.okTests.length, suite.testResults.length);
- this.printFailedCount(suite.ngTests.length, suite.testResults.length);
- }
-
- public printTests(adding: FileDict): void {
- this.printDiv();
- this.printSubHeader('Testing');
- this.printDiv();
-
- Object.keys(adding).sort().map((src) => {
- this.printLine(adding[src].filePathWithName);
- return adding[src];
- });
- }
-
- public printQueue(files: File[]): void {
- this.printDiv();
- this.printSubHeader('Queued for testing');
- this.printDiv();
-
- files.forEach((file) => {
- this.printLine(file.filePathWithName);
- });
- }
-
- public printTestAll(): void {
- this.printDiv();
- this.printSubHeader('Ignoring changes, testing all files');
- }
-
- public printFiles(files: File[]): void {
- this.printDiv();
- this.printSubHeader('Files');
- this.printDiv();
-
- files.forEach((file) => {
- this.printLine(file.filePathWithName);
- file.references.forEach((file) => {
- this.printElement(file.filePathWithName);
- });
- });
- }
-
- public printMissing(index: FileIndex, refMap: FileArrDict): void {
- this.printDiv();
- this.printSubHeader('Missing references');
- this.printDiv();
-
- Object.keys(refMap).sort().forEach((src) => {
- var ref = index.getFile(src);
- this.printLine('\33[31m\33[1m' + ref.filePathWithName + '\33[0m');
- refMap[src].forEach((file) => {
- this.printElement(file.filePathWithName);
- });
- });
- }
-
- public printAllChanges(paths: string[]): void {
- this.printSubHeader('All changes');
- this.printDiv();
-
- paths.sort().forEach((line) => {
- this.printLine(line);
- });
- }
-
- public printRelChanges(changeMap: FileDict): void {
- this.printDiv();
- this.printSubHeader('Interesting files');
- this.printDiv();
-
- Object.keys(changeMap).sort().forEach((src) => {
- this.printLine(changeMap[src].filePathWithName);
- });
- }
-
- public printRemovals(changeMap: FileDict): void {
- this.printDiv();
- this.printSubHeader('Removed files');
- this.printDiv();
-
- Object.keys(changeMap).sort().forEach((src) => {
- this.printLine(changeMap[src].filePathWithName);
- });
- }
-
- public printRefMap(index: FileIndex, refMap: FileArrDict): void {
- this.printDiv();
- this.printSubHeader('Referring');
- this.printDiv();
-
- Object.keys(refMap).sort().forEach((src) => {
- var ref = index.getFile(src);
- this.printLine(ref.filePathWithName);
- refMap[src].forEach((file) => {
- this.printLine(' - ' + file.filePathWithName);
- });
- });
- }
- }
-}
diff --git a/_infrastructure/tests/src/reporter/reporter.ts b/_infrastructure/tests/src/reporter/reporter.ts
deleted file mode 100644
index 736ac413cc..0000000000
--- a/_infrastructure/tests/src/reporter/reporter.ts
+++ /dev/null
@@ -1,42 +0,0 @@
-///
-///
-
-module DT {
- /////////////////////////////////
- // Test reporter interface
- // for example, . and x
- /////////////////////////////////
- export interface ITestReporter {
- printPositiveCharacter(testResult: TestResult):void;
- printNegativeCharacter(testResult: TestResult):void;
- }
-
- /////////////////////////////////
- // Default test reporter
- /////////////////////////////////
- export class DefaultTestReporter implements ITestReporter {
-
- index = 0;
-
- constructor(public print: Print) {
- }
-
- public printPositiveCharacter(testResult: TestResult) {
- this.print.out('\33[36m\33[1m' + '.' + '\33[0m');
- this.index++;
- this.printBreakIfNeeded(this.index);
- }
-
- public printNegativeCharacter( testResult: TestResult) {
- this.print.out('x');
- this.index++;
- this.printBreakIfNeeded(this.index);
- }
-
- private printBreakIfNeeded(index: number) {
- if (index % this.print.WIDTH === 0) {
- this.print.printBreak();
- }
- }
- }
-}
diff --git a/_infrastructure/tests/src/suite/suite.ts b/_infrastructure/tests/src/suite/suite.ts
deleted file mode 100644
index 8624da0d37..0000000000
--- a/_infrastructure/tests/src/suite/suite.ts
+++ /dev/null
@@ -1,82 +0,0 @@
-///
-
-module DT {
- 'use strict';
-
- var Promise: typeof Promise = require('bluebird');
-
- /////////////////////////////////
- // The interface for test suite
- /////////////////////////////////
- export interface ITestSuite {
- testSuiteName:string;
- errorHeadline:string;
- filterTargetFiles(files: File[]): Promise;
-
- start(targetFiles: File[], testCallback: (result: TestResult, index: number) => void): Promise;
-
- testResults:TestResult[];
- okTests:TestResult[];
- ngTests:TestResult[];
- timer:Timer;
-
- testReporter:ITestReporter;
- printErrorCount:boolean;
- }
-
- /////////////////////////////////
- // Base class for test suite
- /////////////////////////////////
- export class TestSuiteBase implements ITestSuite {
- timer: Timer = new Timer();
- testResults: TestResult[] = [];
- testReporter: ITestReporter;
- printErrorCount = true;
- queue: TestQueue;
-
- constructor(public options: ITestRunnerOptions, public testSuiteName: string, public errorHeadline: string) {
- this.queue = new TestQueue(options.concurrent);
- }
-
- public filterTargetFiles(files: File[]): Promise {
- throw new Error('please implement this method');
- }
-
- public start(targetFiles: File[], testCallback: (result: TestResult) => void): Promise {
- this.timer.start();
-
- return this.filterTargetFiles(targetFiles).then((targetFiles) => {
- // tests get queued for multi-threading
- return Promise.all(targetFiles.map((targetFile) => {
- return this.runTest(targetFile).then((result) => {
- testCallback(result);
- });
- }));
- }).then(() => {
- this.timer.end();
- return this;
- });
- }
-
- public runTest(targetFile: File): Promise {
- return this.queue.run(new Test(this, targetFile, {
- tscVersion: this.options.tscVersion
- })).then((result) => {
- this.testResults.push(result);
- return result;
- });
- }
-
- public get okTests(): TestResult[] {
- return this.testResults.filter((r) => {
- return r.success;
- });
- }
-
- public get ngTests(): TestResult[] {
- return this.testResults.filter((r) => {
- return !r.success
- });
- }
- }
-}
diff --git a/_infrastructure/tests/src/suite/syntax.ts b/_infrastructure/tests/src/suite/syntax.ts
deleted file mode 100644
index 915fd18d07..0000000000
--- a/_infrastructure/tests/src/suite/syntax.ts
+++ /dev/null
@@ -1,26 +0,0 @@
-///
-///
-
-module DT {
- 'use strict';
-
- var Promise: typeof Promise = require('bluebird');
-
- var endDts = /\w\.d\.ts$/i;
-
- /////////////////////////////////
- // .d.ts syntax inspection
- /////////////////////////////////
- export class SyntaxChecking extends TestSuiteBase {
-
- constructor(options: ITestRunnerOptions) {
- super(options, 'Syntax checking', 'Syntax error');
- }
-
- public filterTargetFiles(files: File[]): Promise {
- return Promise.cast(files.filter((file) => {
- return endDts.test(file.filePathWithName);
- }));
- }
- }
-}
diff --git a/_infrastructure/tests/src/suite/testEval.ts b/_infrastructure/tests/src/suite/testEval.ts
deleted file mode 100644
index abc4d50935..0000000000
--- a/_infrastructure/tests/src/suite/testEval.ts
+++ /dev/null
@@ -1,26 +0,0 @@
-///
-///
-
-module DT {
- 'use strict';
-
- var Promise: typeof Promise = require('bluebird');
-
- var endTestDts = /\w-tests?\.ts$/i;
-
- /////////////////////////////////
- // Compile with *-tests.ts
- /////////////////////////////////
- export class TestEval extends TestSuiteBase {
-
- constructor(options) {
- super(options, 'Typing tests', 'Failed tests');
- }
-
- public filterTargetFiles(files: File[]): Promise {
- return Promise.cast(files.filter((file) => {
- return endTestDts.test(file.filePathWithName);
- }));
- }
- }
-}
diff --git a/_infrastructure/tests/src/suite/tscParams.ts b/_infrastructure/tests/src/suite/tscParams.ts
deleted file mode 100644
index 12e3f46017..0000000000
--- a/_infrastructure/tests/src/suite/tscParams.ts
+++ /dev/null
@@ -1,59 +0,0 @@
-///
-///
-
-module DT {
- 'use strict';
-
- var fs = require('fs');
- var Promise: typeof Promise = require('bluebird');
-
- /////////////////////////////////
- // Try compile without .tscparams
- // It may indicate that it is compatible with --noImplicitAny maybe...
- /////////////////////////////////
- export class FindNotRequiredTscparams extends TestSuiteBase {
- testReporter: ITestReporter;
- printErrorCount = false;
-
- constructor(options: ITestRunnerOptions, private print: Print) {
- super(options, 'Find not required .tscparams files', 'New arrival!');
-
- this.testReporter = {
- printPositiveCharacter: (testResult: TestResult) => {
- this.print
- .clearCurrentLine()
- .printTypingsWithoutTestName(testResult.targetFile.filePathWithName);
- },
- printNegativeCharacter: (testResult: TestResult) => {
- }
- }
- }
-
- public filterTargetFiles(files: File[]): Promise {
- return Promise.filter(files, (file) => {
- return new Promise((resolve) => {
- fs.exists(file.filePathWithName + '.tscparams', resolve);
- });
- });
- }
-
- public runTest(targetFile: File): Promise {
- this.print.clearCurrentLine().out(targetFile.filePathWithName);
-
- return this.queue.run(new Test(this, targetFile, {
- tscVersion: this.options.tscVersion,
- useTscParams: false,
- checkNoImplicitAny: true
- })).then((result) => {
- this.testResults.push(result);
- this.print.clearCurrentLine();
- return result
- });
- }
-
- public get ngTests(): TestResult[] {
- // Do not show ng test results
- return [];
- }
- }
-}
diff --git a/_infrastructure/tests/src/timer.ts b/_infrastructure/tests/src/timer.ts
deleted file mode 100644
index 0f74743471..0000000000
--- a/_infrastructure/tests/src/timer.ts
+++ /dev/null
@@ -1,50 +0,0 @@
-///
-///
-
-module DT {
- 'use strict';
-
- /////////////////////////////////
- // Timer.start starts a timer
- // Timer.end stops the timer and sets asString to the pretty print value
- /////////////////////////////////
- export class Timer {
- startTime: number;
- time = 0;
- asString: string = ''
-
- public start() {
- this.time = 0;
- this.startTime = this.now();
- this.asString = '';
- }
-
- public now(): number {
- return Date.now();
- }
-
- public end() {
- this.time = (this.now() - this.startTime) / 1000;
- this.asString = Timer.prettyDate(this.startTime, this.now());
- }
-
- public static prettyDate(date1: number, date2: number): string {
- var diff = ((date2 - date1) / 1000);
- var day_diff = Math.floor(diff / 86400);
-
- if (isNaN(day_diff) || day_diff < 0 || day_diff >= 31) {
- return null;
- }
-
- return ( (day_diff == 0 && (
- diff < 60 && (diff + ' seconds') ||
- diff < 120 && '1 minute' ||
- diff < 3600 && Math.floor(diff / 60) + ' minutes' ||
- diff < 7200 && '1 hour' ||
- diff < 86400 && Math.floor(diff / 3600) + ' hours') ||
- day_diff == 1 && 'Yesterday' ||
- day_diff < 7 && day_diff + ' days' ||
- day_diff < 31 && Math.ceil(day_diff / 7) + ' weeks'));
- }
- }
-}
diff --git a/_infrastructure/tests/src/tsc.ts b/_infrastructure/tests/src/tsc.ts
deleted file mode 100644
index 61c8335283..0000000000
--- a/_infrastructure/tests/src/tsc.ts
+++ /dev/null
@@ -1,60 +0,0 @@
-///
-///
-///
-
-module DT {
- 'use strict';
-
- var fs = require('fs');
-
- var Promise: typeof Promise = require('bluebird');
-
- export interface TscExecOptions {
- tscVersion?: string;
- useTscParams?: boolean;
- checkNoImplicitAny?: boolean;
- }
-
- export class Tsc {
- public static run(tsfile: string, options: TscExecOptions): Promise {
- var tscPath;
- return new Promise.attempt(() => {
- options = options || {};
- options.tscVersion = options.tscVersion || DEFAULT_TSC_VERSION;
- if (typeof options.checkNoImplicitAny === 'undefined') {
- options.checkNoImplicitAny = true;
- }
- if (typeof options.useTscParams === 'undefined') {
- options.useTscParams = true;
- }
- return fileExists(tsfile);
- }).then((exists) => {
- if (!exists) {
- throw new Error(tsfile + ' does not exist');
- }
- tscPath = './_infrastructure/tests/typescript/' + options.tscVersion + '/tsc.js';
- return fileExists(tscPath);
- }).then((exists) => {
- if (!exists) {
- throw new Error(tscPath + ' does not exist');
- }
- return fileExists(tsfile + '.tscparams');
- }).then(exists => {
- if (exists) {
- return readFile(tsfile + '.tscparams');
- } else {
- return new Promise('');
- }
- }).then((paramContents: string) => {
- var command = 'node ' + tscPath + ' --module commonjs ';
- if (options.useTscParams && paramContents.trim() !== '' && paramContents.trim() !== '""') {
- command += '@' + tsfile + '.tscparams';
- }
- else if (options.checkNoImplicitAny) {
- command += '--noImplicitAny';
- }
- return exec(command, [tsfile]);
- });
- }
- }
-}
diff --git a/_infrastructure/tests/src/util.ts b/_infrastructure/tests/src/util.ts
deleted file mode 100644
index a77583edaa..0000000000
--- a/_infrastructure/tests/src/util.ts
+++ /dev/null
@@ -1,52 +0,0 @@
-///
-
-module DT {
- 'use strict';
-
- var fs = require('fs');
- var Lazy: LazyJS.LazyStatic = require('lazy.js');
- var Promise: typeof Promise = require('bluebird');
-
- var referenceTagExp = //g;
-
- export function endsWith(str: string, suffix: string) {
- return str.indexOf(suffix, str.length - suffix.length) !== -1;
- }
-
- export function extractReferenceTags(source: string): string[] {
- var ret: string[] = [];
- var match: RegExpExecArray;
-
- if (!referenceTagExp.global) {
- throw new Error('referenceTagExp RegExp must have global flag');
- }
- referenceTagExp.lastIndex = 0;
-
- while ((match = referenceTagExp.exec(source))) {
- if (match.length > 0 && match[1].length > 0) {
- ret.push(match[1]);
- }
- }
- return ret;
- }
-
- export function fileExists(target: string): Promise {
- return new Promise((resolve, reject) => {
- fs.exists(target, (bool: boolean) => {
- resolve(bool);
- });
- });
- }
-
- export function readFile(target: string): Promise {
- return new Promise((resolve, reject) => {
- fs.readFile(target, 'utf-8', (err, contents: string) => {
- if (err) {
- reject(err);
- } else {
- resolve(contents);
- }
- });
- });
- }
-}
diff --git a/_infrastructure/tests/typings/bluebird/bluebird.d.ts b/_infrastructure/tests/typings/bluebird/bluebird.d.ts
deleted file mode 100644
index 45db9d86a3..0000000000
--- a/_infrastructure/tests/typings/bluebird/bluebird.d.ts
+++ /dev/null
@@ -1,656 +0,0 @@
-// Type definitions for bluebird 1.0.0
-// Project: https://github.com/petkaantonov/bluebird
-// Definitions by: Bart van der Schoor
-// Definitions: https://github.com/borisyankov/DefinitelyTyped
-
-// ES6 model with generics overload was sourced and trans-multiplied from es6-promises.d.ts
-// By: Campredon
-
-// Warning: recommended to use `tsc > v1.0.0` (critical bugs in generic code:
-// - https://github.com/borisyankov/DefinitelyTyped/issues/1563
-// - https://github.com/borisyankov/DefinitelyTyped/tree/def/bluebird
-
-// Note: replicate changes to all overloads in both definition and test file
-// Note: keep both static and instance members inline (so similar)
-
-// TODO fix remaining TODO annotations in both definition and test
-
-// TODO verify support to have no return statement in handlers to get a Promise (more overloads?)
-
-declare class Promise implements Promise.Thenable {
- /**
- * Create a new promise. The passed in function will receive functions `resolve` and `reject` as its arguments which can be called to seal the fate of the created promise.
- */
- constructor(callback: (resolve: (thenable: Promise.Thenable) => void, reject: (error: any) => void) => void);
- constructor(callback: (resolve: (result: R) => void, reject: (error: any) => void) => void);
-
- /**
- * Promises/A+ `.then()` with progress handler. Returns a new promise chained from this promise. The new promise will be rejected or resolved dedefer on the passed `fulfilledHandler`, `rejectedHandler` and the state of this promise.
- */
- then(onFulfill: (value: R) => Promise.Thenable, onReject: (error: any) => Promise.Thenable, onProgress?: (note: any) => any): Promise;
- then(onFulfill: (value: R) => Promise.Thenable, onReject?: (error: any) => U, onProgress?: (note: any) => any): Promise;
- then(onFulfill: (value: R) => U, onReject: (error: any) => Promise.Thenable, onProgress?: (note: any) => any): Promise;
- then(onFulfill?: (value: R) => U, onReject?: (error: any) => U, onProgress?: (note: any) => any): Promise;
-
- /**
- * This is a catch-all exception handler, shortcut for calling `.then(null, handler)` on this promise. Any exception happening in a `.then`-chain will propagate to nearest `.catch` handler.
- *
- * Alias `.caught();` for compatibility with earlier ECMAScript version.
- */
- catch(onReject?: (error: any) => Promise.Thenable): Promise;
- caught(onReject?: (error: any) => Promise.Thenable): Promise;
-
- catch(onReject?: (error: any) => U): Promise;
- caught(onReject?: (error: any) => U): Promise;
-
- /**
- * This extends `.catch` to work more like catch-clauses in languages like Java or C#. Instead of manually checking `instanceof` or `.name === "SomeError"`, you may specify a number of error constructors which are eligible for this catch handler. The catch handler that is first met that has eligible constructors specified, is the one that will be called.
- *
- * This method also supports predicate-based filters. If you pass a predicate function instead of an error constructor, the predicate will receive the error as an argument. The return result of the predicate will be used determine whether the error handler should be called.
- *
- * Alias `.caught();` for compatibility with earlier ECMAScript version.
- */
- catch(predicate: (error: any) => boolean, onReject: (error: any) => Promise.Thenable): Promise;
- caught(predicate: (error: any) => boolean, onReject: (error: any) => Promise.Thenable): Promise;
-
- catch(predicate: (error: any) => boolean, onReject: (error: any) => U): Promise;
- caught(predicate: (error: any) => boolean, onReject: (error: any) => U): Promise;
-
- catch(ErrorClass: Function, onReject: (error: any) => Promise.Thenable): Promise;
- caught(ErrorClass: Function, onReject: (error: any) => Promise.Thenable): Promise;
-
- catch(ErrorClass: Function, onReject: (error: any) => U): Promise;
- caught(ErrorClass: Function, onReject: (error: any) => U): Promise;
-
- /**
- * Like `.catch` but instead of catching all types of exceptions, it only catches those that don't originate from thrown errors but rather from explicit rejections.
- */
- error(onReject: (reason: any) => Promise.Thenable): Promise;
- error(onReject: (reason: any) => U): Promise;
-
- /**
- * Pass a handler that will be called regardless of this promise's fate. Returns a new promise chained from this promise. There are special semantics for `.finally()` in that the final value cannot be modified from the handler.
- *
- * Alias `.lastly();` for compatibility with earlier ECMAScript version.
- */
- finally(handler: (value: R) => Promise.Thenable): Promise;
- finally(handler: (value: R) => R): Promise;
- finally(handler: (value: R) => void): Promise;
-
- lastly(handler: (value: R) => Promise.Thenable): Promise;
- lastly(handler: (value: R) => R): Promise;
-
- /**
- * Create a promise that follows this promise, but is bound to the given `thisArg` value. A bound promise will call its handlers with the bound value set to `this`. Additionally promises derived from a bound promise will also be bound promises with the same `thisArg` binding as the original promise.
- */
- bind(thisArg: any): Promise;
-
- /**
- * Like `.then()`, but any unhandled rejection that ends up here will be thrown as an error.
- */
- done(onFulfilled: (value: R) => Promise.Thenable, onRejected: (error: any) => Promise.Thenable, onProgress?: (note: any) => any): Promise;
- done(onFulfilled: (value: R) => Promise.Thenable, onRejected?: (error: any) => U, onProgress?: (note: any) => any): Promise;
- done(onFulfilled: (value: R) => U, onRejected: (error: any) => Promise.Thenable, onProgress?: (note: any) => any): Promise;
- done(onFulfilled?: (value: R) => U, onRejected?: (error: any) => U, onProgress?: (note: any) => any): Promise;
-
- /**
- * Shorthand for `.then(null, null, handler);`. Attach a progress handler that will be called if this promise is progressed. Returns a new promise chained from this promise.
- */
- progressed(handler: (note: any) => any): Promise;
-
- /**
- * Same as calling `Promise.delay(this, ms)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
- */
- delay(ms: number): Promise;
-
- /**
- * Returns a promise that will be fulfilled with this promise's fulfillment value or rejection reason. However, if this promise is not fulfilled or rejected within `ms` milliseconds, the returned promise is rejected with a `Promise.TimeoutError` instance.
- *
- * You may specify a custom error message with the `message` parameter.
- */
- timeout(ms: number, message?: string): Promise;
-
- /**
- * Register a node-style callback on this promise. When this promise is is either fulfilled or rejected, the node callback will be called back with the node.js convention where error reason is the first argument and success value is the second argument. The error argument will be `null` in case of success.
- * Returns back this promise instead of creating a new one. If the `callback` argument is not a function, this method does not do anything.
- */
- nodeify(callback: (err: any, value?: R) => void): Promise;
- nodeify(...sink: any[]): void;
-
- /**
- * Marks this promise as cancellable. Promises by default are not cancellable after v0.11 and must be marked as such for `.cancel()` to have any effect. Marking a promise as cancellable is infectious and you don't need to remark any descendant promise.
- */
- cancellable(): Promise;
-
- /**
- * Cancel this promise. The cancellation will propagate to farthest cancellable ancestor promise which is still pending.
- *
- * That ancestor will then be rejected with a `CancellationError` (get a reference from `Promise.CancellationError`) object as the rejection reason.
- *
- * In a promise rejection handler you may check for a cancellation by seeing if the reason object has `.name === "Cancel"`.
- *
- * Promises are by default not cancellable. Use `.cancellable()` to mark a promise as cancellable.
- */
- // TODO what to do with this?
- cancel(): Promise;
-
- /**
- * Like `.then()`, but cancellation of the the returned promise or any of its descendant will not propagate cancellation to this promise or this promise's ancestors.
- */
- fork(onFulfilled: (value: R) => Promise.Thenable, onRejected: (error: any) => Promise.Thenable, onProgress?: (note: any) => any): Promise;
- fork(onFulfilled: (value: R) => Promise.Thenable, onRejected?: (error: any) => U, onProgress?: (note: any) => any): Promise;
- fork(onFulfilled: (value: R) => U, onRejected: (error: any) => Promise.Thenable, onProgress?: (note: any) => any): Promise;
- fork(onFulfilled?: (value: R) => U, onRejected?: (error: any) => U, onProgress?: (note: any) => any): Promise;
-
- /**
- * Create an uncancellable promise based on this promise.
- */
- uncancellable(): Promise;
-
- /**
- * See if this promise can be cancelled.
- */
- isCancellable(): boolean;
-
- /**
- * See if this `promise` has been fulfilled.
- */
- isFulfilled(): boolean;
-
- /**
- * See if this `promise` has been rejected.
- */
- isRejected(): boolean;
-
- /**
- * See if this `promise` is still defer.
- */
- isPending(): boolean;
-
- /**
- * See if this `promise` is resolved -> either fulfilled or rejected.
- */
- isResolved(): boolean;
-
- /**
- * Synchronously inspect the state of this `promise`. The `PromiseInspection` will represent the state of the promise as snapshotted at the time of calling `.inspect()`.
- */
- inspect(): Promise.Inspection;
-
- /**
- * This is a convenience method for doing:
- *
- *
- * promise.then(function(obj){
- * return obj[propertyName].call(obj, arg...);
- * });
- *
- */
- call(propertyName: string, ...args: any[]): Promise;
-
- /**
- * This is a convenience method for doing:
- *
- *
- * promise.then(function(obj){
- * return obj[propertyName];
- * });
- *
- */
- // TODO find way to fix get()
- // get(propertyName: string): Promise;
-
- /**
- * Convenience method for:
- *
- *
- * .then(function() {
- * return value;
- * });
- *
- *
- * in the case where `value` doesn't change its value. That means `value` is bound at the time of calling `.return()`
- *
- * Alias `.thenReturn();` for compatibility with earlier ECMAScript version.
- */
- return(value: U): Promise;
- thenReturn(value: U): Promise;
- return(): Promise;
- thenReturn(): Promise;
-
- /**
- * Convenience method for:
- *
- *
- * .then(function() {
- * throw reason;
- * });
- *
- * Same limitations apply as with `.return()`.
- *
- * Alias `.thenThrow();` for compatibility with earlier ECMAScript version.
- */
- throw(reason: Error): Promise;
- thenThrow(reason: Error): Promise;
-
- /**
- * Convert to String.
- */
- toString(): string;
-
- /**
- * This is implicitly called by `JSON.stringify` when serializing the object. Returns a serialized representation of the `Promise`.
- */
- toJSON(): Object;
-
- /**
- * Like calling `.then`, but the fulfillment value or rejection reason is assumed to be an array, which is flattened to the formal parameters of the handlers.
- */
- // TODO how to model instance.spread()? like Q?
- spread(onFulfill: Function, onReject?: (reason: any) => Promise.Thenable): Promise;
- spread(onFulfill: Function, onReject?: (reason: any) => U): Promise;
- /*
- // TODO or something like this?
- spread(onFulfill: (...values: W[]) => Promise.Thenable, onReject?: (reason: any) => Promise.Thenable): Promise;
- spread(onFulfill: (...values: W[]) => Promise.Thenable, onReject?: (reason: any) => U): Promise;
- spread(onFulfill: (...values: W[]) => U, onReject?: (reason: any) => Promise.Thenable): Promise;
- spread(onFulfill: (...values: W[]) => U, onReject?: (reason: any) => U): Promise;
- */
- /**
- * Same as calling `Promise.all(thisPromise)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
- */
- // TODO type inference from array-resolving promise?
- all(): Promise;
-
- /**
- * Same as calling `Promise.props(thisPromise)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
- */
- // TODO how to model instance.props()?
- props(): Promise