-
Notifications
You must be signed in to change notification settings - Fork 0
Phase 3: core/shell/proxy #140
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
91013cd
initial implementation
teresa-ortega dd44b6d
Add test file
teresa-ortega e9c7343
Apply shlex.quote to positional args to handle paths with spaces
teresa-ortega cd71b24
Extended documentation
teresa-ortega 07be477
Add dry run behaviour
teresa-ortega f0a8f54
Fix pytest problems
teresa-ortega 1ceb415
Add new test
teresa-ortega 303b756
Set dry-run default to True and Raise NotImplementedError when dry_ru…
teresa-ortega d949e0b
Add default impementation in the context file
teresa-ortega File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| # Copyright 2026 Ekumen, Inc. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| """Shell subpackage for the lambkin SDK. | ||
|
|
||
| Provides shell abstractions for executing system commands within benchmarks. | ||
| Each shell implementation exposes the same interface, allowing benchmarks to | ||
| switch between dry-run and real execution without changing any benchmark code. | ||
| """ | ||
|
|
||
| from .proxy import ShellProxy | ||
|
|
||
| __all__ = [ | ||
| "ShellProxy", | ||
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| # Copyright 2026 Ekumen, Inc. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| """Unit tests for the shell class in lambkin.core.shell.""" | ||
|
|
||
| import pytest | ||
|
|
||
| from lambkin.core.shell import ShellProxy | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def shell(): | ||
| """Return a fresh ShellProxy instance for each test.""" | ||
| return ShellProxy(dry_run=True) | ||
|
|
||
|
|
||
| def test_simple_command(shell, capsys): | ||
| """Test that a simple single-level command is printed correctly.""" | ||
| shell.ros2.launch("beluga.launch.xml") | ||
| assert capsys.readouterr().out == "[CMD]: ros2 launch beluga.launch.xml\n" | ||
|
|
||
|
|
||
| def test_chained_command(shell, capsys): | ||
| """Test that chained attribute access builds the command word by word.""" | ||
| shell.ros2.bag.play("my_bag") | ||
| assert capsys.readouterr().out == "[CMD]: ros2 bag play my_bag\n" | ||
|
|
||
|
|
||
| def test_multiple_args(shell, capsys): | ||
| """Test that multiple positional arguments are appended in order.""" | ||
| shell.ros2.bag.play("my_bag", "--clock", "-r", "1.0") | ||
| assert capsys.readouterr().out == "[CMD]: ros2 bag play my_bag --clock -r 1.0\n" | ||
|
|
||
|
|
||
| def test_kwarg_becomes_flag(shell, capsys): | ||
|
teresa-ortega marked this conversation as resolved.
|
||
| """Test that keyword arguments are converted to --flag value pairs.""" | ||
| shell.evo_ape.bag2("output.mcap", save_results="out.zip") | ||
| assert ( | ||
| capsys.readouterr().out | ||
| == "[CMD]: evo_ape bag2 output.mcap --save-results out.zip\n" | ||
| ) | ||
|
|
||
|
|
||
| def test_arbitrary_tool(shell, capsys): | ||
| """Test that any top-level tool name works without hardcoding.""" | ||
| shell.evo.traj("output.mcap") | ||
| assert capsys.readouterr().out == "[CMD]: evo traj output.mcap\n" | ||
|
|
||
|
|
||
| def test_kwarg_true_is_standalone_flag(shell, capsys): | ||
| """Test that a boolean True kwarg produces a standalone flag.""" | ||
| shell.ros2.bag.play("my_bag", clock=True) | ||
| assert capsys.readouterr().out == "[CMD]: ros2 bag play my_bag --clock\n" | ||
|
|
||
|
|
||
| def test_kwarg_false_is_ignored(shell, capsys): | ||
| """Test that a boolean False kwarg is ignored.""" | ||
| shell.ros2.bag.play("my_bag", clock=False) | ||
| assert capsys.readouterr().out == "[CMD]: ros2 bag play my_bag\n" | ||
|
|
||
|
|
||
| def test_path_with_spaces(shell, capsys): | ||
| """Test that positional args with spaces are correctly quoted.""" | ||
| shell.ros2.bag.play("/my path/to/bag.mcap") | ||
| assert capsys.readouterr().out == "[CMD]: ros2 bag play '/my path/to/bag.mcap'\n" | ||
|
|
||
|
|
||
| def test_kwarg_multiple_underscores_converted(shell, capsys): | ||
| """Test that multiple underscores in kwarg names are converted to dashes.""" | ||
| shell.evo_ape.bag2("output.mcap", save_all_results="out.zip") | ||
| assert ( | ||
| capsys.readouterr().out | ||
| == "[CMD]: evo_ape bag2 output.mcap --save-all-results out.zip\n" | ||
| ) | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.