Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the unit test builder to retry finding test files from the project root if they are not found under the project source root, aligning with the builder's schema. The findTests function is refactored to use a helper collectTests to perform this search. Feedback on the changes points out a redundant ternary check when calling glob, as dynamicPatterns is guaranteed to be non-empty at that point.
…ect root The `include` option is documented by the builder schema as relative to the project root, but patterns were only ever resolved from the project source root. A library that keeps a secondary entry point beside `src` had no supported spelling that reached its specs, and the run still reported success. A pattern that matches nothing under the source root is now retried from the project root. A pattern that already matches is not retried, so an existing pattern keeps matching exactly what it matches today. A project rooted at the workspace root is never retried, since that would search every project. Closes angular#33467
689f7b7 to
580323c
Compare
|
Thank you for the contribution. For existing library projects, using parent traversal is the recommended solution: However, for the in-development new library build system. The path constraints for secondary entrypoints will no longer be present. This will allow all source files to reside within the actual project source root in the future. |
|
@clydin thanks, that is clear. Should have looked for that answer before writing code. Want me to send small PR fixing two descriptions in |
|
Already done and merged but thank you for the offer. |
PR Checklist
PR Type
What is the current behavior?
Issue Number: #33467
Schema says
includeis relative to project root. Code resolves it from source root. So for a library with secondary entry point next tosrcnothing reaches it -my-sub-package/**/*.spec.ts,./my-sub-package/**/*.spec.ts,my-sub-package/my-sub.spec.ts,projects/my-lib/my-sub-package/**/*.spec.tsall find zero files and run still says success. Happens with no config too,ng generate librarywrites noinclude.What is the new behavior?
Pattern that matched nothing under source root gets retried from project root. Pattern that already matched is not retried, so
**/*.spec.tsstays where it is and does not start picking up specs outsidesrc. Project rooted at workspace root is never retried, that would search every project.Checked on generated workspace with library, secondary entry point and an
e2e/spec. Four spellings above fixed plus reporter's["**/*.spec.ts", "my-sub-package/**/*.spec.ts"]. Six spellings that work today return same files.e2e/spec not picked up before or after.Cost is globbing per pattern instead of batching, needed to tell unmatched from matched. On library with 302 specs medians are 451ms before and 447ms after, spread between rounds is wider than that.
builders/karma/find-tests.tsuntouched, it calls through without new argument so karma keeps current behavior.Three of five new cases fail without the change. Other two pin what must not move.
Does this PR introduce a breaking change?