Add try catch and defer.reject for checking sys tests (#58252)

This commit is contained in:
Sheetal Nandi 2024-04-19 09:48:19 -07:00 committed by GitHub
parent 84265652d6
commit 10b784aa88
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -45,10 +45,16 @@ describe("unittests:: sys:: symlinkWatching::", () => {
watcher: sys.watchFile!(
toWatch,
(fileName, eventKind, modifiedTime) => {
assert.equal(fileName, toWatch);
assert.equal(eventKind, ts.FileWatcherEventKind.Changed);
const actual = modifiedTimeToString(modifiedTime);
assert(actual === undefined || actual === modifiedTimeToString(sys.getModifiedTime!(file)));
try {
assert.equal(fileName, toWatch);
assert.equal(eventKind, ts.FileWatcherEventKind.Changed);
const actual = modifiedTimeToString(modifiedTime);
assert(actual === undefined || actual === modifiedTimeToString(sys.getModifiedTime!(file)));
}
catch (e) {
result.deferred.reject(e);
return;
}
result.deferred.resolve();
},
10,
@ -118,8 +124,14 @@ describe("unittests:: sys:: symlinkWatching::", () => {
const deferred = defer();
delayedOp(() => {
if (opType !== "init") {
verifyEventAndFileNames(`${opType}:: dir`, dirResult.actual, expectedResult);
verifyEventAndFileNames(`${opType}:: link`, linkResult.actual, expectedResult);
try {
verifyEventAndFileNames(`${opType}:: dir`, dirResult.actual, expectedResult);
verifyEventAndFileNames(`${opType}:: link`, linkResult.actual, expectedResult);
}
catch (e) {
deferred.reject(e);
return;
}
}
deferred.resolve();
}, !!process.env.CI ? 1000 : 500);