-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Added a test updater tool #6709
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
Changes from 1 commit
0a6ec87
0fe8ac2
0a2ea1b
f8ff03e
965c27a
f6b69b7
e9265bd
28ef3b4
61e485b
fdb476d
5b9ae5c
db005d4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,73 @@ | ||||||||||||||||||||||||||||||||||
| #!/bin/bash | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| usage() { echo "Usage: $0 [-c <cpython path>] [-r <rustpython path>] [-u <copy untracked test>]" 1>&2; exit 1; } | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| cpython_path="" | ||||||||||||||||||||||||||||||||||
| rpython_path="" | ||||||||||||||||||||||||||||||||||
| copy_untracked=false | ||||||||||||||||||||||||||||||||||
| libraries=() | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| while [[ $# -gt 0 ]]; do | ||||||||||||||||||||||||||||||||||
| case "$1" in | ||||||||||||||||||||||||||||||||||
| -c|--cpython-path) | ||||||||||||||||||||||||||||||||||
| cpython_path="$2" | ||||||||||||||||||||||||||||||||||
| shift 2 | ||||||||||||||||||||||||||||||||||
| ;; | ||||||||||||||||||||||||||||||||||
| -r|--rpython-path) | ||||||||||||||||||||||||||||||||||
| rpython_path="$2" | ||||||||||||||||||||||||||||||||||
| shift 2 | ||||||||||||||||||||||||||||||||||
| ;; | ||||||||||||||||||||||||||||||||||
| -u|--copy-untracked) | ||||||||||||||||||||||||||||||||||
| copy_untracked=true | ||||||||||||||||||||||||||||||||||
| shift | ||||||||||||||||||||||||||||||||||
| ;; | ||||||||||||||||||||||||||||||||||
| *) | ||||||||||||||||||||||||||||||||||
| libraries+=("$1") | ||||||||||||||||||||||||||||||||||
| shift | ||||||||||||||||||||||||||||||||||
| ;; | ||||||||||||||||||||||||||||||||||
| esac | ||||||||||||||||||||||||||||||||||
| done | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| cpython_path="$cpython_path/Lib/test" | ||||||||||||||||||||||||||||||||||
| rpython_path="$rpython_path/Lib/test" | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| if [[ ${#libraries[@]} -eq 0 ]]; then | ||||||||||||||||||||||||||||||||||
| libraries=$(find ${cpython_path} -type f -printf "%P\n") | ||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||
| echo "libraries is ${libraries}" | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| for lib in "${arr[@]}" | ||||||||||||||||||||||||||||||||||
| do | ||||||||||||||||||||||||||||||||||
| cpython_file="$cpython_path/$lib" | ||||||||||||||||||||||||||||||||||
| rpython_file="$rpython_path/$lib" | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| if [[ $files_equal $cpython_file $rpython_file -eq 0 ]]; then | ||||||||||||||||||||||||||||||||||
| continue | ||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||
|
Comment on lines
+132
to
+138
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing error handling and variable quoting.
Suggested improvements else
echo "Using lib_updater to update $lib"
- ./scripts/lib_updater.py --from $clib_path --to $rlib_path -o $rlib_path
+ if ! ./scripts/lib_updater.py --from "$clib_path" --to "$rlib_path" -o "$rlib_path"; then
+ echo "Warning: lib_updater.py failed for $lib" >&2
+ fi
fi
- if [[ $annotate && -f "$rlib_path" && $(basename -- "$rlib_path") == test_*.py ]]; then
- annotate_lib $lib $rlib_path
+ if [[ $annotate == true && -f "$rlib_path" && $(basename -- "$rlib_path") == test_*.py ]]; then
+ annotate_lib "$lib" "$rlib_path"
fi📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| if [[ ! -f $cpython_file ]]; then | ||||||||||||||||||||||||||||||||||
| if $copy_untracked then | ||||||||||||||||||||||||||||||||||
| echo "Test file $lib missing. Copying..." | ||||||||||||||||||||||||||||||||||
| cp "$cpython_file" "$rpython_file" | ||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||||||||||
| echo "Updating $lib..." | ||||||||||||||||||||||||||||||||||
| ./scripts/lib_updater.py --from ${rpython_path}/Lib/test/$lib --to ${rpython_path}/Lib/test/$lib | ||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| cargo run | ||||||||||||||||||||||||||||||||||
| done | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| files_equal() { | ||||||||||||||||||||||||||||||||||
| file1=$1 | ||||||||||||||||||||||||||||||||||
| file2=$2 | ||||||||||||||||||||||||||||||||||
| cmp --silent $file1 $file2 && files_equal=0 || files_equal=1 | ||||||||||||||||||||||||||||||||||
| return $files_equal | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing validation for required arguments and option values.
Several issues with argument parsing:
-t,-j,-c,-rdon't validate that$2exists beforeshift 2, which can silently consume the next flag.cpython_pathis provided when not using--update-skipped.timeout/num_jobsare valid integers.Suggested validation pattern
Add post-parsing validation:
🤖 Prompt for AI Agents