Skip to content

Commit b9c977c

Browse files
committed
add testing pod support for python
1 parent cf77a0f commit b9c977c

File tree

1 file changed

+44
-1
lines changed

1 file changed

+44
-1
lines changed

ui/src/lib/ws/middleware.js

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,26 @@ function getChildExports({ id, pods }) {
219219
return res;
220220
}
221221

222+
function getDeckExports({ id, pods }) {
223+
let res = {};
224+
res[pods[id].ns] = [].concat(
225+
...pods[id].children
226+
.filter(({ id }) => pods[id].type !== "DECK" && pods[id].exports)
227+
.map(({ id }) => Object.keys(pods[id].exports))
228+
);
229+
for (let pod of pods[id].children
230+
.filter(({ id }) => pods[id].type !== "DECK" && pods[id].reexports)
231+
.map(({ id }) => pods[id])) {
232+
for (let [name, id] of Object.entries(pod.reexports)) {
233+
if (!res[pods[id].ns]) {
234+
res[pods[id].ns] = [];
235+
}
236+
res[pods[id].ns].push(name);
237+
}
238+
}
239+
return res;
240+
}
241+
222242
function getUtilExports({ id, pods }) {
223243
let res = {};
224244
let utilIds = getUtilIds({ id, pods });
@@ -262,8 +282,15 @@ function powerRun_python({ id, storeAPI, socket }) {
262282

263283
let childexports = getChildExports({ id, pods });
264284
let utilexports = getUtilExports({ id, pods });
265-
// FIXME would childexports and utilexports overlap?
266285
let allexports = Object.assign({}, childexports, utilexports);
286+
if (pod.thundar) {
287+
// for testing pod, get all exports/reexports from its parent
288+
allexports = Object.assign(
289+
allexports,
290+
getDeckExports({ id: pod.parent, pods })
291+
);
292+
}
293+
// FIXME would childexports and utilexports overlap?
267294
let code = Object.keys(allexports)
268295
.map((ns) =>
269296
allexports[ns]
@@ -376,6 +403,15 @@ CODEPOD_EVAL("""${name} = CODEPOD_GETMOD("${pod.ns}").__dict__["${name}"]\n0""",
376403
ns: pod.ns,
377404
});
378405
}
406+
// if the deck of this pod contains testing decks, update there as well
407+
pods[pod.parent].children
408+
.filter(({ id, type }) => type === "DECK" && pods[id].thundar)
409+
.map(({ id }) => {
410+
code += `
411+
CODEPOD_EVAL("""${name} = CODEPOD_GETMOD("${pod.ns}").__dict__["${name}"]\n0""", "${pods[id].ns}")
412+
`;
413+
});
414+
379415
console.log("==", name, uses);
380416
if (uses) {
381417
for (let use of uses) {
@@ -393,6 +429,13 @@ CODEPOD_EVAL("""${name} = CODEPOD_GETMOD("${pod.ns}").__dict__["${name}"]\n0""",
393429
ns: pod.ns,
394430
});
395431
}
432+
pods[pods[use].parent].children
433+
.filter(({ id, type }) => type === "DECK" && pods[id].thundar)
434+
.map(({ id }) => {
435+
code += `
436+
CODEPOD_EVAL("""${name} = CODEPOD_GETMOD("${pod.ns}").__dict__["${name}"]\n0""", "${pods[id].ns}")
437+
`;
438+
});
396439
}
397440
}
398441
}

0 commit comments

Comments
 (0)