From b252dba5a0804056a84508da1841b08f9864f1fa Mon Sep 17 00:00:00 2001 From: Ben Taylor Date: Sun, 17 Nov 2024 11:56:09 +1100 Subject: [PATCH] Fix test failures (#300) * Fix upload artifact * Fix STDIN with large inputs --- .github/workflows/test-on-pull-request.yml | 2 +- packages/wasi/tests/libstd.spec.ts | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test-on-pull-request.yml b/.github/workflows/test-on-pull-request.yml index 5850c5f4..58175a33 100644 --- a/.github/workflows/test-on-pull-request.yml +++ b/.github/workflows/test-on-pull-request.yml @@ -18,7 +18,7 @@ jobs: run: npm run test - name: Upload test results if: always() - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: playwright-report path: playwright-report diff --git a/packages/wasi/tests/libstd.spec.ts b/packages/wasi/tests/libstd.spec.ts index 93d734b2..a5151818 100644 --- a/packages/wasi/tests/libstd.spec.ts +++ b/packages/wasi/tests/libstd.spec.ts @@ -57,6 +57,7 @@ for (const name of wasmFiles) { let stderr = ""; let stdout = ""; + let stdinBytes = new TextEncoder().encode(stdin ?? ""); return W.start( fetch(url), @@ -69,11 +70,10 @@ for (const name of wasmFiles) { stderr: (s) => { stderr += s; }, - stdin: (maxByteLength: number) => { - const index = Math.floor(maxByteLength / 2) + 1; - const retvalue = stdin.slice(0, index); - stdin = stdin.slice(index); - return retvalue; + stdin: (maxByteLength) => { + const chunk = stdinBytes.slice(0, maxByteLength); + stdinBytes = stdinBytes.slice(maxByteLength); + return new TextDecoder().decode(chunk); }, fs, })