Remove unused (and sometimes broken) targets and scripts (#30054)
* Remove unused (and sometimes broken) targets and scripts * Remove browser-specific harness code
This commit is contained in:
parent
e982240500
commit
a887c6ba40
51
Gulpfile.js
51
Gulpfile.js
|
@ -12,10 +12,9 @@ const merge2 = require("merge2");
|
|||
const mkdirp = require("mkdirp");
|
||||
const { src, dest, task, parallel, series, watch } = require("gulp");
|
||||
const { append, transform } = require("gulp-insert");
|
||||
const { browserify } = require("./scripts/build/browserify");
|
||||
const { prependFile } = require("./scripts/build/prepend");
|
||||
const { exec, readJson, needsUpdate, getDiffTool, getDirSize, flatten, rm } = require("./scripts/build/utils");
|
||||
const { runConsoleTests, cleanTestDirs, writeTestConfigFile, refBaseline, localBaseline, refRwcBaseline, localRwcBaseline } = require("./scripts/build/tests");
|
||||
const { runConsoleTests, refBaseline, localBaseline, refRwcBaseline, localRwcBaseline } = require("./scripts/build/tests");
|
||||
const { buildProject, cleanProject, watchProject } = require("./scripts/build/projects");
|
||||
const cmdLineOptions = require("./scripts/build/options");
|
||||
|
||||
|
@ -454,44 +453,6 @@ task("runtests-parallel").flags = {
|
|||
" --built": "Compile using the built version of the compiler.",
|
||||
};
|
||||
|
||||
const buildWebTestServer = () => buildProject("tests/webTestServer.tsconfig.json");
|
||||
const cleanWebTestServer = () => cleanProject("tests/webTestServer.tsconfig.json");
|
||||
cleanTasks.push(cleanWebTestServer);
|
||||
|
||||
const browserifyTests = () => src(["built/local/run.js"], { base: "built/local" })
|
||||
.pipe(newer("built/local/bundle.js"))
|
||||
.pipe(sourcemaps.init({ loadMaps: true }))
|
||||
.pipe(browserify())
|
||||
.pipe(rename("bundle.js"))
|
||||
.pipe(sourcemaps.write(".", /**@type {*}*/({ includeContent: false, destPath: "built/local" })))
|
||||
.pipe(dest("built/local"));
|
||||
|
||||
const runtestsBrowser = async () => {
|
||||
await cleanTestDirs();
|
||||
const { tests, runners, light } = cmdLineOptions;
|
||||
const testConfigFile = "test.config";
|
||||
await del([testConfigFile]);
|
||||
if (tests || runners || light) {
|
||||
writeTestConfigFile(tests, runners, light);
|
||||
}
|
||||
const args = ["tests/webTestServer.js"];
|
||||
if (cmdLineOptions.browser) {
|
||||
args.push(cmdLineOptions.browser);
|
||||
}
|
||||
if (tests) {
|
||||
args.push(JSON.stringify(tests));
|
||||
}
|
||||
await exec(process.execPath, args);
|
||||
};
|
||||
|
||||
task("runtests-browser", series(preBuild, parallel(buildTests, buildServices, buildLssl, buildWebTestServer), browserifyTests, runtestsBrowser));
|
||||
task("runtests-browser").description = "Runs the tests using the built run.js file like 'gulp runtests'.";
|
||||
task("runtests-browser").flags = {
|
||||
"-t --tests=<regex>": "pattern for tests to run",
|
||||
"-b --browser=<browser>": "Either 'IE' or 'chrome'",
|
||||
" --built": "Compile using the built version of the compiler.",
|
||||
};
|
||||
|
||||
task("diff", () => exec(getDiffTool(), [refBaseline, localBaseline], { ignoreExitCode: true }));
|
||||
task("diff").description = "Diffs the compiler baselines using the diff tool specified by the 'DIFF' environment variable";
|
||||
|
||||
|
@ -525,16 +486,6 @@ cleanTasks.push(cleanWebHost);
|
|||
task("clean-webhost", cleanWebHost);
|
||||
task("clean-webhost").description = "Cleans the outputs of the tsc web host";
|
||||
|
||||
// TODO(rbuckton): Determine if 'perftsc' is still in use.
|
||||
const buildPerfTsc = () => buildProject("tests/perftsc.tsconfig.json");
|
||||
task("perftsc", series(lkgPreBuild, buildPerfTsc));
|
||||
task("perftsc").description = "Builds augmented version of the compiler for perf tests";
|
||||
|
||||
const cleanPerfTsc = () => cleanProject("tests/perftsc.tsconfig.json");
|
||||
cleanTasks.push(cleanPerfTsc);
|
||||
task("clean-perftsc", cleanPerfTsc);
|
||||
task("clean-perftsc").description = "Cleans the outputs of the perftsc project";
|
||||
|
||||
const buildLoggedIO = async () => {
|
||||
mkdirp.sync("built/local/temp");
|
||||
await exec(process.execPath, ["lib/tsc", "--types", "--target", "es5", "--lib", "es5", "--outdir", "built/local/temp", "src/harness/loggedIO.ts"]);
|
||||
|
|
|
@ -1,24 +0,0 @@
|
|||
// simple script to optionally elide source-map-support (or other optional modules) when running browserify.
|
||||
|
||||
var stream = require("stream"),
|
||||
Transform = stream.Transform,
|
||||
resolve = require("browser-resolve");
|
||||
|
||||
var requirePattern = /require\s*\(\s*['"](source-map-support)['"]\s*\)/;
|
||||
module.exports = function (file) {
|
||||
return new Transform({
|
||||
transform: function (data, encoding, cb) {
|
||||
var text = encoding === "buffer" ? data.toString("utf8") : data;
|
||||
this.push(new Buffer(text.replace(requirePattern, function (originalText, moduleName) {
|
||||
try {
|
||||
resolve.sync(moduleName, { filename: file });
|
||||
return originalText;
|
||||
}
|
||||
catch (e) {
|
||||
return "(function () { throw new Error(\"module '" + moduleName + "' not found.\"); })()";
|
||||
}
|
||||
}), "utf8"));
|
||||
cb();
|
||||
}
|
||||
});
|
||||
};
|
|
@ -1,33 +0,0 @@
|
|||
// @ts-check
|
||||
const browserify = require("browserify");
|
||||
const Vinyl = require("vinyl");
|
||||
const { Transform } = require("stream");
|
||||
const { streamFromFile } = require("./utils");
|
||||
const { replaceContents } = require("./sourcemaps");
|
||||
|
||||
/**
|
||||
* @param {import("browserify").Options} [opts]
|
||||
*/
|
||||
function browserifyFile(opts) {
|
||||
return new Transform({
|
||||
objectMode: true,
|
||||
/**
|
||||
* @param {string | Buffer | Vinyl} input
|
||||
*/
|
||||
transform(input, _, cb) {
|
||||
if (typeof input === "string" || Buffer.isBuffer(input)) return cb(new Error("Only Vinyl files are supported."));
|
||||
try {
|
||||
browserify(Object.assign({}, opts, { debug: !!input.sourceMap, basedir: input.base }))
|
||||
.add(streamFromFile(input), { file: input.path, basedir: input.base })
|
||||
.bundle((err, contents) => {
|
||||
if (err) return cb(err);
|
||||
cb(null, replaceContents(input, contents));
|
||||
});
|
||||
}
|
||||
catch (e) {
|
||||
cb(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
exports.browserify = browserifyFile;
|
|
@ -1,102 +1,4 @@
|
|||
// @ts-check
|
||||
/// <reference path="../types/ambient.d.ts" />
|
||||
|
||||
const path = require("path");
|
||||
const convertMap = require("convert-source-map");
|
||||
const applySourceMap = require("vinyl-sourcemaps-apply");
|
||||
const through2 = require("through2");
|
||||
|
||||
/**
|
||||
* @param {import("vinyl")} input
|
||||
* @param {string | Buffer} contents
|
||||
* @param {string | RawSourceMap} [sourceMap]
|
||||
*/
|
||||
function replaceContents(input, contents, sourceMap) {
|
||||
const output = input.clone();
|
||||
output.contents = typeof contents === "string" ? Buffer.from(contents, "utf8") : contents;
|
||||
if (input.sourceMap) {
|
||||
output.sourceMap = typeof input.sourceMap === "string" ? /**@type {RawSourceMap}*/(JSON.parse(input.sourceMap)) : input.sourceMap;
|
||||
if (typeof sourceMap === "string") {
|
||||
sourceMap = /** @type {RawSourceMap} */(JSON.parse(sourceMap));
|
||||
}
|
||||
else if (sourceMap === undefined) {
|
||||
const stringContents = typeof contents === "string" ? contents : contents.toString("utf8");
|
||||
const newSourceMapConverter = convertMap.fromSource(stringContents);
|
||||
if (newSourceMapConverter) {
|
||||
sourceMap = /** @type {RawSourceMap} */(newSourceMapConverter.toObject());
|
||||
output.contents = new Buffer(convertMap.removeMapFileComments(stringContents), "utf8");
|
||||
}
|
||||
}
|
||||
if (sourceMap) {
|
||||
const cwd = input.cwd || process.cwd();
|
||||
const base = input.base || cwd;
|
||||
const sourceRoot = output.sourceMap.sourceRoot;
|
||||
makeAbsoluteSourceMap(cwd, base, output.sourceMap);
|
||||
makeAbsoluteSourceMap(cwd, base, /** @type {RawSourceMap} */(sourceMap));
|
||||
applySourceMap(output, sourceMap);
|
||||
makeRelativeSourceMap(cwd, base, sourceRoot, output.sourceMap);
|
||||
}
|
||||
else {
|
||||
output.sourceMap = undefined;
|
||||
}
|
||||
}
|
||||
return output;
|
||||
}
|
||||
exports.replaceContents = replaceContents;
|
||||
|
||||
function removeSourceMaps() {
|
||||
return through2.obj((/**@type {import("vinyl")}*/file, _, cb) => {
|
||||
if (file.isBuffer()) {
|
||||
file.contents = Buffer.from(convertMap.removeMapFileComments(file.contents.toString("utf8")), "utf8");
|
||||
if (file.sourceMap) {
|
||||
file.sourceMap = undefined;
|
||||
}
|
||||
}
|
||||
cb(null, file);
|
||||
});
|
||||
}
|
||||
exports.removeSourceMaps = removeSourceMaps;
|
||||
|
||||
/**
|
||||
* @param {string | undefined} cwd
|
||||
* @param {string | undefined} base
|
||||
* @param {RawSourceMap} sourceMap
|
||||
*
|
||||
* @typedef {object} RawSourceMap
|
||||
* @property {string} version
|
||||
* @property {string} file
|
||||
* @property {string} [sourceRoot]
|
||||
* @property {string[]} sources
|
||||
* @property {string[]} [sourcesContent]
|
||||
* @property {string} mappings
|
||||
* @property {string[]} [names]
|
||||
*/
|
||||
function makeAbsoluteSourceMap(cwd = process.cwd(), base = "", sourceMap) {
|
||||
const sourceRoot = sourceMap.sourceRoot || "";
|
||||
const resolvedBase = path.resolve(cwd, base);
|
||||
const resolvedSourceRoot = path.resolve(resolvedBase, sourceRoot);
|
||||
sourceMap.file = path.resolve(resolvedBase, sourceMap.file).replace(/\\/g, "/");
|
||||
sourceMap.sources = sourceMap.sources.map(source => path.resolve(resolvedSourceRoot, source).replace(/\\/g, "/"));
|
||||
sourceMap.sourceRoot = "";
|
||||
}
|
||||
exports.makeAbsoluteSourceMap = makeAbsoluteSourceMap;
|
||||
|
||||
/**
|
||||
* @param {string | undefined} cwd
|
||||
* @param {string | undefined} base
|
||||
* @param {string} sourceRoot
|
||||
* @param {RawSourceMap} sourceMap
|
||||
*/
|
||||
function makeRelativeSourceMap(cwd = process.cwd(), base = "", sourceRoot, sourceMap) {
|
||||
makeAbsoluteSourceMap(cwd, base, sourceMap);
|
||||
const resolvedBase = path.resolve(cwd, base);
|
||||
const resolvedSourceRoot = path.resolve(resolvedBase, sourceRoot);
|
||||
sourceMap.file = path.relative(resolvedBase, sourceMap.file).replace(/\\/g, "/");
|
||||
sourceMap.sources = sourceMap.sources.map(source => path.relative(resolvedSourceRoot, source).replace(/\\/g, "/"));
|
||||
sourceMap.sourceRoot = sourceRoot;
|
||||
}
|
||||
exports.makeRelativeSourceMap = makeRelativeSourceMap;
|
||||
|
||||
/**
|
||||
* @param {string} message
|
||||
* @returns {never}
|
||||
|
|
|
@ -1,124 +0,0 @@
|
|||
/// <reference path="../src/harness/external/node.d.ts" />
|
||||
/// <reference path="../built/local/typescript.d.ts" />
|
||||
|
||||
import * as fs from "fs";
|
||||
import * as path from "path";
|
||||
import * as typescript from "typescript";
|
||||
declare var ts: typeof typescript;
|
||||
|
||||
var tsSourceDir = "../src";
|
||||
var tsBuildDir = "../built/local";
|
||||
var testOutputDir = "../built/benchmark";
|
||||
var sourceFiles = [
|
||||
"compiler/types.ts",
|
||||
"compiler/core.ts",
|
||||
"compiler/sys.ts",
|
||||
"compiler/diagnosticInformationMap.generated.ts",
|
||||
"compiler/scanner.ts",
|
||||
"compiler/binder.ts",
|
||||
"compiler/utilities.ts",
|
||||
"compiler/parser.ts",
|
||||
"compiler/checker.ts",
|
||||
"compiler/declarationEmitter.ts",
|
||||
"compiler/emitter.ts",
|
||||
"compiler/program.ts",
|
||||
"compiler/commandLineParser.ts",
|
||||
"compiler/tsc.ts"];
|
||||
|
||||
// .ts sources for the compiler, used as a test input
|
||||
var rawCompilerSources = "";
|
||||
sourceFiles.forEach(f=> {
|
||||
rawCompilerSources += "\r\n" + fs.readFileSync(path.join(tsSourceDir, f)).toString();
|
||||
});
|
||||
var compilerSources = `var compilerSources = ${JSON.stringify(rawCompilerSources) };`;
|
||||
|
||||
// .js code for the compiler, what we are actually testing
|
||||
var rawCompilerJavaScript = fs.readFileSync(path.join(tsBuildDir, "tsc.js")).toString();
|
||||
rawCompilerJavaScript = rawCompilerJavaScript.replace("ts.executeCommandLine(ts.sys.args);", "");
|
||||
|
||||
// lib.d.ts sources
|
||||
var rawLibSources = fs.readFileSync(path.join(tsBuildDir, "lib.d.ts")).toString();
|
||||
var libSources = `var libSources = ${JSON.stringify(rawLibSources) };`;
|
||||
|
||||
// write test output
|
||||
if (!fs.existsSync(testOutputDir)) {
|
||||
fs.mkdirSync(testOutputDir);
|
||||
}
|
||||
|
||||
// 1. compiler ts sources, used to test
|
||||
fs.writeFileSync(
|
||||
path.join(testOutputDir, "compilerSources.js"),
|
||||
`${ compilerSources } \r\n ${ libSources }`);
|
||||
|
||||
// 2. the compiler js sources + a call the compiler
|
||||
fs.writeFileSync(
|
||||
path.join(testOutputDir, "benchmarktsc.js"),
|
||||
`${ rawCompilerJavaScript }\r\n${ compile.toString() }\r\ncompile(compilerSources, libSources);`);
|
||||
|
||||
// 3. test html file to drive the test
|
||||
fs.writeFileSync(
|
||||
path.join(testOutputDir, "benchmarktsc.html"),
|
||||
`<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta content="IE=Edge" http-equiv="X-UA-Compatible">
|
||||
<title>Typescript 1.1 Compiler</title>
|
||||
<meta content="text/html; charset=ISO-8859-1" http-equiv="content-type">
|
||||
</head>
|
||||
<body>
|
||||
<div><span>Status: </span><span id="status">Running</span></div>
|
||||
<div id="main"><span>End-to-End Time: </span><span id="totalTime">N/A</span></div>
|
||||
<script>
|
||||
var startTime = performance.now();
|
||||
</script>
|
||||
<script src="compilerSources.js"></script>
|
||||
<script src="benchmarktsc.js"></script>
|
||||
<script>
|
||||
var endTime = performance.now();
|
||||
document.getElementById("totalTime").innerHTML = parseInt(endTime - startTime, 10);
|
||||
document.getElementById("status").innerHTML = "DONE";
|
||||
</script>
|
||||
</body>
|
||||
</html>`);
|
||||
|
||||
function compile(compilerSources, librarySources) {
|
||||
var program = ts.createProgram(
|
||||
["lib.d.ts", "compiler.ts"],
|
||||
{
|
||||
noResolve: true,
|
||||
out: "compiler.js",
|
||||
removeComments: true,
|
||||
target: ts.ScriptTarget.ES3
|
||||
}, {
|
||||
getDefaultLibFileName: () => "lib.d.ts",
|
||||
getSourceFile: (filename, languageVersion) => {
|
||||
var source: string;
|
||||
if (filename === "lib.d.ts") source = librarySources;
|
||||
else if (filename === "compiler.ts") source = compilerSources;
|
||||
else console.error("Unexpected read file request: " + filename);
|
||||
|
||||
return ts.createSourceFile(filename, source, languageVersion);
|
||||
},
|
||||
writeFile: (filename, data, writeByteOrderMark) => {
|
||||
if (filename !== "compiler.js")
|
||||
console.error("Unexpected write file request: " + filename);
|
||||
// console.log(data);
|
||||
},
|
||||
getCurrentDirectory: () => "",
|
||||
getCanonicalFileName: (filename) => filename,
|
||||
useCaseSensitiveFileNames: () => false,
|
||||
getNewLine: () => "\r\n"
|
||||
});
|
||||
|
||||
var emitOutput = program.emit();
|
||||
|
||||
var errors = program.getSyntacticDiagnostics()
|
||||
.concat(program.getSemanticDiagnostics())
|
||||
.concat(program.getGlobalDiagnostics())
|
||||
.concat(emitOutput.diagnostics);
|
||||
|
||||
if (errors.length) {
|
||||
console.error("Unexpected errors.");
|
||||
errors.forEach(e=> console.log(`${e.code}: ${e.messageText}`))
|
||||
}
|
||||
}
|
125
scripts/ior.ts
125
scripts/ior.ts
|
@ -1,125 +0,0 @@
|
|||
/// <reference types="node"/>
|
||||
|
||||
import fs = require('fs');
|
||||
import path = require('path');
|
||||
|
||||
interface IOLog {
|
||||
filesRead: {
|
||||
path: string;
|
||||
result: { contents: string; };
|
||||
}[];
|
||||
arguments: string[];
|
||||
}
|
||||
|
||||
module Commands {
|
||||
export function dir(obj: IOLog) {
|
||||
obj.filesRead.filter(f => f.result !== undefined).forEach(f => {
|
||||
console.log(f.path);
|
||||
});
|
||||
}
|
||||
dir['description'] = ': displays a list of files';
|
||||
|
||||
export function find(obj: IOLog, str: string) {
|
||||
obj.filesRead.filter(f => f.result !== undefined).forEach(f => {
|
||||
var lines = f.result.contents.split('\n');
|
||||
var printedHeader = false;
|
||||
lines.forEach(line => {
|
||||
if (line.indexOf(str) >= 0) {
|
||||
if (!printedHeader) {
|
||||
console.log(' === ' + f.path + ' ===');
|
||||
printedHeader = true;
|
||||
}
|
||||
console.log(line);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
find['description'] = ' string: finds text in files';
|
||||
|
||||
export function grab(obj: IOLog, filename: string) {
|
||||
obj.filesRead.filter(f => f.result !== undefined).forEach(f => {
|
||||
if (path.basename(f.path) === filename) {
|
||||
fs.writeFile(filename, f.result.contents);
|
||||
}
|
||||
});
|
||||
}
|
||||
grab['description'] = ' filename.ts: writes out the specified file to disk';
|
||||
|
||||
export function extract(obj: IOLog, outputFolder: string) {
|
||||
var directorySeparator = "/";
|
||||
function directoryExists(path: string): boolean {
|
||||
return fs.existsSync(path) && fs.statSync(path).isDirectory();
|
||||
}
|
||||
function getDirectoryPath(path: string) {
|
||||
return path.substr(0, Math.max(getRootLength(path), path.lastIndexOf(directorySeparator)));
|
||||
}
|
||||
function getRootLength(path: string): number {
|
||||
if (path.charAt(0) === directorySeparator) {
|
||||
if (path.charAt(1) !== directorySeparator) return 1;
|
||||
var p1 = path.indexOf(directorySeparator, 2);
|
||||
if (p1 < 0) return 2;
|
||||
var p2 = path.indexOf(directorySeparator, p1 + 1);
|
||||
if (p2 < 0) return p1 + 1;
|
||||
return p2 + 1;
|
||||
}
|
||||
if (path.charAt(1) === ":") {
|
||||
if (path.charAt(2) === directorySeparator) return 3;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
function ensureDirectoriesExist(directoryPath: string) {
|
||||
if (directoryPath.length > getRootLength(directoryPath) && !directoryExists(directoryPath)) {
|
||||
var parentDirectory = getDirectoryPath(directoryPath);
|
||||
ensureDirectoriesExist(parentDirectory);
|
||||
console.log("creating directory: " + directoryPath);
|
||||
fs.mkdirSync(directoryPath);
|
||||
}
|
||||
}
|
||||
function normalizeSlashes(path: string): string {
|
||||
return path.replace(/\\/g, "/");
|
||||
}
|
||||
function transalatePath(outputFolder:string, path: string): string {
|
||||
return normalizeSlashes(outputFolder + directorySeparator + path.replace(":", ""));
|
||||
}
|
||||
function fileExists(path: string): boolean {
|
||||
return fs.existsSync(path);
|
||||
}
|
||||
obj.filesRead.forEach(f => {
|
||||
var filename = transalatePath(outputFolder, f.path);
|
||||
ensureDirectoriesExist(getDirectoryPath(filename));
|
||||
console.log("writing filename: " + filename);
|
||||
fs.writeFileSync(filename, f.result.contents);
|
||||
});
|
||||
|
||||
console.log("Command: tsc ");
|
||||
obj.arguments.forEach(a => {
|
||||
if (getRootLength(a) > 0) {
|
||||
console.log(transalatePath(outputFolder, a));
|
||||
}
|
||||
else {
|
||||
console.log(a);
|
||||
}
|
||||
console.log(" ");
|
||||
});
|
||||
}
|
||||
extract['description'] = ' outputFolder: extract all input files to <outputFolder>';
|
||||
}
|
||||
|
||||
var args = process.argv.slice(2);
|
||||
if (args.length < 2) {
|
||||
console.log('Usage: node ior.js path_to_file.json [command]');
|
||||
console.log('List of commands: ');
|
||||
Object.keys(Commands).forEach(k => console.log(' ' + k + Commands[k]['description']));
|
||||
} else {
|
||||
var cmd: Function = Commands[args[1]];
|
||||
if (cmd === undefined) {
|
||||
console.log('Unknown command ' + args[1]);
|
||||
} else {
|
||||
fs.readFile(args[0], 'utf-8', (err, data) => {
|
||||
if (err) throw err;
|
||||
var json = JSON.parse(data);
|
||||
cmd.apply(undefined, [json].concat(args.slice(2)));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -1,50 +0,0 @@
|
|||
var tslint = require("tslint");
|
||||
var fs = require("fs");
|
||||
var path = require("path");
|
||||
|
||||
function getLinterOptions() {
|
||||
return {
|
||||
formatter: "prose",
|
||||
formattersDirectory: undefined,
|
||||
rulesDirectory: "built/local/tslint"
|
||||
};
|
||||
}
|
||||
function getLinterConfiguration() {
|
||||
return tslint.Configuration.loadConfigurationFromPath(path.join(__dirname, "../tslint.json"));
|
||||
}
|
||||
|
||||
function lintFileContents(options, configuration, path, contents) {
|
||||
var ll = new tslint.Linter(options);
|
||||
ll.lint(path, contents, configuration);
|
||||
return ll.getResult();
|
||||
}
|
||||
|
||||
function lintFileAsync(options, configuration, path, cb) {
|
||||
fs.readFile(path, "utf8", function (err, contents) {
|
||||
if (err) {
|
||||
return cb(err);
|
||||
}
|
||||
var result = lintFileContents(options, configuration, path, contents);
|
||||
cb(undefined, result);
|
||||
});
|
||||
}
|
||||
|
||||
process.on("message", function (data) {
|
||||
switch (data.kind) {
|
||||
case "file":
|
||||
var target = data.name;
|
||||
var lintOptions = getLinterOptions();
|
||||
var lintConfiguration = getLinterConfiguration();
|
||||
lintFileAsync(lintOptions, lintConfiguration, target, function (err, result) {
|
||||
if (err) {
|
||||
process.send({ kind: "error", error: err.toString() });
|
||||
return;
|
||||
}
|
||||
process.send({ kind: "result", failures: result.failureCount, output: result.output });
|
||||
});
|
||||
break;
|
||||
case "close":
|
||||
process.exit(0);
|
||||
break;
|
||||
}
|
||||
});
|
8
scripts/types/ambient.d.ts
vendored
8
scripts/types/ambient.d.ts
vendored
|
@ -1,13 +1,5 @@
|
|||
import { TaskFunction } from "gulp";
|
||||
|
||||
declare module "gulp-clone" {
|
||||
function Clone(): NodeJS.ReadWriteStream;
|
||||
namespace Clone {
|
||||
export function sink() : NodeJS.ReadWriteStream & {tap: () => NodeJS.ReadWriteStream};
|
||||
}
|
||||
export = Clone;
|
||||
}
|
||||
|
||||
declare module "gulp-insert" {
|
||||
export function append(text: string | Buffer): NodeJS.ReadWriteStream;
|
||||
export function prepend(text: string | Buffer): NodeJS.ReadWriteStream;
|
||||
|
|
|
@ -1,21 +0,0 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE
|
2856
scripts/types/mocha/index.d.ts
vendored
2856
scripts/types/mocha/index.d.ts
vendored
File diff suppressed because it is too large
Load diff
109
scripts/types/mocha/lib/interfaces/common.d.ts
vendored
109
scripts/types/mocha/lib/interfaces/common.d.ts
vendored
|
@ -1,109 +0,0 @@
|
|||
import Mocha = require("../../");
|
||||
|
||||
export = common;
|
||||
|
||||
declare function common(suites: Mocha.Suite[], context: Mocha.MochaGlobals, mocha: Mocha): common.CommonFunctions;
|
||||
|
||||
declare namespace common {
|
||||
export interface CommonFunctions {
|
||||
/**
|
||||
* This is only present if flag --delay is passed into Mocha. It triggers
|
||||
* root suite execution.
|
||||
*/
|
||||
runWithSuite(suite: Mocha.Suite): () => void;
|
||||
|
||||
/**
|
||||
* Execute before running tests.
|
||||
*/
|
||||
before(fn?: Mocha.Func | Mocha.AsyncFunc): void;
|
||||
|
||||
/**
|
||||
* Execute before running tests.
|
||||
*/
|
||||
before(name: string, fn?: Mocha.Func | Mocha.AsyncFunc): void;
|
||||
|
||||
/**
|
||||
* Execute after running tests.
|
||||
*/
|
||||
after(fn?: Mocha.Func | Mocha.AsyncFunc): void;
|
||||
|
||||
/**
|
||||
* Execute after running tests.
|
||||
*/
|
||||
after(name: string, fn?: Mocha.Func | Mocha.AsyncFunc): void;
|
||||
|
||||
/**
|
||||
* Execute before each test case.
|
||||
*/
|
||||
beforeEach(fn?: Mocha.Func | Mocha.AsyncFunc): void;
|
||||
|
||||
/**
|
||||
* Execute before each test case.
|
||||
*/
|
||||
beforeEach(name: string, fn?: Mocha.Func | Mocha.AsyncFunc): void;
|
||||
|
||||
/**
|
||||
* Execute after each test case.
|
||||
*/
|
||||
afterEach(fn?: Mocha.Func | Mocha.AsyncFunc): void;
|
||||
|
||||
/**
|
||||
* Execute after each test case.
|
||||
*/
|
||||
afterEach(name: string, fn?: Mocha.Func | Mocha.AsyncFunc): void;
|
||||
|
||||
suite: SuiteFunctions;
|
||||
test: TestFunctions;
|
||||
}
|
||||
|
||||
export interface CreateOptions {
|
||||
/** Title of suite */
|
||||
title: string;
|
||||
|
||||
/** Suite function */
|
||||
fn?: (this: Mocha.Suite) => void;
|
||||
|
||||
/** Is suite pending? */
|
||||
pending?: boolean;
|
||||
|
||||
/** Filepath where this Suite resides */
|
||||
file?: string;
|
||||
|
||||
/** Is suite exclusive? */
|
||||
isOnly?: boolean;
|
||||
}
|
||||
|
||||
export interface SuiteFunctions {
|
||||
/**
|
||||
* Create an exclusive Suite; convenience function
|
||||
*/
|
||||
only(opts: CreateOptions): Mocha.Suite;
|
||||
|
||||
/**
|
||||
* Create a Suite, but skip it; convenience function
|
||||
*/
|
||||
skip(opts: CreateOptions): Mocha.Suite;
|
||||
|
||||
/**
|
||||
* Creates a suite.
|
||||
*/
|
||||
create(opts: CreateOptions): Mocha.Suite;
|
||||
}
|
||||
|
||||
export interface TestFunctions {
|
||||
/**
|
||||
* Exclusive test-case.
|
||||
*/
|
||||
only(mocha: Mocha, test: Mocha.Test): Mocha.Test;
|
||||
|
||||
/**
|
||||
* Pending test case.
|
||||
*/
|
||||
skip(title: string): void;
|
||||
|
||||
/**
|
||||
* Number of retry attempts
|
||||
*/
|
||||
retries(n: number): void;
|
||||
}
|
||||
}
|
17
scripts/types/mocha/lib/ms.d.ts
vendored
17
scripts/types/mocha/lib/ms.d.ts
vendored
|
@ -1,17 +0,0 @@
|
|||
export = milliseconds;
|
||||
|
||||
/**
|
||||
* Parse the given `str` and return milliseconds.
|
||||
*
|
||||
* @see {@link https://mochajs.org/api/module-milliseconds.html}
|
||||
* @see {@link https://mochajs.org/api/module-milliseconds.html#~parse}
|
||||
*/
|
||||
declare function milliseconds(val: string): number;
|
||||
|
||||
/**
|
||||
* Format for `ms`.
|
||||
*
|
||||
* @see {@link https://mochajs.org/api/module-milliseconds.html}
|
||||
* @see {@link https://mochajs.org/api/module-milliseconds.html#~format}
|
||||
*/
|
||||
declare function milliseconds(val: number): string;
|
|
@ -1,5 +0,0 @@
|
|||
{
|
||||
"name": "@types/mocha",
|
||||
"private": true,
|
||||
"version": "5.2.1"
|
||||
}
|
|
@ -47,23 +47,6 @@ interface XMLHttpRequest {
|
|||
/* tslint:enable:no-var-keyword prefer-const */
|
||||
|
||||
namespace Utils {
|
||||
// Setup some globals based on the current environment
|
||||
export const enum ExecutionEnvironment {
|
||||
Node,
|
||||
Browser,
|
||||
}
|
||||
|
||||
export function getExecutionEnvironment() {
|
||||
if (typeof window !== "undefined") {
|
||||
return ExecutionEnvironment.Browser;
|
||||
}
|
||||
else {
|
||||
return ExecutionEnvironment.Node;
|
||||
}
|
||||
}
|
||||
|
||||
export let currentExecutionEnvironment = getExecutionEnvironment();
|
||||
|
||||
export function encodeString(s: string): string {
|
||||
return ts.sys.bufferFrom!(s).toString("utf8");
|
||||
}
|
||||
|
@ -74,23 +57,12 @@ namespace Utils {
|
|||
}
|
||||
|
||||
export function evalFile(fileContents: string, fileName: string, nodeContext?: any) {
|
||||
const environment = getExecutionEnvironment();
|
||||
switch (environment) {
|
||||
case ExecutionEnvironment.Browser:
|
||||
// tslint:disable-next-line:no-eval
|
||||
eval(fileContents);
|
||||
break;
|
||||
case ExecutionEnvironment.Node:
|
||||
const vm = require("vm");
|
||||
if (nodeContext) {
|
||||
vm.runInNewContext(fileContents, nodeContext, fileName);
|
||||
}
|
||||
else {
|
||||
vm.runInThisContext(fileContents, fileName);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw new Error("Unknown context");
|
||||
const vm = require("vm");
|
||||
if (nodeContext) {
|
||||
vm.runInNewContext(fileContents, nodeContext, fileName);
|
||||
}
|
||||
else {
|
||||
vm.runInThisContext(fileContents, fileName);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -624,344 +596,11 @@ namespace Harness {
|
|||
};
|
||||
}
|
||||
|
||||
interface URL {
|
||||
hash: string;
|
||||
host: string;
|
||||
hostname: string;
|
||||
href: string;
|
||||
password: string;
|
||||
pathname: string;
|
||||
port: string;
|
||||
protocol: string;
|
||||
search: string;
|
||||
username: string;
|
||||
toString(): string;
|
||||
}
|
||||
|
||||
declare var URL: {
|
||||
prototype: URL;
|
||||
new(url: string, base?: string | URL): URL;
|
||||
};
|
||||
|
||||
function createBrowserIO(): IO {
|
||||
const serverRoot = new URL("http://localhost:8888/");
|
||||
|
||||
class HttpHeaders extends collections.SortedMap<string, string | string[]> {
|
||||
constructor(template?: Record<string, string | string[]>) {
|
||||
super(ts.compareStringsCaseInsensitive);
|
||||
if (template) {
|
||||
for (const key in template) {
|
||||
if (ts.hasProperty(template, key)) {
|
||||
this.set(key, template[key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static combine(left: HttpHeaders | undefined, right: HttpHeaders | undefined): HttpHeaders | undefined {
|
||||
if (!left && !right) return undefined;
|
||||
const headers = new HttpHeaders();
|
||||
if (left) left.forEach((value, key) => { headers.set(key, value); });
|
||||
if (right) right.forEach((value, key) => { headers.set(key, value); });
|
||||
return headers;
|
||||
}
|
||||
|
||||
public has(key: string) {
|
||||
return super.has(key.toLowerCase());
|
||||
}
|
||||
|
||||
public get(key: string) {
|
||||
return super.get(key.toLowerCase());
|
||||
}
|
||||
|
||||
public set(key: string, value: string | string[]) {
|
||||
return super.set(key.toLowerCase(), value);
|
||||
}
|
||||
|
||||
public delete(key: string) {
|
||||
return super.delete(key.toLowerCase());
|
||||
}
|
||||
|
||||
public writeRequestHeaders(xhr: XMLHttpRequest) {
|
||||
this.forEach((values, key) => {
|
||||
if (key === "access-control-allow-origin" || key === "content-length") return;
|
||||
const value = Array.isArray(values) ? values.join(",") : values;
|
||||
if (key === "content-type") {
|
||||
xhr.overrideMimeType(value);
|
||||
return;
|
||||
}
|
||||
xhr.setRequestHeader(key, value);
|
||||
});
|
||||
}
|
||||
|
||||
public static readResponseHeaders(xhr: XMLHttpRequest): HttpHeaders {
|
||||
const allHeaders = xhr.getAllResponseHeaders();
|
||||
const headers = new HttpHeaders();
|
||||
for (const header of allHeaders.split(/\r\n/g)) {
|
||||
const colonIndex = header.indexOf(":");
|
||||
if (colonIndex >= 0) {
|
||||
const key = header.slice(0, colonIndex).trim();
|
||||
const value = header.slice(colonIndex + 1).trim();
|
||||
const values = value.split(",");
|
||||
headers.set(key, values.length > 1 ? values : value);
|
||||
}
|
||||
}
|
||||
return headers;
|
||||
}
|
||||
}
|
||||
|
||||
class HttpContent {
|
||||
public headers: HttpHeaders;
|
||||
public content: string;
|
||||
|
||||
constructor(headers: HttpHeaders | Record<string, string | string[]>, content: string) {
|
||||
this.headers = headers instanceof HttpHeaders ? headers : new HttpHeaders(headers);
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public static fromMediaType(mediaType: string, content: string) {
|
||||
return new HttpContent({ "Content-Type": mediaType }, content);
|
||||
}
|
||||
|
||||
public static text(content: string) {
|
||||
return HttpContent.fromMediaType("text/plain", content);
|
||||
}
|
||||
|
||||
public static json(content: object) {
|
||||
return HttpContent.fromMediaType("application/json", JSON.stringify(content));
|
||||
}
|
||||
|
||||
public static readResponseContent(xhr: XMLHttpRequest) {
|
||||
if (typeof xhr.responseText === "string") {
|
||||
return new HttpContent({
|
||||
"Content-Type": xhr.getResponseHeader("Content-Type") || undefined!, // TODO: GH#18217
|
||||
"Content-Length": xhr.getResponseHeader("Content-Length") || undefined!, // TODO: GH#18217
|
||||
}, xhr.responseText);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
public writeRequestHeaders(xhr: XMLHttpRequest) {
|
||||
this.headers.writeRequestHeaders(xhr);
|
||||
}
|
||||
}
|
||||
|
||||
class HttpRequestMessage {
|
||||
public method: string;
|
||||
public url: URL;
|
||||
public headers: HttpHeaders;
|
||||
public content?: HttpContent;
|
||||
|
||||
constructor(method: string, url: string | URL, headers?: HttpHeaders | Record<string, string | string[]>, content?: HttpContent) {
|
||||
this.method = method;
|
||||
this.url = typeof url === "string" ? new URL(url) : url;
|
||||
this.headers = headers instanceof HttpHeaders ? headers : new HttpHeaders(headers);
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public static options(url: string | URL) {
|
||||
return new HttpRequestMessage("OPTIONS", url);
|
||||
}
|
||||
|
||||
public static head(url: string | URL) {
|
||||
return new HttpRequestMessage("HEAD", url);
|
||||
}
|
||||
|
||||
public static get(url: string | URL) {
|
||||
return new HttpRequestMessage("GET", url);
|
||||
}
|
||||
|
||||
public static delete(url: string | URL) {
|
||||
return new HttpRequestMessage("DELETE", url);
|
||||
}
|
||||
|
||||
public static put(url: string | URL, content: HttpContent) {
|
||||
return new HttpRequestMessage("PUT", url, /*headers*/ undefined, content);
|
||||
}
|
||||
|
||||
public static post(url: string | URL, content: HttpContent) {
|
||||
return new HttpRequestMessage("POST", url, /*headers*/ undefined, content);
|
||||
}
|
||||
|
||||
public writeRequestHeaders(xhr: XMLHttpRequest) {
|
||||
this.headers.writeRequestHeaders(xhr);
|
||||
if (this.content) {
|
||||
this.content.writeRequestHeaders(xhr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class HttpResponseMessage {
|
||||
public statusCode: number;
|
||||
public statusMessage: string;
|
||||
public headers: HttpHeaders;
|
||||
public content?: HttpContent;
|
||||
|
||||
constructor(statusCode: number, statusMessage: string, headers?: HttpHeaders | Record<string, string | string[]>, content?: HttpContent) {
|
||||
this.statusCode = statusCode;
|
||||
this.statusMessage = statusMessage;
|
||||
this.headers = headers instanceof HttpHeaders ? headers : new HttpHeaders(headers);
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public static notFound(): HttpResponseMessage {
|
||||
return new HttpResponseMessage(404, "Not Found");
|
||||
}
|
||||
|
||||
public static hasSuccessStatusCode(response: HttpResponseMessage) {
|
||||
return response.statusCode === 304 || (response.statusCode >= 200 && response.statusCode < 300);
|
||||
}
|
||||
|
||||
public static readResponseMessage(xhr: XMLHttpRequest) {
|
||||
return new HttpResponseMessage(
|
||||
xhr.status,
|
||||
xhr.statusText,
|
||||
HttpHeaders.readResponseHeaders(xhr),
|
||||
HttpContent.readResponseContent(xhr));
|
||||
}
|
||||
}
|
||||
|
||||
function send(request: HttpRequestMessage): HttpResponseMessage {
|
||||
const xhr = new XMLHttpRequest();
|
||||
try {
|
||||
xhr.open(request.method, request.url.toString(), /*async*/ false);
|
||||
request.writeRequestHeaders(xhr);
|
||||
xhr.setRequestHeader("Access-Control-Allow-Origin", "*");
|
||||
xhr.send(request.content && request.content.content);
|
||||
while (xhr.readyState !== 4); // block until ready
|
||||
return HttpResponseMessage.readResponseMessage(xhr);
|
||||
}
|
||||
catch (e) {
|
||||
return HttpResponseMessage.notFound();
|
||||
}
|
||||
}
|
||||
|
||||
let caseSensitivity: "CI" | "CS" | undefined;
|
||||
|
||||
function useCaseSensitiveFileNames() {
|
||||
if (!caseSensitivity) {
|
||||
const response = send(HttpRequestMessage.options(new URL("*", serverRoot)));
|
||||
const xCaseSensitivity = response.headers.get("X-Case-Sensitivity");
|
||||
caseSensitivity = xCaseSensitivity === "CS" ? "CS" : "CI";
|
||||
}
|
||||
return caseSensitivity === "CS";
|
||||
}
|
||||
|
||||
function resolvePath(path: string) {
|
||||
const response = send(HttpRequestMessage.post(new URL("/api/resolve", serverRoot), HttpContent.text(path)));
|
||||
return HttpResponseMessage.hasSuccessStatusCode(response) && response.content ? response.content.content : undefined;
|
||||
}
|
||||
|
||||
function getFileSize(path: string): number {
|
||||
const response = send(HttpRequestMessage.head(new URL(path, serverRoot)));
|
||||
return HttpResponseMessage.hasSuccessStatusCode(response) ? +response.headers.get("Content-Length")!.toString() : 0;
|
||||
}
|
||||
|
||||
function readFile(path: string): string | undefined {
|
||||
const response = send(HttpRequestMessage.get(new URL(path, serverRoot)));
|
||||
return HttpResponseMessage.hasSuccessStatusCode(response) && response.content ? response.content.content : undefined;
|
||||
}
|
||||
|
||||
function writeFile(path: string, contents: string) {
|
||||
send(HttpRequestMessage.put(new URL(path, serverRoot), HttpContent.text(contents)));
|
||||
}
|
||||
|
||||
function fileExists(path: string): boolean {
|
||||
const response = send(HttpRequestMessage.head(new URL(path, serverRoot)));
|
||||
return HttpResponseMessage.hasSuccessStatusCode(response);
|
||||
}
|
||||
|
||||
function directoryExists(path: string): boolean {
|
||||
const response = send(HttpRequestMessage.post(new URL("/api/directoryExists", serverRoot), HttpContent.text(path)));
|
||||
return hasJsonContent(response) && JSON.parse(response.content.content) as boolean;
|
||||
}
|
||||
|
||||
function deleteFile(path: string) {
|
||||
send(HttpRequestMessage.delete(new URL(path, serverRoot)));
|
||||
}
|
||||
|
||||
function directoryName(path: string) {
|
||||
const url = new URL(path, serverRoot);
|
||||
return ts.getDirectoryPath(ts.normalizeSlashes(url.pathname || "/"));
|
||||
}
|
||||
|
||||
function enumerateTestFiles(runner: RunnerBase): (string | FileBasedTest)[] {
|
||||
const response = send(HttpRequestMessage.post(new URL("/api/enumerateTestFiles", serverRoot), HttpContent.text(runner.kind())));
|
||||
return hasJsonContent(response) ? JSON.parse(response.content.content) : [];
|
||||
}
|
||||
|
||||
function listFiles(dirname: string, spec?: RegExp, options?: { recursive?: boolean }): string[] {
|
||||
if (spec || (options && !options.recursive)) {
|
||||
let results = IO.listFiles(dirname);
|
||||
if (spec) {
|
||||
results = results.filter(file => spec.test(file));
|
||||
}
|
||||
if (options && !options.recursive) {
|
||||
results = results.filter(file => ts.getDirectoryPath(ts.normalizeSlashes(file)) === dirname);
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
const response = send(HttpRequestMessage.post(new URL("/api/listFiles", serverRoot), HttpContent.text(dirname)));
|
||||
return hasJsonContent(response) ? JSON.parse(response.content.content) : [];
|
||||
}
|
||||
|
||||
function readDirectory(path: string, extension?: string[], exclude?: string[], include?: string[], depth?: number) {
|
||||
return ts.matchFiles(path, extension, exclude, include, useCaseSensitiveFileNames(), "", depth, getAccessibleFileSystemEntries);
|
||||
}
|
||||
|
||||
function getAccessibleFileSystemEntries(dirname: string): ts.FileSystemEntries {
|
||||
const response = send(HttpRequestMessage.post(new URL("/api/getAccessibleFileSystemEntries", serverRoot), HttpContent.text(dirname)));
|
||||
return hasJsonContent(response) ? JSON.parse(response.content.content) : { files: [], directories: [] };
|
||||
}
|
||||
|
||||
function hasJsonContent(response: HttpResponseMessage): response is HttpResponseMessage & { content: HttpContent } {
|
||||
return HttpResponseMessage.hasSuccessStatusCode(response)
|
||||
&& !!response.content
|
||||
&& /^application\/json(;.*)$/.test("" + response.content.headers.get("Content-Type"));
|
||||
}
|
||||
|
||||
return {
|
||||
newLine: () => harnessNewLine,
|
||||
getCurrentDirectory: () => "",
|
||||
useCaseSensitiveFileNames,
|
||||
resolvePath,
|
||||
getFileSize,
|
||||
readFile,
|
||||
writeFile,
|
||||
directoryName: Utils.memoize(directoryName, path => path),
|
||||
getDirectories: () => [],
|
||||
createDirectory: () => {}, // tslint:disable-line no-empty
|
||||
fileExists,
|
||||
directoryExists,
|
||||
deleteFile,
|
||||
listFiles: Utils.memoize(listFiles, (path, spec, options) => `${path}|${spec}|${options ? options.recursive === true : true}`),
|
||||
enumerateTestFiles: Utils.memoize(enumerateTestFiles, runner => runner.kind()),
|
||||
log: s => console.log(s),
|
||||
args: () => [],
|
||||
getExecutingFilePath: () => "",
|
||||
exit: () => {}, // tslint:disable-line no-empty
|
||||
readDirectory,
|
||||
getAccessibleFileSystemEntries,
|
||||
getWorkspaceRoot: () => "/"
|
||||
};
|
||||
}
|
||||
|
||||
export function mockHash(s: string): string {
|
||||
return `hash-${s}`;
|
||||
}
|
||||
|
||||
const environment = Utils.getExecutionEnvironment();
|
||||
switch (environment) {
|
||||
case Utils.ExecutionEnvironment.Node:
|
||||
IO = createNodeIO();
|
||||
break;
|
||||
case Utils.ExecutionEnvironment.Browser:
|
||||
IO = createBrowserIO();
|
||||
break;
|
||||
default:
|
||||
throw new Error(`Unknown value '${environment}' for ExecutionEnvironment.`);
|
||||
}
|
||||
IO = createNodeIO();
|
||||
}
|
||||
|
||||
if (Harness.IO.tryEnableSourceMapsForHost && /^development$/i.test(Harness.IO.getEnvironmentVariable!("NODE_ENV"))) {
|
||||
|
@ -970,10 +609,8 @@ if (Harness.IO.tryEnableSourceMapsForHost && /^development$/i.test(Harness.IO.ge
|
|||
|
||||
namespace Harness {
|
||||
export const libFolder = "built/local/";
|
||||
const tcServicesFileName = ts.combinePaths(libFolder, Utils.getExecutionEnvironment() === Utils.ExecutionEnvironment.Browser ? "typescriptServicesInBrowserTest.js" : "typescriptServices.js");
|
||||
export const tcServicesFile = IO.readFile(tcServicesFileName) + (Utils.getExecutionEnvironment() !== Utils.ExecutionEnvironment.Browser
|
||||
? IO.newLine() + `//# sourceURL=${IO.resolvePath(tcServicesFileName)}`
|
||||
: "");
|
||||
const tcServicesFileName = ts.combinePaths(libFolder, "typescriptServices.js");
|
||||
export const tcServicesFile = IO.readFile(tcServicesFileName) + IO.newLine() + `//# sourceURL=${IO.resolvePath(tcServicesFileName)}`;
|
||||
|
||||
export type SourceMapEmitterCallback = (
|
||||
emittedFile: string,
|
||||
|
|
|
@ -538,25 +538,23 @@ namespace Harness.Parallel.Host {
|
|||
|
||||
let xunitReporter: import("mocha").reporters.XUnit | undefined;
|
||||
let failedTestReporter: import("../../../scripts/failed-tests") | undefined;
|
||||
if (Utils.getExecutionEnvironment() !== Utils.ExecutionEnvironment.Browser) {
|
||||
if (process.env.CI === "true") {
|
||||
xunitReporter = new Mocha.reporters.XUnit(replayRunner, {
|
||||
reporterOptions: {
|
||||
suiteName: "Tests",
|
||||
output: "./TEST-results.xml"
|
||||
}
|
||||
});
|
||||
patchStats(xunitReporter.stats);
|
||||
xunitReporter.write(`<?xml version="1.0" encoding="UTF-8"?>\n`);
|
||||
}
|
||||
else {
|
||||
failedTestReporter = new FailedTestReporter(replayRunner, {
|
||||
reporterOptions: {
|
||||
file: path.resolve(".failed-tests"),
|
||||
keepFailed
|
||||
}
|
||||
});
|
||||
}
|
||||
if (process.env.CI === "true") {
|
||||
xunitReporter = new Mocha.reporters.XUnit(replayRunner, {
|
||||
reporterOptions: {
|
||||
suiteName: "Tests",
|
||||
output: "./TEST-results.xml"
|
||||
}
|
||||
});
|
||||
patchStats(xunitReporter.stats);
|
||||
xunitReporter.write(`<?xml version="1.0" encoding="UTF-8"?>\n`);
|
||||
}
|
||||
else {
|
||||
failedTestReporter = new FailedTestReporter(replayRunner, {
|
||||
reporterOptions: {
|
||||
file: path.resolve(".failed-tests"),
|
||||
keepFailed
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
const savedUseColors = Base.useColors;
|
||||
|
|
|
@ -182,10 +182,7 @@ function handleTestConfig() {
|
|||
runners.push(new CompilerBaselineRunner(CompilerTestType.Conformance));
|
||||
runners.push(new CompilerBaselineRunner(CompilerTestType.Regressions));
|
||||
|
||||
// TODO: project tests don"t work in the browser yet
|
||||
if (Utils.getExecutionEnvironment() !== Utils.ExecutionEnvironment.Browser) {
|
||||
runners.push(new project.ProjectRunner());
|
||||
}
|
||||
runners.push(new project.ProjectRunner());
|
||||
|
||||
// language services
|
||||
runners.push(new FourSlashRunner(FourSlash.FourSlashTestType.Native));
|
||||
|
@ -195,7 +192,7 @@ function handleTestConfig() {
|
|||
// runners.push(new GeneratedFourslashRunner());
|
||||
|
||||
// CRON-only tests
|
||||
if (Utils.getExecutionEnvironment() !== Utils.ExecutionEnvironment.Browser && process.env.TRAVIS_EVENT_TYPE === "cron") {
|
||||
if (process.env.TRAVIS_EVENT_TYPE === "cron") {
|
||||
runners.push(new UserCodeRunner());
|
||||
}
|
||||
}
|
||||
|
@ -229,13 +226,11 @@ function beginTests() {
|
|||
let isWorker: boolean;
|
||||
function startTestEnvironment() {
|
||||
isWorker = handleTestConfig();
|
||||
if (Utils.getExecutionEnvironment() !== Utils.ExecutionEnvironment.Browser) {
|
||||
if (isWorker) {
|
||||
return Harness.Parallel.Worker.start();
|
||||
}
|
||||
else if (taskConfigsFolder && workerCount && workerCount > 1) {
|
||||
return Harness.Parallel.Host.start();
|
||||
}
|
||||
if (isWorker) {
|
||||
return Harness.Parallel.Worker.start();
|
||||
}
|
||||
else if (taskConfigsFolder && workerCount && workerCount > 1) {
|
||||
return Harness.Parallel.Host.start();
|
||||
}
|
||||
beginTests();
|
||||
}
|
||||
|
|
104
tests/perfsys.ts
104
tests/perfsys.ts
|
@ -1,104 +0,0 @@
|
|||
/// <reference path="..\src\compiler\sys.ts"/>
|
||||
/// <reference path="..\src\compiler\types.ts"/>
|
||||
|
||||
namespace perftest {
|
||||
interface IOLog {
|
||||
resolvePath: ts.Map<string>;
|
||||
fileNames: string[];
|
||||
}
|
||||
|
||||
export interface IO {
|
||||
getOut(): string;
|
||||
}
|
||||
|
||||
export const readFile = ts.sys.readFile;
|
||||
const writeFile = ts.sys.writeFile;
|
||||
export const write = ts.sys.write;
|
||||
const resolvePath = ts.sys.resolvePath;
|
||||
export const getExecutingFilePath = ts.sys.getExecutingFilePath;
|
||||
export const getCurrentDirectory = ts.sys.getCurrentDirectory;
|
||||
// const exit = ts.sys.exit;
|
||||
|
||||
const args = ts.sys.args;
|
||||
|
||||
// augment sys so first ts.executeCommandLine call will be finish silently
|
||||
ts.sys.write = (s: string) => { };
|
||||
ts.sys.exit = (code: number) => { };
|
||||
ts.sys.args = [];
|
||||
|
||||
export function restoreSys() {
|
||||
ts.sys.args = args;
|
||||
ts.sys.write = write;
|
||||
}
|
||||
|
||||
export function hasLogIOFlag() {
|
||||
return args.length > 2 && args[0] === "--logio";
|
||||
}
|
||||
|
||||
export function getArgsWithoutLogIOFlag() {
|
||||
return args.slice(2);
|
||||
}
|
||||
|
||||
export function getArgsWithoutIOLogFile() {
|
||||
return args.slice(1);
|
||||
}
|
||||
|
||||
const resolvePathLog: ts.Map<string> = {};
|
||||
|
||||
export function interceptIO() {
|
||||
ts.sys.resolvePath = (s) => {
|
||||
const result = resolvePath(s);
|
||||
resolvePathLog[s] = result;
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
export function writeIOLog(fileNames: string[]) {
|
||||
const path = args[1];
|
||||
const log: IOLog = {
|
||||
fileNames: fileNames,
|
||||
resolvePath: resolvePathLog
|
||||
};
|
||||
|
||||
writeFile(path, JSON.stringify(log));
|
||||
}
|
||||
|
||||
export function prepare(): IO {
|
||||
const log = <IOLog>JSON.parse(readFile(args[0]));
|
||||
|
||||
const files: ts.Map<string> = {};
|
||||
log.fileNames.forEach(f => { files[f] = readFile(f); });
|
||||
|
||||
ts.sys.createDirectory = (s: string) => { };
|
||||
ts.sys.directoryExists = (s: string) => true;
|
||||
ts.sys.fileExists = (s: string) => true;
|
||||
|
||||
const currentDirectory = ts.sys.getCurrentDirectory();
|
||||
ts.sys.getCurrentDirectory = () => currentDirectory;
|
||||
|
||||
const executingFilePath = ts.sys.getExecutingFilePath();
|
||||
ts.sys.getExecutingFilePath = () => executingFilePath;
|
||||
|
||||
ts.sys.readFile = (s: string) => {
|
||||
return files[s];
|
||||
};
|
||||
|
||||
ts.sys.resolvePath = (s: string) => {
|
||||
const path = log.resolvePath[s];
|
||||
if (!path) {
|
||||
throw new Error("Unexpected path '" + s + "'");
|
||||
}
|
||||
return path;
|
||||
};
|
||||
|
||||
ts.sys.writeFile = (path: string, data: string) => { };
|
||||
|
||||
let out = "";
|
||||
|
||||
ts.sys.write = (s: string) => { out += s; };
|
||||
|
||||
return {
|
||||
getOut: () => out,
|
||||
};
|
||||
}
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
/// <reference path="perfsys.ts"/>
|
||||
/// <reference path="..\src\compiler\tsc.ts"/>
|
||||
|
||||
// resolve all files used in this compilation
|
||||
if (perftest.hasLogIOFlag()) {
|
||||
perftest.interceptIO();
|
||||
|
||||
const compilerHost: ts.CompilerHost = {
|
||||
getSourceFile: (s, v) => {
|
||||
const content = perftest.readFile(s);
|
||||
return content !== undefined ? ts.createSourceFile(s, content, v) : undefined;
|
||||
},
|
||||
getDefaultLibFileName: () => ts.combinePaths(ts.getDirectoryPath(ts.normalizePath(perftest.getExecutingFilePath())), "lib.d.ts"),
|
||||
writeFile: (f: string, content: string) => { throw new Error("Unexpected operation: writeFile"); },
|
||||
getCurrentDirectory: () => perftest.getCurrentDirectory(),
|
||||
getCanonicalFileName: (f: string) => ts.sys.useCaseSensitiveFileNames ? f : f.toLowerCase(),
|
||||
useCaseSensitiveFileNames: () => ts.sys.useCaseSensitiveFileNames,
|
||||
getNewLine: () => ts.sys.newLine
|
||||
};
|
||||
|
||||
const commandLine = ts.parseCommandLine(perftest.getArgsWithoutLogIOFlag());
|
||||
const program = ts.createProgram(commandLine.fileNames, commandLine.options, compilerHost);
|
||||
const fileNames = program.getSourceFiles().map(f => f.fileName);
|
||||
perftest.writeIOLog(fileNames);
|
||||
}
|
||||
else {
|
||||
const io = perftest.prepare();
|
||||
ts.executeCommandLine(perftest.getArgsWithoutIOLogFile());
|
||||
perftest.write(io.getOut());
|
||||
}
|
|
@ -1,15 +0,0 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"target": "es2015",
|
||||
"module": "commonjs",
|
||||
"declaration": false,
|
||||
"removeComments": true,
|
||||
"noResolve": false,
|
||||
"stripInternal": false,
|
||||
"sourceMap": true,
|
||||
"outFile": "../built/local/perftsc.js"
|
||||
},
|
||||
"files": [
|
||||
"perftsc.ts"
|
||||
]
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
@echo off
|
||||
setlocal
|
||||
set LF=^
|
||||
|
||||
|
||||
for /f %%a in ('copy /Z "%~dpf0" nul') do set "CR=%%a"
|
||||
|
||||
setlocal enableDelayedExpansion
|
||||
echo "START"
|
||||
echo "asdf!CR!asdf"
|
||||
echo "AASDF!LF!ASDF"
|
||||
echo "END"
|
||||
findstr /S /R /M /C:"[^!CR!]!LF!" *
|
|
@ -1,42 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Mocha Tests</title>
|
||||
<link rel="stylesheet" href="../node_modules/mocha/mocha.css" />
|
||||
<link rel="icon" href="./webhost/favicon-32x32.png"/>
|
||||
<style>
|
||||
.btn {
|
||||
color: #ffffff;
|
||||
background: #3498db;
|
||||
border-radius: 30px;
|
||||
font-size: 50px;
|
||||
}
|
||||
.btn:hover { background: #50c7ff; }
|
||||
.btn:focus { background: #50c7ff; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id='setup'>
|
||||
<button id='runTestBtn' onclick='runTests()' type="button" class="btn">Run Tests</button>
|
||||
</div>
|
||||
<div id="mocha"></div>
|
||||
<script src="../node_modules/source-map-support/browser-source-map-support.js"></script>
|
||||
<script>sourceMapSupport.install();</script>
|
||||
<script src="../node_modules/mocha/mocha.js"></script>
|
||||
<script>mocha.setup({ ui: 'bdd', timeout: 0 })</script>
|
||||
<script src="../built/local/bundle.js"></script>
|
||||
|
||||
<script>
|
||||
// mocha is going to call this on every test result and make the results page unusable for a long
|
||||
// time after the tests are already done, doesn't seem necessary
|
||||
Mocha.utils.highlightTags = function() {}
|
||||
|
||||
function runTests() {
|
||||
mocha.checkLeaks();
|
||||
mocha.globals(['jQuery']);
|
||||
mocha.run();
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
File diff suppressed because it is too large
Load diff
|
@ -1,14 +0,0 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"target": "es2015",
|
||||
"module": "commonjs",
|
||||
"declaration": false,
|
||||
"removeComments": true,
|
||||
"noResolve": false,
|
||||
"stripInternal": false,
|
||||
"sourceMap": true
|
||||
},
|
||||
"files": [
|
||||
"webTestServer.ts"
|
||||
]
|
||||
}
|
Binary file not shown.
Before Width: | Height: | Size: 800 B |
|
@ -1,87 +0,0 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>WebTSC</title>
|
||||
<style>
|
||||
textarea {
|
||||
width: 95%;
|
||||
height: 120px;
|
||||
border: 3px solid #cccccc;
|
||||
padding: 5px;
|
||||
font-family: Tahoma, sans-serif;
|
||||
}
|
||||
|
||||
#container {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
#header {
|
||||
height:50px;
|
||||
text-align:center;
|
||||
}
|
||||
|
||||
#content {
|
||||
text-align:left;
|
||||
width:950px;
|
||||
min-height:300px;
|
||||
margin:0px auto;
|
||||
}
|
||||
|
||||
#main {
|
||||
float:left;
|
||||
width:700px;
|
||||
}
|
||||
|
||||
#side{
|
||||
float:right;
|
||||
width:250px;
|
||||
text-align:left;
|
||||
padding-top:75px;
|
||||
}
|
||||
</style>
|
||||
<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.9.1.js"></script>
|
||||
<script language="javascript" src="wscript.js"></script>
|
||||
<script language="javascript" src="webtsc.js"></script>
|
||||
<script>
|
||||
var idx = location.href.lastIndexOf("/");
|
||||
var currentDir = location.href.substring("file:///".length, idx);
|
||||
function appendText(str) {
|
||||
var outputPane = $("#outputPane");
|
||||
outputPane.val(outputPane.val() + str);
|
||||
}
|
||||
var stdOut = {
|
||||
WriteLine: function (str) {
|
||||
appendText(str + "\n");
|
||||
},
|
||||
Write: function (str) {
|
||||
appendText(str);
|
||||
},
|
||||
Close: function() {}
|
||||
};
|
||||
var compile = TypeScript.WebTsc.prepareCompiler(currentDir, stdOut, stdOut);
|
||||
function doCompile() {
|
||||
$("#outputPane").val("");
|
||||
var commandLine = $("#commandLine").val();
|
||||
compile(commandLine);
|
||||
appendText("===done===");
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="container">
|
||||
<div id="header">
|
||||
<h1>WebTSC</h1>
|
||||
</div>
|
||||
<div id="content">
|
||||
<div id="main">
|
||||
<h1>Command line:</h1>
|
||||
<textarea id="commandLine"></textarea>
|
||||
<h1>Output:</h1>
|
||||
<textarea id="outputPane"></textarea>
|
||||
</div>
|
||||
<div id="side">
|
||||
<button onclick="doCompile()">Compile</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
|
@ -1,104 +0,0 @@
|
|||
/// <reference path='..\..\src\compiler\tsc.ts'/>
|
||||
|
||||
namespace TypeScript.WebTsc {
|
||||
|
||||
declare var RealActiveXObject: { new (s: string): any };
|
||||
|
||||
function getWScriptSystem() {
|
||||
const fso = new RealActiveXObject("Scripting.FileSystemObject");
|
||||
|
||||
const fileStream = new ActiveXObject("ADODB.Stream");
|
||||
fileStream.Type = 2 /*text*/;
|
||||
|
||||
const args: string[] = [];
|
||||
for (let i = 0; i < WScript.Arguments.length; i++) {
|
||||
args[i] = WScript.Arguments.Item(i);
|
||||
}
|
||||
return {
|
||||
args: args,
|
||||
newLine: "\r\n",
|
||||
write(s: string): void {
|
||||
WScript.StdOut.Write(s);
|
||||
},
|
||||
writeErr(s: string): void {
|
||||
WScript.StdErr.Write(s);
|
||||
},
|
||||
readFile(fileName: string, encoding?: string): string {
|
||||
if (!fso.FileExists(fileName)) {
|
||||
return undefined;
|
||||
}
|
||||
fileStream.Open();
|
||||
try {
|
||||
if (encoding) {
|
||||
fileStream.Charset = encoding;
|
||||
fileStream.LoadFromFile(fileName);
|
||||
}
|
||||
else {
|
||||
// Load file and read the first two bytes into a string with no interpretation
|
||||
fileStream.Charset = "x-ansi";
|
||||
fileStream.LoadFromFile(fileName);
|
||||
const bom = fileStream.ReadText(2) || "";
|
||||
// Position must be at 0 before encoding can be changed
|
||||
fileStream.Position = 0;
|
||||
// [0xFF,0xFE] and [0xFE,0xFF] mean utf-16 (little or big endian), otherwise default to utf-8
|
||||
fileStream.Charset = bom.length >= 2 && (bom.charCodeAt(0) === 0xFF && bom.charCodeAt(1) === 0xFE || bom.charCodeAt(0) === 0xFE && bom.charCodeAt(1) === 0xFF) ? "unicode" : "utf-8";
|
||||
}
|
||||
// ReadText method always strips byte order mark from resulting string
|
||||
return fileStream.ReadText();
|
||||
}
|
||||
catch (e) {
|
||||
throw e;
|
||||
}
|
||||
finally {
|
||||
fileStream.Close();
|
||||
}
|
||||
},
|
||||
writeFile(fileName: string, data: string): boolean {
|
||||
const f = fso.CreateTextFile(fileName, true);
|
||||
f.Write(data);
|
||||
f.Close();
|
||||
return true;
|
||||
},
|
||||
resolvePath(path: string): string {
|
||||
return fso.GetAbsolutePathName(path);
|
||||
},
|
||||
fileExists(path: string): boolean {
|
||||
return fso.FileExists(path);
|
||||
},
|
||||
directoryExists(path: string) {
|
||||
return fso.FolderExists(path);
|
||||
},
|
||||
createDirectory(directoryName: string) {
|
||||
if (!this.directoryExists(directoryName)) {
|
||||
fso.CreateFolder(directoryName);
|
||||
}
|
||||
},
|
||||
getExecutingFilePath() {
|
||||
return WScript.ScriptFullName;
|
||||
},
|
||||
getCurrentDirectory() {
|
||||
return "";
|
||||
},
|
||||
getMemoryUsage() {
|
||||
return 0;
|
||||
},
|
||||
exit(exitCode?: number): void {
|
||||
WScript.Quit(exitCode);
|
||||
},
|
||||
useCaseSensitiveFileNames: false
|
||||
};
|
||||
}
|
||||
|
||||
export function prepareCompiler(currentDir: string, stdOut: ITextWriter, stdErr: ITextWriter) {
|
||||
const shell = new RealActiveXObject("WScript.Shell");
|
||||
shell.CurrentDirectory = currentDir;
|
||||
WScript.ScriptFullName = currentDir + "\\tc.js";
|
||||
WScript.StdOut = stdOut;
|
||||
WScript.StdErr = stdErr;
|
||||
sys = getWScriptSystem();
|
||||
|
||||
return (commandLine: string) => {
|
||||
ts.executeCommandLine(commandLine.split(" "));
|
||||
};
|
||||
}
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"target": "es2015",
|
||||
"module": "commonjs",
|
||||
"declaration": false,
|
||||
"removeComments": true,
|
||||
"noResolve": false,
|
||||
"stripInternal": false,
|
||||
"sourceMap": true
|
||||
},
|
||||
"files": [
|
||||
"webtsc.ts"
|
||||
]
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
var RealActiveXObject = ActiveXObject
|
||||
|
||||
var WScript;
|
||||
(function (WScript) {
|
||||
WScript.Arguments = [];
|
||||
WScript.Echo = function (str) { };
|
||||
WScript.StdErr = {
|
||||
Write: function() {}
|
||||
}
|
||||
WScript.StdOut = {
|
||||
Write: function () { },
|
||||
WriteLine: function () { }
|
||||
}
|
||||
|
||||
WScript.Quit = function (exitCode) { }
|
||||
})(WScript || (WScript = {}));
|
||||
|
||||
var ActiveXObject = (function () {
|
||||
function ActiveXObject(name) {
|
||||
}
|
||||
return ActiveXObject;
|
||||
})();
|
Loading…
Reference in a new issue