Skip to content

Commit 141097c

Browse files
test: micropython
1 parent 6ab065a commit 141097c

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
const device = pymakr.devicesStore.get()[0];
2+
3+
const busyChange = (device) => new Promise((resolve) => device.busy.next(resolve));
4+
5+
// tests pertaining to the capabilities of micropython-ctl-cont
6+
7+
test("micropython", async () => {
8+
await device.connect();
9+
test("x06 safeboots device", async () => {
10+
assert(!device.busy.get());
11+
device.adapter.sendData("\x06");
12+
await busyChange(device);
13+
assert(device.busy.get());
14+
await busyChange(device);
15+
assert(!device.busy.get());
16+
});
17+
test("can use rawRepl", async () => {
18+
console.log("[TEST] RUN SCRIPT");
19+
const rawReplPromise = device.runScript("import time\ntime.sleep(0.3)");
20+
await rawReplPromise;
21+
});
22+
test("rawrepl can handle safeboot (ctrl + f / 0x06)", async () => {
23+
assert(!device.busy.get());
24+
const rawReplPromise = device.runScript("import time\nprint('hello')\ntime.sleep(100)");
25+
await new Promise((resolve) => setTimeout(resolve, 200));
26+
27+
// process.env.debug = "silly";
28+
device.adapter.sendData("\x06");
29+
console.log("state", device.adapter.getState());
30+
assert.equal(device.adapter.getState().receivingResponseSubState, "SCRIPT_ABORTED");
31+
await rawReplPromise;
32+
});
33+
test("rawrepl can handle stopScript(3)", async () => {
34+
assert(!device.busy.get());
35+
const rawReplPromise = device.runScript("import time\nprint('hello')\ntime.sleep(100)");
36+
await new Promise((resolve) => setTimeout(resolve, 200));
37+
38+
// process.env.debug = "silly";
39+
await device.stopScript(3);
40+
console.log("state", device.adapter.getState());
41+
assert.equal(device.adapter.getState().receivingResponseSubState, "SCRIPT_ABORTED");
42+
await rawReplPromise;
43+
});
44+
test("rawrepl can handle stopScript(0)", async () => {
45+
assert(!device.busy.get());
46+
const rawReplPromise = device.runScript("import time\nprint('hello')\ntime.sleep(100)");
47+
await new Promise((resolve) => setTimeout(resolve, 200));
48+
49+
// process.env.debug = "silly";
50+
await device.stopScript(0);
51+
console.log("state", device.adapter.getState());
52+
assert.equal(device.adapter.getState().receivingResponseSubState, "SCRIPT_ABORTED");
53+
await rawReplPromise;
54+
});
55+
});

0 commit comments

Comments
 (0)