test: lazy create stats in runner #9469
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Should not call
stats.toJson
in test runner if__STATS__
is not used.Before:

After:

This pull request involves significant changes to the
rspack-test-tools
package, primarily focusing on modifying how compiler statistics are handled and passed around. The major changes include introducing acreateStatsGetter
method, updating various runner classes to use this new method, and altering test cases to reflect these changes.Major Changes:
Enhancements to Statistics Handling:
createStatsGetter
method inBasicRunnerFactory
to cache and retrieve compiler statistics efficiently.createRunner
method in multiple runner classes (BasicRunnerFactory
,MultipleRunnerFactory
,NormalRunnerFactory
,WatchRunnerFactory
) to use thecreateStatsGetter
method instead of directly passing statistics. [1] [2] [3] [4] [5] [6] [7]Interface Changes:
IBasicRunnerOptions
to use a function returningTCompilerStatsCompilation
instead of directly using the type. [1] [2]Test Case Updates:
__STATS__
instead ofSTATS_JSON
to align with the new statistics handling approach. [1] [2] [3] [4] [5] [6]These changes improve the efficiency and consistency of how compiler statistics are accessed and used across different parts of the
rspack-test-tools
package.Checklist