From 75e7dd625c8eaca8c61fe06d29a11c9e7c07a682 Mon Sep 17 00:00:00 2001 From: "Mark S. Miller" Date: Tue, 12 Dec 2023 13:34:55 -0800 Subject: [PATCH] refactor(env-options): migrate test to reduce cyclic dependencies --- packages/env-options/README.md | 5 +++++ packages/env-options/package.json | 4 +--- packages/env-options/test/prepare-test-env-ava.js | 9 --------- packages/lockdown/package.json | 3 --- packages/ses-ava/package.json | 2 ++ packages/ses-ava/test/prepare-test-env-ava.js | 7 +++++++ .../{env-options => ses-ava}/test/test-env-options.js | 4 +++- 7 files changed, 18 insertions(+), 16 deletions(-) delete mode 100644 packages/env-options/test/prepare-test-env-ava.js create mode 100644 packages/ses-ava/test/prepare-test-env-ava.js rename packages/{env-options => ses-ava}/test/test-env-options.js (91%) diff --git a/packages/env-options/README.md b/packages/env-options/README.md index 1dc361eb95..a6cb7aa739 100644 --- a/packages/env-options/README.md +++ b/packages/env-options/README.md @@ -74,3 +74,8 @@ if (capturedEnvironmentOptionNames.length > 0) { ); } ``` + +# Note of test migration + +To reduce cyclic dependencies, the tests of this module have been moved to +@endo/ses-ava. Doing `yarn test` here currently does nothing. diff --git a/packages/env-options/package.json b/packages/env-options/package.json index bdf56e4921..bc2168b9e8 100644 --- a/packages/env-options/package.json +++ b/packages/env-options/package.json @@ -32,11 +32,9 @@ "lint:types": "tsc", "build:types": "tsc --build tsconfig.build.json", "clean:types": "git clean -f '*.d.ts*'", - "test": "ava" + "test": "exit 0" }, "devDependencies": { - "@endo/init": "^1.0.0", - "@endo/ses-ava": "^1.0.0", "ava": "^5.3.0", "babel-eslint": "^10.0.3", "eslint": "^8.46.0", diff --git a/packages/env-options/test/prepare-test-env-ava.js b/packages/env-options/test/prepare-test-env-ava.js deleted file mode 100644 index f5ed7c0c84..0000000000 --- a/packages/env-options/test/prepare-test-env-ava.js +++ /dev/null @@ -1,9 +0,0 @@ -// eslint-disable-next-line import/no-extraneous-dependencies -import '@endo/init/debug.js'; - -// eslint-disable-next-line import/no-extraneous-dependencies -import { wrapTest } from '@endo/ses-ava'; -import rawTest from 'ava'; - -/** @type {typeof rawTest} */ -export const test = wrapTest(rawTest); diff --git a/packages/lockdown/package.json b/packages/lockdown/package.json index a851b5e46a..6e2c92ca08 100644 --- a/packages/lockdown/package.json +++ b/packages/lockdown/package.json @@ -12,9 +12,6 @@ "lint-fix": "eslint --fix '**/*.js'", "lint": "eslint '**/*.js'" }, - "devDependencies": { - "ava": "^5.1.1" - }, "dependencies": { "ses": "^1.0.0" }, diff --git a/packages/ses-ava/package.json b/packages/ses-ava/package.json index 08c6659507..0c56e90839 100644 --- a/packages/ses-ava/package.json +++ b/packages/ses-ava/package.json @@ -38,6 +38,8 @@ "ses": "^1.0.0" }, "devDependencies": { + "@endo/env-options": "^1.0.0", + "@endo/lockdown": "^1.0.0", "ava": "^5.3.0", "babel-eslint": "^10.0.3", "c8": "^7.14.0", diff --git a/packages/ses-ava/test/prepare-test-env-ava.js b/packages/ses-ava/test/prepare-test-env-ava.js new file mode 100644 index 0000000000..e83f4928c7 --- /dev/null +++ b/packages/ses-ava/test/prepare-test-env-ava.js @@ -0,0 +1,7 @@ +import '@endo/lockdown/commit-debug.js'; + +import rawTest from 'ava'; +import { wrapTest } from '../src/ses-ava-test.js'; + +/** @type {typeof rawTest} */ +export const test = wrapTest(rawTest); diff --git a/packages/env-options/test/test-env-options.js b/packages/ses-ava/test/test-env-options.js similarity index 91% rename from packages/env-options/test/test-env-options.js rename to packages/ses-ava/test/test-env-options.js index 923ada74ab..c21c0accaf 100644 --- a/packages/env-options/test/test-env-options.js +++ b/packages/ses-ava/test/test-env-options.js @@ -1,5 +1,7 @@ import { test } from './prepare-test-env-ava.js'; -import { makeEnvironmentCaptor } from '../src/env-options.js'; + +// eslint-disable-next-line import/order +import { makeEnvironmentCaptor } from '@endo/env-options'; test('test env options empty env', async t => { const c1 = new Compartment();