Skip to content

Commit c974b77

Browse files
authored
[update_lib] fix hard_deps resolution and fix commit not to miss test data (RustPython#7058)
* [update_lib] fix hard_dep not to unclude other tests * [update_lib] commit test data
1 parent dc2d235 commit c974b77

2 files changed

Lines changed: 22 additions & 14 deletions

File tree

scripts/update_lib/cmd_quick.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def quick(
8080
mark_failure: bool = False,
8181
verbose: bool = True,
8282
skip_build: bool = False,
83-
) -> None:
83+
) -> list[pathlib.Path]:
8484
"""
8585
Process a file or directory: migrate + auto-mark.
8686
@@ -91,10 +91,15 @@ def quick(
9191
mark_failure: Add @expectedFailure to ALL failing tests
9292
verbose: Print progress messages
9393
skip_build: Skip cargo build, use pre-built binary
94+
95+
Returns:
96+
List of extra paths (data dirs, hard deps) that were copied/migrated.
9497
"""
9598
from update_lib.cmd_auto_mark import auto_mark_directory, auto_mark_file
9699
from update_lib.cmd_migrate import patch_directory, patch_file
97100

101+
extra_paths: list[pathlib.Path] = []
102+
98103
# Determine lib_path and whether to migrate
99104
if is_lib_path(src_path):
100105
no_migrate = True
@@ -128,6 +133,7 @@ def quick(
128133
patch_directory(dep_src, dep_lib, verbose=False)
129134
else:
130135
patch_file(dep_src, dep_lib, verbose=False)
136+
extra_paths.append(dep_lib)
131137

132138
# Copy data directories (no migration)
133139
import shutil
@@ -146,6 +152,7 @@ def quick(
146152
else:
147153
data_lib.parent.mkdir(parents=True, exist_ok=True)
148154
shutil.copy2(data_src, data_lib)
155+
extra_paths.append(data_lib)
149156

150157
# Step 2: Auto-mark
151158
if not no_auto_mark:
@@ -174,6 +181,8 @@ def quick(
174181
print(f"Added expectedFailure to {num_added} tests")
175182
print(f"Removed expectedFailure from {num_removed} tests")
176183

184+
return extra_paths
185+
177186

178187
def get_cpython_version(cpython_dir: pathlib.Path) -> str:
179188
"""Get CPython version from git tag."""
@@ -411,13 +420,14 @@ def main(argv: list[str] | None = None) -> int:
411420
test_lib_path = parse_lib_path(test_src)
412421
test_paths_for_commit.append(test_lib_path)
413422

414-
quick(
423+
extra = quick(
415424
test_src,
416425
no_migrate=not args.migrate,
417426
no_auto_mark=not args.auto_mark,
418427
mark_failure=args.mark_failure,
419428
skip_build=not args.build,
420429
)
430+
hard_deps_for_commit.extend(extra)
421431

422432
test_paths = test_paths_for_commit
423433
else:
@@ -426,13 +436,14 @@ def main(argv: list[str] | None = None) -> int:
426436
parse_lib_path(src_path) if not is_lib_path(src_path) else src_path
427437
)
428438

429-
quick(
439+
extra = quick(
430440
src_path,
431441
no_migrate=not args.migrate,
432442
no_auto_mark=not args.auto_mark,
433443
mark_failure=args.mark_failure,
434444
skip_build=not args.build,
435445
)
446+
hard_deps_for_commit.extend(extra)
436447
test_paths = [test_path]
437448

438449
# Step 3: Git commit

scripts/update_lib/deps.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1154,18 +1154,15 @@ def get_test_dependencies(
11541154

11551155
# Convert imports to paths (deps)
11561156
for imp in all_imports:
1157-
# Check if it's a test file (test_*) or support module
1157+
# Skip other test modules (test_*) - they are independently managed
1158+
# via their own update_lib entry. Only support/helper modules
1159+
# (e.g., string_tests, mapping_tests) should be treated as hard deps.
11581160
if imp.startswith("test_"):
1159-
# It's a test, resolve to test path
1160-
dep_path = test_path.parent / f"{imp}.py"
1161-
if not dep_path.exists():
1162-
dep_path = test_path.parent / imp
1163-
else:
1164-
# Support module like string_tests, lock_tests, encoded_modules
1165-
# Check file first, then directory
1166-
dep_path = test_path.parent / f"{imp}.py"
1167-
if not dep_path.exists():
1168-
dep_path = test_path.parent / imp
1161+
continue
1162+
1163+
dep_path = test_path.parent / f"{imp}.py"
1164+
if not dep_path.exists():
1165+
dep_path = test_path.parent / imp
11691166

11701167
if dep_path.exists() and dep_path not in result["hard_deps"]:
11711168
result["hard_deps"].append(dep_path)

0 commit comments

Comments
 (0)