-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add additional package args to ROS test #12
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -83,7 +83,7 @@ def command(): | |||||||||||||||||||||||||||||||||||||||||||||||||
| command() | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| @ros.command(name="test") | ||||||||||||||||||||||||||||||||||||||||||||||||||
| @click.option("--package", type=str, default=None, help="The package to test") | ||||||||||||||||||||||||||||||||||||||||||||||||||
| @click.option("--package", "-p", type=str, multiple=True, help="The package(s) to test") | ||||||||||||||||||||||||||||||||||||||||||||||||||
| @click.option("--results-dir", type=Path, default=None) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| @click.option( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| "--watch", type=bool, is_flag=True, default=False, help="Should we watch for changes?" | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -101,30 +101,46 @@ def command(): | |||||||||||||||||||||||||||||||||||||||||||||||||
| default=2, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| help="Number of times to retest until pass", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| @click.option( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| "--include-dependents", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| type=bool, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| is_flag=True, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| default=False, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| help="Also test packages that depend on changed packages (used with --changed)", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| @click.argument("args", nargs=-1) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| def test( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| package: str, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| package: List[str], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| results_dir: Path, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| watch: bool, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| build: bool, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| retest_until_pass: int, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| include_dependents: bool, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| args: List[str], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ): | ||||||||||||||||||||||||||||||||||||||||||||||||||
| """Runs colcon test on all ROS packages""" | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| env = get_ros_env() | ||||||||||||||||||||||||||||||||||||||||||||||||||
| args_str = " ".join(args) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| # Some args only apply to colcon test | ||||||||||||||||||||||||||||||||||||||||||||||||||
| args_str_test = args_str | ||||||||||||||||||||||||||||||||||||||||||||||||||
| args_str_build = args_str | ||||||||||||||||||||||||||||||||||||||||||||||||||
| if package: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| args_str_test += f" --packages-select {package}" | ||||||||||||||||||||||||||||||||||||||||||||||||||
| args_str_build += f" --package {package}" | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| packages_to_test = list(package) if package else [] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| packages_str = " ".join(packages_to_test) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| if packages_to_test: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| if include_dependents: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| args_str_test += f" --packages-up-to {packages_str}" | ||||||||||||||||||||||||||||||||||||||||||||||||||
| else: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| args_str_test += f" --packages-select {packages_str}" | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| def command(): | ||||||||||||||||||||||||||||||||||||||||||||||||||
| if build: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| args_str_build = args_str | ||||||||||||||||||||||||||||||||||||||||||||||||||
| if packages_to_test: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| for pkg in packages_to_test: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| args_str_build += f" --package {pkg}" | ||||||||||||||||||||||||||||||||||||||||||||||||||
| call(" ".join(["platform ros build", args_str_build])) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+138
to
142
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. Build step only builds the last package; construct a single colcon build with proper selection. Passing Apply this diff to build in-place (avoids re-invoking our CLI and ensures correct selection): - if build:
- args_str_build = args_str
- if packages_to_test:
- for pkg in packages_to_test:
- args_str_build += f" --package {pkg}"
- call(" ".join(["platform ros build", args_str_build]))
+ if build:
+ args_str_build = args_str
+ if packages_to_test:
+ packages_str = " ".join(packages_to_test)
+ if include_dependents:
+ args_str_build += f" --packages-above-and-dependencies {packages_str}"
+ else:
+ args_str_build += f" --packages-select {packages_str}"
+ call(
+ " ".join(
+ [
+ "colcon build",
+ "--merge-install",
+ "--symlink-install",
+ f"--install-base /opt/greenroom/{env['PLATFORM_MODULE']}",
+ args_str_build,
+ ]
+ )
+ )Alternatively, update 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| p1 = call( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| " ".join( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| [ | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -148,7 +164,8 @@ def command(): | |||||||||||||||||||||||||||||||||||||||||||||||||
| p1, p2 = command() | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| if results_dir and results_dir.exists(): | ||||||||||||||||||||||||||||||||||||||||||||||||||
| collect_xunit_xmls(results_dir, package) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| for pkg in packages_to_test: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| collect_xunit_xmls(results_dir, pkg) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| exit(max([p1.returncode, p2.returncode])) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
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.
🧩 Analysis chain
Dependents vs dependencies:
--packages-up-tois the wrong selector for “dependents”.--packages-up-toselects the package(s) and their dependencies. To include packages that depend on the selected ones, use--packages-aboveor--packages-above-and-dependencies. Current code will test dependencies, not dependents. This is a logic bug that will miss intended targets.Apply this diff:
Please confirm the intended semantics and that
--changedis implemented elsewhere (your help text references it but it’s not defined here). Run:Also verify colcon selectors:
Also applies to: 130-134
🏁 Script executed:
Length of output: 30
🌐 Web query:
💡 Result:
--packages-select <pkg...>: selects only the named package(s). [1]
--packages-up-to <pkg...>: selects the named package(s) and all their recursive dependencies (i.e., packages they depend on). [1]
--packages-above <pkg...>: selects the named package(s) and all packages that (recursively) depend on them (i.e., their dependents). [1]
--packages-above-and-dependencies <pkg...>: selects the named package(s), all packages that depend on them, and those dependents' recursive dependencies. (Equivalent to union of --packages-above and their dependencies.) [1]
Reference: colcon package selection arguments. [1] https://colcon.readthedocs.io/en/main/reference/package-selection-arguments.html
🏁 Script executed:
Length of output: 7827
Fix dependents logic in
ros testThe
--include-dependentsflag currently:--packages-up-to, which selects dependencies rather than dependents.--changedoption in its help text.Apply:
help="Also test packages that depend on the selected packages".--packages-up-towith--packages-above-and-dependencieswheninclude_dependentsis true.🤖 Prompt for AI Agents