Skip to content

Conversation

@RobinMalfait
Copy link
Member

This PR improves the tests by not running the optimization step (via Lightning CSS) in places where we know that nothing should be generated.

In fact, if we generate invalid CSS where we expected that nothing was being generated, then Lightning CSS will throw the CSS out. This means that we have a bug somewhere in our code, and we should fix it but we don't know about it.

Bonus points: this improves the performance of the tests a tiny bit.

@RobinMalfait RobinMalfait requested a review from a team as a code owner October 17, 2024 13:50
Copy link
Member Author

RobinMalfait commented Oct 17, 2024

This stack of pull requests is managed by Graphite. Learn more about stacking.

@RobinMalfait RobinMalfait force-pushed the robin/ensure_existing_spaces_in_attribute_selector_are_valid branch from 9ff2d99 to 5e26aec Compare October 17, 2024 14:11
@RobinMalfait RobinMalfait force-pushed the robin/run_tests_without_optimizing branch 2 times, most recently from 639407d to f08b1e7 Compare October 17, 2024 14:21
}

export async function run(candidates: string[]) {
export async function run(candidates: string[], { optimize = true } = {}) {
Copy link
Member

Choose a reason for hiding this comment

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

Not a big fan of having to add an object with optimize to every call site. How do you feel about this?

I’m wondering if we:

  • Should make this the default (or is the number of run() calls that do need optimize: true even larger than this subset?
  • Should instead add a second runOptimized export instead of adding a boolean variable?

Copy link
Contributor

Choose a reason for hiding this comment

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

Also not a fan but not enough to really care. I think unoptimized is not the default. Pretty sure more tests require an optimized CSS result than not but I don't have a good idea of what the function should be called.

Copy link
Member Author

Choose a reason for hiding this comment

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

Funny thing is, I did use a new method initially (14817cb) but run vs runOptimized or vs build all felt wrong, so did a fallback here because typically you run it without.

You could argue that we just don't run the tests through Lightning CSS (which will make the tests bigger but faster).

@RobinMalfait RobinMalfait force-pushed the robin/ensure_existing_spaces_in_attribute_selector_are_valid branch from 71c24fe to 5120b3b Compare October 18, 2024 11:03
@RobinMalfait RobinMalfait force-pushed the robin/run_tests_without_optimizing branch 2 times, most recently from 13dd01e to 8fd45ba Compare October 18, 2024 11:09
@RobinMalfait RobinMalfait force-pushed the robin/ensure_existing_spaces_in_attribute_selector_are_valid branch from 6aa4ed3 to 7b0465b Compare October 18, 2024 13:37
@RobinMalfait RobinMalfait force-pushed the robin/run_tests_without_optimizing branch from 8fd45ba to ef7332a Compare October 18, 2024 13:37
@RobinMalfait RobinMalfait force-pushed the robin/ensure_existing_spaces_in_attribute_selector_are_valid branch from 5e4504d to 8d48594 Compare October 18, 2024 14:10
@RobinMalfait RobinMalfait force-pushed the robin/run_tests_without_optimizing branch from ef7332a to 4055bb9 Compare October 18, 2024 14:10
Base automatically changed from robin/ensure_existing_spaces_in_attribute_selector_are_valid to next October 18, 2024 17:51
If we generate something incorrect, then Lightning CSS will throw it
away which could result in the fact that we generate something wrong but
don't know about it because of Lightning CSS.

In a lot of tests we know that nothing should be generated, so running
an optimization step is not required.
The optimization happens by default, but for the cases where we know we
don't need to optimize, we can pass in a flag.
@RobinMalfait
Copy link
Member Author

Closing this, if we want this we can re-enable it later.

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