Skip to content
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

[#98] Clean up entrypoint CLI #366

Merged

Conversation

orecham
Copy link
Contributor

@orecham orecham commented Sep 3, 2024

Notes for Reviewer

Refactoring of commands.rs:

  • add abstraction to make logic testable
  • remove duplicate code
  • utilize anyhow since errors only require printing, no unique error handling
  • fix bug where args were not forwarded to subcommands
  • remove need for --dev flag
    • dev builds will instead have their build type appended (e.g. foo-debug or foo-release)
  • utilize cargo_metadata to more reliably determine the target dir to search for dev builds

Pre-Review Checklist for the PR Author

  1. Add sensible notes for the reviewer
  2. PR title is short, expressive and meaningful
  3. Relevant issues are linked in the References section
  4. Every source code file has a copyright header with SPDX-License-Identifier: Apache-2.0 OR MIT
  5. Branch follows the naming format (iox2-123-introduce-posix-ipc-example)
  6. Commits messages are according to this guideline
  7. Tests follow the best practice for testing
  8. Changelog updated in the unreleased section including API breaking changes
  9. Assign PR to reviewer
  10. All checks have passed (except task-list-completed)

Checklist for the PR Reviewer

  • Commits are properly organized and messages are according to the guideline
  • Unit tests have been written for new behavior
  • Public API is documented
  • PR title describes the changes

Post-review Checklist for the PR Author

  1. All open points are addressed and tracked via issues

References

Relates #98

@orecham orecham force-pushed the iox2-98-cleanup-iox-entrypoint-cli branch from f082455 to a503b85 Compare September 3, 2024 14:39
Copy link

codecov bot commented Sep 3, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 79.48%. Comparing base (b4b8d9c) to head (e83a259).
Report is 8 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #366   +/-   ##
=======================================
  Coverage   79.48%   79.48%           
=======================================
  Files         193      193           
  Lines       22716    22716           
=======================================
+ Hits        18055    18056    +1     
+ Misses       4661     4660    -1     

see 4 files with indirect coverage changes

@orecham orecham force-pushed the iox2-98-cleanup-iox-entrypoint-cli branch from a503b85 to 8536d97 Compare September 3, 2024 15:01
Copy link
Member

@elBoberido elBoberido left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good in general. Just a few remarks.

iceoryx2-cli/iox2/src/commands.rs Show resolved Hide resolved
iceoryx2-cli/iox2/src/commands.rs Outdated Show resolved Hide resolved
iceoryx2-cli/iox2/src/commands.rs Outdated Show resolved Hide resolved
@elfenpiff elfenpiff changed the title Clean up entrypoint CLI [#98] Clean up entrypoint CLI Sep 4, 2024
if let Some(arguments) = args {
command.args(arguments);
#[test]
fn test_paths() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could actually let the test work in the real environment. Take a look at iceoryx2-bb/posix/tests/file_tests.rs. Here, I utilize the iceoryx2_bb_posix::config::test_directory() call, which provides a platform-independent location to a directory where you can create files and directories for testing.

This would allow you to get rid of the traits and the generic parameters.

What do you think?

@orecham orecham force-pushed the iox2-98-cleanup-iox-entrypoint-cli branch 9 times, most recently from e3b1b25 to 67f46a2 Compare September 11, 2024 07:40
use std::io::Write;

#[cfg(windows)]
const MINIMAL_EXE: &[u8] = include_bytes!("minimal.exe");
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@elfenpiff @elBoberido This is the easiest way I could test the execution on windows. Thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am fine with it - I would rename it to no-op.exe since it is a bit more descriptive but this is not a must.

@@ -173,6 +173,34 @@ macro_rules! assert_that {
}
}
};
($lhs:expr, contains_match |$element:ident| $predicate:expr) => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@elfenpiff To use assert_that I had to extend it with this. Thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like it. But a look at this file reminds me that we have to start to document this at some point ...

thiserror = { workspace = true }
clap = { workspace = true }
human-panic = { workspace = true }
cargo_metadata = { version = "0.18.1" }
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this and tempfile be moved to the workspace Cargo.toml? I left them here since I doubt they will be used elsewhere.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. The idea is that the whole workspace has unified and compatible dependencies. Therefore, everything has to be in the workspace and is then used with workspace = true by the individual crates of that workspace.

@orecham orecham force-pushed the iox2-98-cleanup-iox-entrypoint-cli branch 5 times, most recently from 9e719f8 to ff0ce66 Compare September 11, 2024 08:04
@@ -173,6 +173,34 @@ macro_rules! assert_that {
}
}
};
($lhs:expr, contains_match |$element:ident| $predicate:expr) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like it. But a look at this file reminds me that we have to start to document this at some point ...

thiserror = { workspace = true }
clap = { workspace = true }
human-panic = { workspace = true }
cargo_metadata = { version = "0.18.1" }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. The idea is that the whole workspace has unified and compatible dependencies. Therefore, everything has to be in the workspace and is then used with workspace = true by the individual crates of that workspace.

use std::io::Write;

#[cfg(windows)]
const MINIMAL_EXE: &[u8] = include_bytes!("minimal.exe");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am fine with it - I would rename it to no-op.exe since it is a bit more descriptive but this is not a must.

iceoryx2-cli/iox2/tests/commands_tests.rs Show resolved Hide resolved
@orecham orecham force-pushed the iox2-98-cleanup-iox-entrypoint-cli branch 2 times, most recently from d895d19 to c6cb7d4 Compare September 11, 2024 20:28
@orecham orecham force-pushed the iox2-98-cleanup-iox-entrypoint-cli branch 2 times, most recently from 3e254d8 to 89355a0 Compare September 12, 2024 09:28
Copy link
Member

@elBoberido elBoberido left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Just one question regarding a potential ambiguous constant name.

iceoryx2-cli/iox2/src/commands.rs Outdated Show resolved Hide resolved
@orecham orecham force-pushed the iox2-98-cleanup-iox-entrypoint-cli branch from 89355a0 to e83a259 Compare September 12, 2024 13:01
@orecham orecham merged commit 2d1f01d into eclipse-iceoryx:main Sep 12, 2024
54 of 55 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants