-
Notifications
You must be signed in to change notification settings - Fork 72
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
refactor: port certificate-generation condition script to Rust #259
base: main
Are you sure you want to change the base?
Conversation
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.
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (2)
crates/wdk-build/src/cargo_make.rs:1041
- The error message 'WDRLocalTestCert already in WDRTestCertStore. Skipping certificate generation.' could be more informative. Consider including more context about why the certificate generation is being skipped.
anyhow::anyhow!("WDRLocalTestCert already in WDRTestCertStore. Skipping certificate generation.")
crates/wdk-build/src/cargo_make.rs:1024
- Ensure that the new behavior introduced in the
generate_certificate_condition_script
function is covered by tests.
pub fn generate_certificate_condition_script() -> anyhow::Result<()> {
crates/wdk-build/src/cargo_make.rs
Outdated
]) | ||
.arg(get_wdk_build_output_directory().join("WDRLocalTestCert.cer")) | ||
.output() | ||
.expect("Failed to run certmgr.exe."); |
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.
The error message 'Failed to run certmgr.exe.' could be more descriptive. Consider providing more context about what went wrong.
.expect("Failed to run certmgr.exe."); | |
.expect("Failed to run certmgr.exe with the provided arguments."); |
Copilot is powered by AI, so mistakes are possible. Review output carefully before use.
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.
@leon-xd I think the expect prints the Err variant contents, but doesn't print anything to do with the Command. It probably makes sense to print all the args here to make it more clear what command failed, since it will fail and then continue to try to run the task. Maybe do smth like:
let cert_save_location = get_wdk_build_output_directory().join("WDRLocalTestCert.cer");
let args = [
"-put",
"-s",
"WDRTestCertStore",
"-c",
"-n",
"WdrLocalTestCert",
cert_save_location.as_str()
];
let output = Command::new("certmgr")
.args(&args)
.output()
.unwrap_or_else(|| panic!("Failed to run 'certmgr.exe {}'", &args.join(" ")));
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.
@wmmc88 I ended up doing it slightly differently. cert_save_location is a PathBuf
which is impossible to reduce to a &str
without either an unwrap
after a conversion or a lossy str conversion. Given that it's possible for path strings to be non-UTF8 I figured keeping the lossy conversion until the unwrap was more complete, in case a developer's build path contains a non-UTF8 string.
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.
some minor comments, but good to merge after
crates/wdk-build/src/cargo_make.rs
Outdated
]) | ||
.arg(get_wdk_build_output_directory().join("WDRLocalTestCert.cer")) | ||
.output() | ||
.expect("Failed to run certmgr.exe."); |
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.
@leon-xd I think the expect prints the Err variant contents, but doesn't print anything to do with the Command. It probably makes sense to print all the args here to make it more clear what command failed, since it will fail and then continue to try to run the task. Maybe do smth like:
let cert_save_location = get_wdk_build_output_directory().join("WDRLocalTestCert.cer");
let args = [
"-put",
"-s",
"WDRTestCertStore",
"-c",
"-n",
"WdrLocalTestCert",
cert_save_location.as_str()
];
let output = Command::new("certmgr")
.args(&args)
.output()
.unwrap_or_else(|| panic!("Failed to run 'certmgr.exe {}'", &args.join(" ")));
Ported last Duckscript condition script to Rust
closes #93