Skip to content

Commit 10b784a

Browse files
authored
Add try catch and defer.reject for checking sys tests (#58252)
1 parent 8426565 commit 10b784a

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

src/testRunner/unittests/sys/symlinkWatching.ts

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,16 @@ describe("unittests:: sys:: symlinkWatching::", () => {
4545
watcher: sys.watchFile!(
4646
toWatch,
4747
(fileName, eventKind, modifiedTime) => {
48-
assert.equal(fileName, toWatch);
49-
assert.equal(eventKind, ts.FileWatcherEventKind.Changed);
50-
const actual = modifiedTimeToString(modifiedTime);
51-
assert(actual === undefined || actual === modifiedTimeToString(sys.getModifiedTime!(file)));
48+
try {
49+
assert.equal(fileName, toWatch);
50+
assert.equal(eventKind, ts.FileWatcherEventKind.Changed);
51+
const actual = modifiedTimeToString(modifiedTime);
52+
assert(actual === undefined || actual === modifiedTimeToString(sys.getModifiedTime!(file)));
53+
}
54+
catch (e) {
55+
result.deferred.reject(e);
56+
return;
57+
}
5258
result.deferred.resolve();
5359
},
5460
10,
@@ -118,8 +124,14 @@ describe("unittests:: sys:: symlinkWatching::", () => {
118124
const deferred = defer();
119125
delayedOp(() => {
120126
if (opType !== "init") {
121-
verifyEventAndFileNames(`${opType}:: dir`, dirResult.actual, expectedResult);
122-
verifyEventAndFileNames(`${opType}:: link`, linkResult.actual, expectedResult);
127+
try {
128+
verifyEventAndFileNames(`${opType}:: dir`, dirResult.actual, expectedResult);
129+
verifyEventAndFileNames(`${opType}:: link`, linkResult.actual, expectedResult);
130+
}
131+
catch (e) {
132+
deferred.reject(e);
133+
return;
134+
}
123135
}
124136
deferred.resolve();
125137
}, !!process.env.CI ? 1000 : 500);

0 commit comments

Comments
 (0)