Move fixed chunk size polling as a watch option and move it out of server (#42542)

* Move fixed chunk size polling as a watch option and move it out of server
Fixes #41549

* Feedback
This commit is contained in:
Sheetal Nandi authored and GitHub committed 2021-03-02 16:45:53 -08:00
1 parent 5dbb110497
commit 0cf834ceec
14 files changed
+572 -179

No files matched your search

@@ -650,7 +650,7 @@ namespace ts {
length: undefined
},
{
messageText: "Argument for '--fallbackPolling' option must be: 'fixedinterval', 'priorityinterval', 'dynamicpriority'.",
messageText: "Argument for '--fallbackPolling' option must be: 'fixedinterval', 'priorityinterval', 'dynamicpriority', 'fixedchunksize'.",
category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category,
code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code,
file: undefined,
@@ -957,7 +957,7 @@ namespace ts {
length: undefined
},
{
messageText: "Argument for '--fallbackPolling' option must be: 'fixedinterval', 'priorityinterval', 'dynamicpriority'.",
messageText: "Argument for '--fallbackPolling' option must be: 'fixedinterval', 'priorityinterval', 'dynamicpriority', 'fixedchunksize'.",
category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category,
code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code,
file: undefined,
@@ -66,6 +66,90 @@ namespace ts.tscWatch {
]
});
verifyTscWatch({
scenario,
subScenario: "watchFile/using fixed chunk size polling",
commandLineArgs: ["-w", "-p", "/a/b/tsconfig.json"],
sys: () => {
const configFile: File = {
path: "/a/b/tsconfig.json",
content: JSON.stringify({
watchOptions: {
watchFile: "FixedChunkSizePolling"
}
})
};
const files = [libFile, commonFile1, commonFile2, configFile];
return createWatchedSystem(files);
},
changes: [
{
caption: "The timeout is to check the status of all files",
change: noop,
timeouts: (sys, programs) => {
// On each timeout file does not change
const initialProgram = programs[0][0];
for (let index = 0; index < 4; index++) {
sys.checkTimeoutQueueLengthAndRun(1);
assert.deepEqual(programs[0][0], initialProgram);
}
},
},
{
caption: "Make change to file but should detect as changed and schedule program update",
// Make a change to file
change: sys => sys.writeFile(commonFile1.path, "var zz30 = 100;"),
timeouts: checkSingleTimeoutQueueLengthAndRun,
},
{
caption: "Callbacks: queue and scheduled program update",
change: noop,
// Callbacks: scheduled program update and queue for the polling
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(2),
},
{
caption: "The timeout is to check the status of all files",
change: noop,
timeouts: (sys, programs) => {
// On each timeout file does not change
const initialProgram = programs[0][0];
sys.checkTimeoutQueueLengthAndRun(1);
assert.deepEqual(programs[0][0], initialProgram);
},
},
]
});
verifyTscWatch({
scenario,
subScenario: "watchFile/setting default as fixed chunk size watch file works",
commandLineArgs: ["-w", "-p", "/a/b/tsconfig.json"],
sys: () => {
const configFile: File = {
path: "/a/b/tsconfig.json",
content: "{}"
};
const files = [libFile, commonFile1, commonFile2, configFile];
const sys = createWatchedSystem(files);
sys.defaultWatchFileKind = () => WatchFileKind.FixedChunkSizePolling;
return sys;
},
changes: [
{
caption: "Make change to file but should detect as changed and schedule program update",
// Make a change to file
change: sys => sys.writeFile(commonFile1.path, "var zz30 = 100;"),
timeouts: checkSingleTimeoutQueueLengthAndRun,
},
{
caption: "Callbacks: queue and scheduled program update",
change: noop,
// Callbacks: scheduled program update and queue for the polling
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(2),
},
]
});
describe("tsc-watch when watchDirectories implementation", () => {
function verifyRenamingFileInSubFolder(subScenario: string, tscWatchDirectory: Tsc_WatchDirectory) {
const projectFolder = "/a/username/project";