mirror of
https://github.com/zulip/zulip.git
synced 2025-11-15 19:31:58 +00:00
zjsunit: Handle exceptions in with_field, with_overrides.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
committed by
Anders Kaseorg
parent
7e3735b9ba
commit
58b18fd499
@@ -68,10 +68,12 @@ exports.restore = function () {
|
|||||||
|
|
||||||
exports.with_field = function (obj, field, val, f) {
|
exports.with_field = function (obj, field, val, f) {
|
||||||
const old_val = obj[field];
|
const old_val = obj[field];
|
||||||
|
try {
|
||||||
obj[field] = val;
|
obj[field] = val;
|
||||||
const result = f();
|
return f();
|
||||||
|
} finally {
|
||||||
obj[field] = old_val;
|
obj[field] = old_val;
|
||||||
return result;
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.with_overrides = function (test_function) {
|
exports.with_overrides = function (test_function) {
|
||||||
@@ -165,12 +167,14 @@ exports.with_overrides = function (test_function) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
try {
|
||||||
test_function(override);
|
test_function(override);
|
||||||
|
} finally {
|
||||||
restore_callbacks.reverse();
|
restore_callbacks.reverse();
|
||||||
for (const restore_callback of restore_callbacks) {
|
for (const restore_callback of restore_callbacks) {
|
||||||
restore_callback();
|
restore_callback();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (const module_unused_funcs of unused_funcs.values()) {
|
for (const module_unused_funcs of unused_funcs.values()) {
|
||||||
for (const unused_name of module_unused_funcs.keys()) {
|
for (const unused_name of module_unused_funcs.keys()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user