Skip to content

Commit e013a56

Browse files
committed
テスト定義をリファクタ
1 parent 1ae527e commit e013a56

File tree

10 files changed

+579
-515
lines changed

10 files changed

+579
-515
lines changed

app/terminal/page.tsx

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { Fragment, useEffect, useRef, useState } from "react";
66
import { useWandbox } from "@my-code/runtime/wandbox/runtime";
77
import { RuntimeContext } from "@my-code/runtime/interface";
88
import { langConstants, RuntimeLang } from "@my-code/runtime/languages";
9-
import { defineTests } from "@my-code/runtime/tests";
109
import { usePyodide } from "@my-code/runtime/worker/pyodide";
1110
import { useRuby } from "@my-code/runtime/worker/ruby";
1211
import { useJSEval } from "@my-code/runtime/worker/jsEval";
@@ -25,6 +24,12 @@ import sub_h from "@my-code/runtime/samples/sub.h?raw";
2524
import sub_cpp from "@my-code/runtime/samples/sub.cpp?raw";
2625
import main2_rs from "@my-code/runtime/samples/main2.rs?raw";
2726
import sub_rs from "@my-code/runtime/samples/sub.rs?raw";
27+
import {
28+
RUNTIME_TIMEOUTS,
29+
waitForRuntimeReady,
30+
} from "@my-code/runtime/tests/utils";
31+
import { replTests } from "@my-code/runtime/tests/repl";
32+
import { fileExecutionTests } from "@my-code/runtime/tests/fileExecution";
2833

2934
export default function RuntimeTestPage() {
3035
return (
@@ -143,7 +148,11 @@ function RuntimeSample({
143148
/>
144149
))}
145150
{config.exec && (
146-
<ExecFile filenames={config.exec} language={langConstants(lang)} content="" />
151+
<ExecFile
152+
filenames={config.exec}
153+
language={langConstants(lang)}
154+
content=""
155+
/>
147156
)}
148157
{config.readonlyFiles?.map((filename) => (
149158
<EditorComponent
@@ -230,7 +239,39 @@ function MochaTest() {
230239

231240
for (const lang of Object.keys(runtimeRef.current) as RuntimeLang[]) {
232241
runtimeRef.current[lang].init?.();
233-
defineTests(lang, runtimeRef);
242+
243+
describe(`${lang} Runtime`, function () {
244+
this.timeout(RUNTIME_TIMEOUTS[lang]);
245+
246+
beforeEach(async function () {
247+
this.timeout(60000);
248+
await waitForRuntimeReady(lang, runtimeRef);
249+
});
250+
251+
describe("REPL", function () {
252+
for (const [name, generator] of Object.entries(replTests)) {
253+
const body = generator(lang);
254+
if (body) {
255+
it(name, async () => body(runtimeRef));
256+
} else {
257+
it.skip(name);
258+
}
259+
}
260+
});
261+
262+
describe("File Execution", function () {
263+
for (const [name, generator] of Object.entries(
264+
fileExecutionTests
265+
)) {
266+
const body = generator(lang);
267+
if (body) {
268+
it(name, async () => body(runtimeRef));
269+
} else {
270+
it.skip(name);
271+
}
272+
}
273+
});
274+
});
234275
}
235276

236277
const runner = mocha.run();

packages/runtime/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"type": "module",
55
"exports": {
66
"./*": "./src/*",
7-
"./samples/*": "./samples/*"
7+
"./samples/*": "./samples/*",
8+
"./tests/*": "./tests/*"
89
},
910
"scripts": {
1011
"test": "vitest run"

0 commit comments

Comments
 (0)