Skip to content

Commit a8bf0f7

Browse files
author
Andy Hanson
committed
Merge branch 'master' into tsconfig_canonicalpath
2 parents ac460e3 + 1eb3082 commit a8bf0f7

File tree

896 files changed

+121945
-95310
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

896 files changed

+121945
-95310
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,5 @@ tests/cases/user/*/**/*.d.ts
7575
!tests/cases/user/discord.js/
7676
tests/baselines/reference/dt
7777
.failed-tests
78-
TEST-results.xml
78+
TEST-results.xml
79+
package-lock.json

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package-lock=false

Gulpfile.js

Lines changed: 57 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,9 @@ const baselineAccept = require("./scripts/build/baselineAccept");
2424
const cmdLineOptions = require("./scripts/build/options");
2525
const exec = require("./scripts/build/exec");
2626
const browserify = require("./scripts/build/browserify");
27-
const debounce = require("./scripts/build/debounce");
2827
const prepend = require("./scripts/build/prepend");
2928
const { removeSourceMaps } = require("./scripts/build/sourcemaps");
30-
const { CancelSource, CancelError } = require("./scripts/build/cancellation");
29+
const { CancellationTokenSource, CancelError, delay, Semaphore } = require("prex");
3130
const { libraryTargets, generateLibs } = require("./scripts/build/lib");
3231
const { runConsoleTests, cleanTestDirs, writeTestConfigFile, refBaseline, localBaseline, refRwcBaseline, localRwcBaseline } = require("./scripts/build/tests");
3332

@@ -534,57 +533,80 @@ gulp.task(
534533
["watch-diagnostics", "watch-lib"].concat(useCompilerDeps),
535534
() => project.watch(tsserverProject, { typescript: useCompiler }));
536535

537-
gulp.task(
538-
"watch-local",
539-
/*help*/ false,
540-
["watch-lib", "watch-tsc", "watch-services", "watch-server"]);
541-
542536
gulp.task(
543537
"watch-runner",
544538
/*help*/ false,
545539
useCompilerDeps,
546540
() => project.watch(testRunnerProject, { typescript: useCompiler }));
547541

548-
const watchPatterns = [
549-
runJs,
550-
typescriptDts,
551-
tsserverlibraryDts
552-
];
542+
gulp.task(
543+
"watch-local",
544+
"Watches for changes to projects in src/ (but does not execute tests).",
545+
["watch-lib", "watch-tsc", "watch-services", "watch-server", "watch-runner", "watch-lssl"]);
553546

554547
gulp.task(
555548
"watch",
556-
"Watches for changes to the build inputs for built/local/run.js, then executes runtests-parallel.",
549+
"Watches for changes to the build inputs for built/local/run.js, then runs tests.",
557550
["build-rules", "watch-runner", "watch-services", "watch-lssl"],
558551
() => {
559-
/** @type {CancelSource | undefined} */
560-
let runTestsSource;
552+
const sem = new Semaphore(1);
561553

562-
const fn = debounce(() => {
563-
runTests().catch(error => {
564-
if (error instanceof CancelError) {
565-
log.warn("Operation was canceled");
566-
}
567-
else {
568-
log.error(error);
569-
}
570-
});
571-
}, /*timeout*/ 100, { max: 500 });
572-
573-
gulp.watch(watchPatterns, () => project.wait().then(fn));
554+
gulp.watch([runJs, typescriptDts, tsserverlibraryDts], () => {
555+
runTests();
556+
});
574557

575558
// NOTE: gulp.watch is far too slow when watching tests/cases/**/* as it first enumerates *every* file
576559
const testFilePattern = /(\.ts|[\\/]tsconfig\.json)$/;
577560
fs.watch("tests/cases", { recursive: true }, (_, file) => {
578-
if (testFilePattern.test(file)) project.wait().then(fn);
561+
if (testFilePattern.test(file)) runTests();
579562
});
580563

581-
function runTests() {
582-
if (runTestsSource) runTestsSource.cancel();
583-
runTestsSource = new CancelSource();
584-
return cmdLineOptions.tests || cmdLineOptions.failed
585-
? runConsoleTests(runJs, "mocha-fivemat-progress-reporter", /*runInParallel*/ false, /*watchMode*/ true, runTestsSource.token)
586-
: runConsoleTests(runJs, "min", /*runInParallel*/ true, /*watchMode*/ true, runTestsSource.token);
587-
}
564+
async function runTests() {
565+
try {
566+
// Ensure only one instance of the test runner is running at any given time.
567+
if (sem.count > 0) {
568+
await sem.wait();
569+
try {
570+
// Wait for any concurrent recompilations to complete...
571+
try {
572+
await delay(100);
573+
while (project.hasRemainingWork()) {
574+
await project.waitForWorkToComplete();
575+
await delay(500);
576+
}
577+
}
578+
catch (e) {
579+
if (e instanceof CancelError) return;
580+
throw e;
581+
}
582+
583+
// cancel any pending or active test run if a new recompilation is triggered
584+
const source = new CancellationTokenSource();
585+
project.waitForWorkToStart().then(() => {
586+
source.cancel();
587+
});
588+
589+
if (cmdLineOptions.tests || cmdLineOptions.failed) {
590+
await runConsoleTests(runJs, "mocha-fivemat-progress-reporter", /*runInParallel*/ false, /*watchMode*/ true, source.token);
591+
}
592+
else {
593+
await runConsoleTests(runJs, "min", /*runInParallel*/ true, /*watchMode*/ true, source.token);
594+
}
595+
}
596+
finally {
597+
sem.release();
598+
}
599+
}
600+
}
601+
catch (e) {
602+
if (e instanceof CancelError) {
603+
log.warn("Operation was canceled");
604+
}
605+
else {
606+
log.error(e);
607+
}
608+
}
609+
};
588610
});
589611

590612
gulp.task("clean-built", /*help*/ false, [`clean:${diagnosticInformationMapTs}`], () => del(["built"]));

lib/de/diagnosticMessages.generated.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@
4949
"A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged_2434": "Eine Namespacedeklaration darf nicht vor der Klasse oder Funktion positioniert werden, mit der sie zusammengeführt wird.",
5050
"A_namespace_declaration_is_only_allowed_in_a_namespace_or_module_1235": "Eine Namespacedeklaration ist nur in einem Namespace oder Modul zulässig.",
5151
"A_namespace_style_import_cannot_be_called_or_constructed_and_will_cause_a_failure_at_runtime_7038": "Ein Import im Namespacestil kann nicht aufgerufen oder erstellt werden und verursacht zur Laufzeit einen Fehler.",
52-
"A_non_dry_build_would_build_project_0_6357": "Bei einem Build mit dem Flag \"-dry\" würde das Projekt \"{0}\" erstellt.",
53-
"A_non_dry_build_would_delete_the_following_files_Colon_0_6356": "Bei einem Build mit dem Flag \"-dry\" würden die folgenden Dateien gelöscht: {0}",
52+
"A_non_dry_build_would_build_project_0_6357": "Bei einem Build ohne das Flag \"-dry\" würde das Projekt \"{0}\" erstellt.",
53+
"A_non_dry_build_would_delete_the_following_files_Colon_0_6356": "Bei einem Build ohne das Flag \"-dry\" würden die folgenden Dateien gelöscht: {0}",
5454
"A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation_2371": "Ein Parameterinitialisierer ist nur in einer Funktions- oder Konstruktorimplementierung zulässig.",
5555
"A_parameter_property_cannot_be_declared_using_a_rest_parameter_1317": "Eine Parametereigenschaft darf nicht mithilfe eines rest-Parameters deklariert werden.",
5656
"A_parameter_property_is_only_allowed_in_a_constructor_implementation_2369": "Eine Parametereigenschaft ist nur in einer Konstruktorimplementierung zulässig.",

0 commit comments

Comments
 (0)