From e21fa4d166d15b03167f86eb8908bcc8f00b1050 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Tue, 19 Feb 2019 12:56:04 -0800 Subject: [PATCH 1/3] Some callbacks in watchUtilities werent being strictly checked due to the structural fallback --- src/compiler/watchUtilities.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/compiler/watchUtilities.ts b/src/compiler/watchUtilities.ts index 9bf242e07e82c..565af054b8feb 100644 --- a/src/compiler/watchUtilities.ts +++ b/src/compiler/watchUtilities.ts @@ -361,9 +361,9 @@ namespace ts { function getWatchFactoryWith(watchLogLevel: WatchLogLevel, log: (s: string) => void, getDetailWatchInfo: GetDetailWatchInfo | undefined, watchFile: (host: WatchFileHost, file: string, callback: FileWatcherCallback, watchPriority: PollingInterval) => FileWatcher, watchDirectory: (host: WatchDirectoryHost, directory: string, callback: DirectoryWatcherCallback, flags: WatchDirectoryFlags) => FileWatcher): WatchFactory { - const createFileWatcher: CreateFileWatcher = getCreateFileWatcher(watchLogLevel, watchFile); + const createFileWatcher: CreateFileWatcher = getCreateFileWatcher(watchLogLevel, watchFile); const createFilePathWatcher: CreateFileWatcher = watchLogLevel === WatchLogLevel.None ? watchFilePath : createFileWatcher; - const createDirectoryWatcher: CreateFileWatcher = getCreateFileWatcher(watchLogLevel, watchDirectory); + const createDirectoryWatcher: CreateFileWatcher = getCreateFileWatcher(watchLogLevel, watchDirectory); return { watchFile: (host, file, callback, pollingInterval, detailInfo1, detailInfo2) => createFileWatcher(host, file, callback, pollingInterval, /*passThrough*/ undefined, detailInfo1, detailInfo2, watchFile, log, "FileWatcher", getDetailWatchInfo), @@ -402,7 +402,7 @@ namespace ts { } } - function createFileWatcherWithLogging(host: H, file: string, cb: WatchCallback, flags: T, passThrough: V | undefined, detailInfo1: X | undefined, detailInfo2: Y | undefined, addWatch: AddWatch, log: (s: string) => void, watchCaption: string, getDetailWatchInfo: GetDetailWatchInfo | undefined): FileWatcher { + function createFileWatcherWithLogging(host: H, file: string, cb: WatchCallback, flags: T, passThrough: V | undefined, detailInfo1: X | undefined, detailInfo2: Y | undefined, addWatch: AddWatch, log: (s: string) => void, watchCaption: string, getDetailWatchInfo: GetDetailWatchInfo | undefined): FileWatcher { log(`${watchCaption}:: Added:: ${getWatchInfo(file, flags, detailInfo1, detailInfo2, getDetailWatchInfo)}`); const watcher = createFileWatcherWithTriggerLogging(host, file, cb, flags, passThrough, detailInfo1, detailInfo2, addWatch, log, watchCaption, getDetailWatchInfo); return { @@ -413,7 +413,7 @@ namespace ts { }; } - function createDirectoryWatcherWithLogging(host: H, file: string, cb: WatchCallback, flags: T, passThrough: V | undefined, detailInfo1: X | undefined, detailInfo2: Y | undefined, addWatch: AddWatch, log: (s: string) => void, watchCaption: string, getDetailWatchInfo: GetDetailWatchInfo | undefined): FileWatcher { + function createDirectoryWatcherWithLogging(host: H, file: string, cb: WatchCallback, flags: T, passThrough: V | undefined, detailInfo1: X | undefined, detailInfo2: Y | undefined, addWatch: AddWatch, log: (s: string) => void, watchCaption: string, getDetailWatchInfo: GetDetailWatchInfo | undefined): FileWatcher { const watchInfo = `${watchCaption}:: Added:: ${getWatchInfo(file, flags, detailInfo1, detailInfo2, getDetailWatchInfo)}`; log(watchInfo); const start = timestamp(); @@ -432,7 +432,7 @@ namespace ts { }; } - function createFileWatcherWithTriggerLogging(host: H, file: string, cb: WatchCallback, flags: T, passThrough: V | undefined, detailInfo1: X | undefined, detailInfo2: Y | undefined, addWatch: AddWatch, log: (s: string) => void, watchCaption: string, getDetailWatchInfo: GetDetailWatchInfo | undefined): FileWatcher { + function createFileWatcherWithTriggerLogging(host: H, file: string, cb: WatchCallback, flags: T, passThrough: V | undefined, detailInfo1: X | undefined, detailInfo2: Y | undefined, addWatch: AddWatch, log: (s: string) => void, watchCaption: string, getDetailWatchInfo: GetDetailWatchInfo | undefined): FileWatcher { return addWatch(host, file, (fileName, cbOptional) => { const triggerredInfo = `${watchCaption}:: Triggered with ${fileName} ${cbOptional !== undefined ? cbOptional : ""}:: ${getWatchInfo(file, flags, detailInfo1, detailInfo2, getDetailWatchInfo)}`; log(triggerredInfo); From 9c019612b1b5b974dfb1d246cc7457c6c43acb3c Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Tue, 19 Feb 2019 12:58:54 -0800 Subject: [PATCH 2/3] Add direct dependeny on ms since mocha removed its impl --- package.json | 2 ++ src/testRunner/parallel/host.ts | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index f891f99be5657..abf7aa17d350e 100644 --- a/package.json +++ b/package.json @@ -46,6 +46,7 @@ "@types/minimist": "latest", "@types/mkdirp": "latest", "@types/mocha": "latest", + "@types/ms": "latest", "@types/node": "8.5.5", "@types/q": "latest", "@types/source-map-support": "latest", @@ -74,6 +75,7 @@ "mkdirp": "latest", "mocha": "latest", "mocha-fivemat-progress-reporter": "latest", + "ms": "latest", "plugin-error": "latest", "pretty-hrtime": "^1.0.3", "prex": "^0.4.3", diff --git a/src/testRunner/parallel/host.ts b/src/testRunner/parallel/host.ts index 9adf9e7e850df..6a5b52496d0e5 100644 --- a/src/testRunner/parallel/host.ts +++ b/src/testRunner/parallel/host.ts @@ -7,7 +7,7 @@ namespace Harness.Parallel.Host { const Base = Mocha.reporters.Base; const color = Base.color; const cursor = Base.cursor; - const ms = require("mocha/lib/ms") as typeof import("mocha/lib/ms"); + const ms = require("ms") as typeof import("ms"); const readline = require("readline") as typeof import("readline"); const os = require("os") as typeof import("os"); const tty = require("tty") as typeof import("tty"); From 6d925c5e1891c6cc657fe3c7a6a41a705aaacc5a Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Tue, 19 Feb 2019 14:05:17 -0800 Subject: [PATCH 3/3] Manually init stats collection on base runner like mocha.run now does --- src/testRunner/parallel/host.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/testRunner/parallel/host.ts b/src/testRunner/parallel/host.ts index 6a5b52496d0e5..597013ed0d985 100644 --- a/src/testRunner/parallel/host.ts +++ b/src/testRunner/parallel/host.ts @@ -530,6 +530,8 @@ namespace Harness.Parallel.Host { const replayRunner = new Mocha.Runner(new Mocha.Suite(""), /*delay*/ false); replayRunner.started = true; + const createStatsCollector = require("mocha/lib/stats-collector"); + createStatsCollector(replayRunner); // manually init stats collector like mocha.run would const consoleReporter = new Base(replayRunner); patchStats(consoleReporter.stats);