Fix the test picker for a date library upgrade
Your task
An AI agent bumped a date library two major versions to silence a deprecation warning, fixed the three call sites it looked at, and reported "all tests pass". Green CI only covers what the tests exercise. So you list the date usage of every call site and match it against the breaking changes in the library's migration guide, to see where a new boundary test is owed.
An assistant wrote select_boundary_tests(call_sites, breaking_areas). It is in the editor. It has a bug. Find it and fix it.
Input and output:
call_sites: the usage inventory. Each entry ispath|tags, where tags is a comma separated list of usage patterns such asparse,format,timezoneordst. A file can appear in several entries, one per call site.breaking_areas: the usage patterns the migration guide says changed.- Return one entry per file that needs a boundary test, written
path:areas.
Rules the tests check:
- Split an entry on
|. Skip it unless it has exactly 2 parts and the path is not empty. - Split the tags on
,and trim whitespace from each one. Skip empty tags. Tags match exactly, case included. - A file's tags are all the tags from all of its entries.
- Trim each breaking area as well, and skip empty ones.
- A file needs a test when any of its tags is a breaking area. Its areas are the matching breaking areas, in the order they appear in
breaking_areas, each once, joined by,. - Sort the output by path, using plain string comparison. The path is used as given, not trimmed.
Examples
select_boundary_tests(call_sites: list[str], breaking_areas: list[str]) -> list[str]Example 1
Input
select_boundary_tests(["src/billing.ts|parse,arith", "src/report.ts|format", "src/user.ts|timezone,parse"], ["timezone", "parse"])Output
["src/billing.ts:parse", "src/user.ts:timezone,parse"]Example 2
Input
select_boundary_tests(["src/billing.ts|parse,arith"], [])Output
[]