Revert "re-run checks"

This reverts commit 5bd68b6a4f.
This commit is contained in:
Nacho Codoñer
2024-04-08 18:03:06 +02:00
parent 9d23a746e1
commit eea9767509
3 changed files with 54 additions and 26 deletions

View File

@@ -42,6 +42,7 @@ EVp.withValue = function (value, func) {
} finally {
currentValues[this.slot] = saved;
}
return ret;
};

View File

@@ -49,20 +49,22 @@ class EnvironmentVariableAsync {
*/
withValue(value, func, options = {}) {
const self = this;
const slotCall = Meteor._getValueFromAslStore(SLOT_CALL_KEY);
const dynamics =
Meteor._getValueFromAslStore(UPPER_CALL_DYNAMICS_KEY_NAME) || {};
dynamics[slotCall] = Meteor._getValueFromAslStore(CURRENT_VALUE_KEY_NAME);
self.upperCallDynamics = dynamics;
const slotCall = self.slot;
const dynamics = Object.assign(
{},
Meteor._getValueFromAslStore(UPPER_CALL_DYNAMICS_KEY_NAME) || {}
);
if (slotCall) {
dynamics[slotCall] = value;
}
return Meteor._runAsync(
async function () {
let ret;
try {
Meteor._updateAslStore(
UPPER_CALL_DYNAMICS_KEY_NAME,
this.upperCallDynamics,
);
Meteor._updateAslStore(CURRENT_VALUE_KEY_NAME, value);
Meteor._updateAslStore(UPPER_CALL_DYNAMICS_KEY_NAME, dynamics);
ret = await func();
} finally {
Meteor._updateAslStore(CURRENT_VALUE_KEY_NAME, undefined);
@@ -80,7 +82,7 @@ class EnvironmentVariableAsync {
[SLOT_CALL_KEY]: this.slot,
},
options,
)
),
);
}

View File

@@ -16,27 +16,52 @@ Tinytest.add("environment - dynamic variables", function (test) {
test.equal(CurrentFoo.get(), undefined);
});
Tinytest.addAsync(
"environment - dynamic variables with two context",
async function (test) {
const context1 = new Meteor.EnvironmentVariable();
const context2 = new Meteor.EnvironmentVariable();
if (Meteor.isServer) {
Tinytest.addAsync(
"environment - dynamic variables with two context (server)",
async function (test) {
const context1 = new Meteor.EnvironmentVariable();
const context2 = new Meteor.EnvironmentVariable();
await context1.withValue(42, async () => {
test.equal(context2.get(), undefined);
await context2.withValue(1, async () => {
await context2.withValue(2, async () => {
test.equal(context2.get(), 2);
return context1.withValue(42, async () => {
test.equal(context2.get(), undefined);
await context2.withValue(1, async () => {
await context2.withValue(2, async () => {
test.equal(context2.get(), 2);
});
test.equal(context1.get(), 42);
test.equal(context2.get(), 1);
});
test.equal(context1.get(), 42);
test.equal(context2.get(), 1);
test.equal(context2.get(), undefined);
});
test.equal(context1.get(), 42);
test.equal(context2.get(), undefined);
});
}
);
}
);
} else {
// Basically the same test as the server one, but without async/await
// as we don't handle async on the client in this case
// due to the idea that we need to keep new EcmaScript features doesn't compile in older browsers
Tinytest.add(
"environment - dynamic variables with two context (client)",
function (test) {
const context1 = new Meteor.EnvironmentVariable();
const context2 = new Meteor.EnvironmentVariable();
context1.withValue(42, () => {
test.equal(context2.get(), undefined);
context2.withValue(1, () => {
context2.withValue(2, () => {
test.equal(context2.get(), 2);
});
test.equal(context1.get(), 42);
test.equal(context2.get(), 1);
});
test.equal(context1.get(), 42);
test.equal(context2.get(), undefined);
});
}
);
}
Tinytest.addAsync("environment - bindEnvironment", async function (test) {
var raised_f;