Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use prepare-test-env and ses-ava in SwingSet where possible #2709

Merged
merged 1 commit into from
Mar 26, 2021

Conversation

erights
Copy link
Member

@erights erights commented Mar 24, 2021

Enhance prepare-test-env beyond #2703 to also bundle in ses-ava.

Use it in SwingSet tests where possible. This does not include the metering tests.

Progress on #2662 but does not yet close it.

@erights
Copy link
Member Author

erights commented Mar 24, 2021

@michaelfig for some reason, it fails in pegasus. It seems related to tape or tap !

Copy link
Member

@warner warner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that one duplicate import is the only thing that really needs to change.

The inconsistency of the lint override for import ordering bugs me, it makes me think I don't understand what prettier wants to do. I'd be happiest if none of the files had an override. I'd be second happiest if all of the files had an override. If the override is really only necessary in some and not others, I'll be unhappy until I understand what makes a difference.. is it the spelling of the second import and whether it would sort before/after ../../tools/something?

packages/SwingSet/test/test-vat-env.js Outdated Show resolved Hide resolved
Copy link
Contributor

@FUDCo FUDCo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks pretty good. And many thanks for shouldering the tedium!

Have you looked into what would be involved in making this work with test-message-patterns.js? That's the biggest gap for me so far, if only because that test is currently the primary exercise point for what I've been in the middle of working on (and likely will continue to be for a while yet).

@FUDCo
Copy link
Contributor

FUDCo commented Mar 24, 2021

(I should add that if it's just a matter of wrapping a few more Ava API entry points in ses-ava, I'm willing to take that on, assuming it's not too deeply weird.)

Base automatically changed from prepare-unsafe-debug-env to master March 24, 2021 21:23
@erights erights force-pushed the prepare-ses-ava branch 4 times, most recently from 61c3bdf to 38133a1 Compare March 26, 2021 05:19
@erights erights changed the base branch from master to markm-update-ses-12-5 March 26, 2021 05:20
@erights
Copy link
Member Author

erights commented Mar 26, 2021

@warner Done. PTAL

@michaelfig please look at the Pegasus error and advise. Thanks.

@michaelfig
Copy link
Member

@michaelfig please look at the Pegasus error and advise. Thanks.

Pegasus doesn't use AVA. This failure was caused by a combination of well-intentioned changes: @katelynsills changed Pegasus tests to use prepare-test-env, then you changed prepare-test-env to use AVA. AVA crashes if it is imported in a non-AVA test.

This is either a regression we should deal with some other way, or you can say it's acceptable to force users of prepare-test-env (i.e. every dapp that is trying to emulate our test environment) to adopt AVA. I don't like the latter very much, but I can accept that it if it is intentional.

In my mind, this might be a misstep, and prepare-test-env should work without requiring AVA. Maybe that's not possible.

@michaelfig
Copy link
Member

michaelfig commented Mar 26, 2021

In my mind, this might be a misstep, and prepare-test-env should work without requiring AVA. Maybe that's not possible.

Easiest way to solve this is to create a prepare-test-env that doesn't provide the AVA-ised test export. Then import that module directly in the Pegasus tests and in the other prepare-test-env-ava.

@michaelfig
Copy link
Member

As long as the mechanism is there to fix the Pegasus situation, go ahead and ignore the error and merge. I can apply the fix soon.

@erights erights changed the base branch from markm-update-ses-12-5 to master March 26, 2021 06:31
Copy link
Member

@michaelfig michaelfig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes me happy!

Are there reasons there are some test files that still have:

import 'prepare-test-env-ava';
import test from 'ava';

? If you're trying not to change semantics, that's a good enough reason.

@erights
Copy link
Member Author

erights commented Mar 26, 2021

That makes me happy!

Likewise! This separation you suggested is definitely nice.

Are there reasons there are some test files that still have:

import 'prepare-test-env-ava';
import test from 'ava';

? If you're trying not to change semantics, that's a good enough reason.

Yup, that's why. In this PR trying to set the stage for that change, but wanted to do that change in a succeeding PR. Coming soon!

Copy link
Member

@warner warner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. In the long run I'm slightly nervous about encouraging the deep import (with tools/ in the name), which might impose some constraints on how we organize swingset's internals. OTOH I think there's a mechanism in package.json to make arbitrary mappings from the name in the import to the location of the file within the package directory, so if we want to rearrange files, we could use that mechanism to keep the external name stable. The pattern we're thus establishing is that @agoric/swingset-vat/X is the actual vat/controller/VM facility, and @agoric/swingset-vat/tools/Y is where you get tools to run tests that exercise code which wants to run in a swingset vat environment. Which seems fine to me.

@erights erights merged commit 85b674e into master Mar 26, 2021
@erights erights deleted the prepare-ses-ava branch March 26, 2021 17:40
@erights
Copy link
Member Author

erights commented Mar 26, 2021

Looks good. In the long run I'm slightly nervous about encouraging the deep import (with tools/ in the name), which might impose some constraints on how we organize swingset's internals. OTOH I think there's a mechanism in package.json to make arbitrary mappings from the name in the import to the location of the file within the package directory, so if we want to rearrange files, we could use that mechanism to keep the external name stable. The pattern we're thus establishing is that @agoric/swingset-vat/X is the actual vat/controller/VM facility, and @agoric/swingset-vat/tools/Y is where you get tools to run tests that exercise code which wants to run in a swingset vat environment. Which seems fine to me.

This sound good. But this PR made no progress towards that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants