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

Add 'fixtureFromGraph' test helper function #331

Merged

Conversation

yamadapc
Copy link
Contributor

@yamadapc yamadapc commented Feb 5, 2025

This is to easily set-up testing fixtures that only care about the graph
relations between source files.

This will be used for integration testing the bundler algorithm.

Test Plan: yarn test

Created using spr 1.3.5
*/
export function asset(
path: string,
dependencies?: (string | DependencySpec)[],
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not just use DependencySpec?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This way you can do:

    await fixtureFromGraph('dir', fs, [
      asset('file1.js', ['file2.js', 'file3.js']),
      asset('file2.js'),
      asset('file3.js'),
    ]);

Which builds:

file1 -> file2
file1 -> file3

Instead of

    await fixtureFromGraph('dir', fs, [
      asset('file1.js', [
         { to: 'file2.js', type: 'sync' },
         { to: 'file3.js', type: 'sync' }
      ]),
      asset('file2.js'),
      asset('file3.js'),
    ]);

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah I just don't love the inconsistency but it's mostly a nit

Created using spr 1.3.5

[skip ci]
Created using spr 1.3.5
@yamadapc yamadapc changed the base branch from main to spr/yamadapc/main.add-fixturefromgraph-test-helper-function February 5, 2025 23:59
yamadapc added a commit that referenced this pull request Feb 5, 2025
This is to easily set-up testing fixtures that only care about the graph
relations between source files.

This will be used for integration testing the bundler algorithm.

Test Plan: yarn test

Pull Request: #331
Created using spr 1.3.5

[skip ci]
Created using spr 1.3.5
@yamadapc yamadapc changed the base branch from spr/yamadapc/main.add-fixturefromgraph-test-helper-function to main February 6, 2025 01:12
@yamadapc yamadapc merged commit 6c4f222 into main Feb 6, 2025
18 checks passed
@yamadapc yamadapc deleted the spr/yamadapc/add-fixturefromgraph-test-helper-function branch February 6, 2025 02:11
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.

2 participants