Skip to content

Commit ea69882

Browse files
refactor(tests); allow more retries on weval tests only
1 parent e2dfcbf commit ea69882

File tree

4 files changed

+19
-8
lines changed

4 files changed

+19
-8
lines changed

test/bindings.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,14 @@ import {
1111
WEVAL_TEST_ENABLED,
1212
DEBUG_TEST_ENABLED,
1313
maybeLogging,
14+
buildDefaultTestOpts,
1415
} from './util.js';
1516

1617
suite('Bindings', async () => {
1718
const bindingsCases = await readdir(new URL('./cases', import.meta.url));
1819

1920
for (const name of bindingsCases) {
20-
test(name, async () => {
21+
test(name, buildDefaultTestOpts(), async () => {
2122
const source = await readFile(
2223
new URL(`./cases/${name}/source.js`, import.meta.url),
2324
'utf8',

test/builtins.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,15 @@ import {
1212
WEVAL_TEST_ENABLED,
1313
DEBUG_TEST_ENABLED,
1414
maybeLogging,
15+
buildDefaultTestOpts,
1516
} from './util.js';
1617

1718
suite('Builtins', async () => {
1819
const builtins = await readdir(new URL('./builtins', import.meta.url));
1920

2021
for (const filename of builtins) {
2122
const name = filename.slice(0, -3);
22-
test(name, async () => {
23+
test(name, buildDefaultTestOpts(), async () => {
2324
const {
2425
source,
2526
test: runTest,

test/util.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,20 @@ export const WEVAL_TEST_ENABLED = isEnabledEnvVar(env.WEVAL_TEST);
77
export const DEBUG_TEST_ENABLED = isEnabledEnvVar(env.DEBUG_TEST);
88

99
function isEnabledEnvVar(v) {
10-
return typeof v === 'string' && ['1', 'yes', 'true'].includes(v.toLowerCase());
10+
return (
11+
typeof v === 'string' && ['1', 'yes', 'true'].includes(v.toLowerCase())
12+
);
1113
}
1214

15+
// Enable retries for individual tests if weval is under test
16+
export function buildDefaultTestOpts() {
17+
const opts = {};
18+
// if weval is enabled, for more retries
19+
if (WEVAL_TEST_ENABLED) {
20+
opts.retry = 3;
21+
}
22+
return opts;
23+
}
1324

1425
// Utility function for getting a random port
1526
export async function getRandomPort() {

test/wasi.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,11 @@ import {
1313
DEBUG_TRACING_ENABLED,
1414
WEVAL_TEST_ENABLED,
1515
DEBUG_TEST_ENABLED,
16+
buildDefaultTestOpts,
1617
} from './util.js';
1718

18-
// Enable retries for individual tests if weval is under test
19-
const TEST_OPTS = WEVAL_TEST_ENABLED ? { retry: 3 } : undefined;
20-
2119
suite('WASI', () => {
22-
test('basic app (old API)', TEST_OPTS, async () => {
20+
test('basic app (old API)', buildDefaultTestOpts(), async () => {
2321
const { instance } = await setupComponent({
2422
componentize: {
2523
src: `
@@ -61,7 +59,7 @@ suite('WASI', () => {
6159
assert.strictEqual(result.split(',').length, 3);
6260
});
6361

64-
test('basic app (OriginalSourceFile API)', TEST_OPTS, async () => {
62+
test('basic app (OriginalSourceFile API)', buildDefaultTestOpts(), async () => {
6563
const { instance } = await setupComponent({
6664
componentize: {
6765
opts: {

0 commit comments

Comments
 (0)