Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,12 @@ jobs:
- name: Package Examples (via Cargo Make)
run: cargo make --cwd ./examples package-driver-flow +${{ matrix.rust_toolchain }} --locked --profile ${{ matrix.cargo_profile }} --target ${{ matrix.target_triple.name }}

- name: Build Tests (via Cargo Make)
run: cargo make --cwd ./tests build +${{ matrix.rust_toolchain }} --locked --profile ${{ matrix.cargo_profile }} --target ${{ matrix.target_triple.name }}

- name: Package Tests (via Cargo Make)
run: cargo make --cwd ./tests package-driver-flow +${{ matrix.rust_toolchain }} --locked --profile ${{ matrix.cargo_profile }} --target ${{ matrix.target_triple.name }}

# Run cargo-wdk on examples
- name: Install cargo-wdk
run: cargo +${{ matrix.rust_toolchain }} install --path=crates/cargo-wdk --profile ${{ matrix.cargo_profile }} --locked --force
Expand Down
10 changes: 9 additions & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,13 @@ jobs:
with:
tool: [email protected]

- name: Run Cargo Test
- name: Install Cargo Make
uses: taiki-e/install-action@v2
with:
tool: cargo-make

- name: Run Cargo Test (workspace)
run: cargo +${{ matrix.rust_toolchain }} test --locked --profile ${{ matrix.cargo_profile }} --target ${{ matrix.target_triple.name }} --all-features

- name: Run Cargo Test (Top-Level tests Folder via Cargo Make)
run: cargo make --cwd ./tests test +${{ matrix.rust_toolchain }} --locked --profile ${{ matrix.cargo_profile }} --target ${{ matrix.target_triple.name }}
7 changes: 6 additions & 1 deletion crates/cargo-wdk/src/actions/build/build_task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ pub struct BuildTask<'a> {
verbosity_level: clap_verbosity_flag::Verbosity,
manifest_path: PathBuf,
command_exec: &'a CommandExec,
working_dir: &'a Path,
}

impl<'a> BuildTask<'a> {
Expand Down Expand Up @@ -70,6 +71,7 @@ impl<'a> BuildTask<'a> {
verbosity_level,
manifest_path,
command_exec,
working_dir,
})
}

Expand Down Expand Up @@ -106,7 +108,10 @@ impl<'a> BuildTask<'a> {
.iter()
.map(std::string::String::as_str)
.collect::<Vec<&str>>();
self.command_exec.run("cargo", &args, None)?;
// Run cargo build from the provided working directory so that workspace
// resolution and relative paths behave as expected for the selected package
self.command_exec
.run("cargo", &args, None, Some(self.working_dir))?;
debug!("Done");
Ok(())
}
Expand Down
18 changes: 9 additions & 9 deletions crates/cargo-wdk/src/actions/build/package_task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub struct PackageTaskParams<'a> {
pub driver_model: DriverConfig,
}

/// Suports low level driver packaging operations
/// Supports low level driver packaging operations
pub struct PackageTask<'a> {
package_name: String,
verify_signature: bool,
Expand Down Expand Up @@ -301,7 +301,7 @@ impl<'a> PackageTask<'a> {
if !wdf_version_flags.is_empty() {
args.append(&mut wdf_version_flags.iter().map(String::as_str).collect());
}
if let Err(e) = self.command_exec.run("stampinf", &args, None) {
if let Err(e) = self.command_exec.run("stampinf", &args, None, None) {
return Err(PackageTaskError::StampinfCommand(e));
}
Ok(())
Expand All @@ -320,7 +320,7 @@ impl<'a> PackageTask<'a> {
"/uselocaltime",
];

if let Err(e) = self.command_exec.run("inf2cat", &args, None) {
if let Err(e) = self.command_exec.run("inf2cat", &args, None, None) {
return Err(PackageTaskError::Inf2CatCommand(e));
}

Expand All @@ -344,7 +344,7 @@ impl<'a> PackageTask<'a> {
debug!("Checking if self signed certificate exists in WDRTestCertStore store.");
let args = ["-s", WDR_TEST_CERT_STORE];

match self.command_exec.run("certmgr.exe", &args, None) {
match self.command_exec.run("certmgr.exe", &args, None, None) {
Ok(output) if output.status.success() => String::from_utf8(output.stdout).map_or_else(
|e| Err(PackageTaskError::VerifyCertExistsInStoreInvalidCommandOutput(e)),
|stdout| Ok(stdout.contains(WDR_LOCAL_TEST_CERT)),
Expand All @@ -370,7 +370,7 @@ impl<'a> PackageTask<'a> {
&format!("CN={WDR_LOCAL_TEST_CERT}"), // FIXME: this should be a parameter
&cert_path,
];
if let Err(e) = self.command_exec.run("makecert", &args, None) {
if let Err(e) = self.command_exec.run("makecert", &args, None, None) {
return Err(PackageTaskError::CertGenerationInStoreCommand(e));
}
Ok(())
Expand All @@ -388,7 +388,7 @@ impl<'a> PackageTask<'a> {
WDR_LOCAL_TEST_CERT,
&cert_path,
];
if let Err(e) = self.command_exec.run("certmgr.exe", &args, None) {
if let Err(e) = self.command_exec.run("certmgr.exe", &args, None, None) {
return Err(PackageTaskError::CreateCertFileFromStoreCommand(e));
}
Ok(())
Expand Down Expand Up @@ -430,7 +430,7 @@ impl<'a> PackageTask<'a> {
"SHA256",
&driver_binary_file_path,
];
if let Err(e) = self.command_exec.run("signtool", &args, None) {
if let Err(e) = self.command_exec.run("signtool", &args, None, None) {
return Err(PackageTaskError::DriverBinarySignCommand(e));
}
Ok(())
Expand All @@ -448,7 +448,7 @@ impl<'a> PackageTask<'a> {
let args = ["verify", "/v", "/pa", &driver_binary_file_path];
// TODO: Differentiate between command exec failure and signature verification
// failure
if let Err(e) = self.command_exec.run("signtool", &args, None) {
if let Err(e) = self.command_exec.run("signtool", &args, None, None) {
return Err(PackageTaskError::DriverBinarySignVerificationCommand(e));
}
Ok(())
Expand Down Expand Up @@ -486,7 +486,7 @@ impl<'a> PackageTask<'a> {
}
args.push(&inf_path);

if let Err(e) = self.command_exec.run("infverif", &args, None) {
if let Err(e) = self.command_exec.run("infverif", &args, None, None) {
return Err(PackageTaskError::InfVerificationCommand(e));
}

Expand Down
55 changes: 33 additions & 22 deletions crates/cargo-wdk/src/actions/build/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2429,13 +2429,14 @@ impl TestSetupPackageExpectations for TestBuildAction {
.withf(
move |command: &str,
args: &[&str],
_env_vars: &Option<&HashMap<&str, &str>>|
_env_vars: &Option<&HashMap<&str, &str>>,
_working_dir: &Option<&Path>|
-> bool {
command == expected_cargo_command && args == expected_cargo_build_args
},
)
.once()
.returning(move |_, _, _| Ok(expected_output.clone()));
.returning(move |_, _, _, _| Ok(expected_output.clone()));
self
}

Expand Down Expand Up @@ -2720,7 +2721,8 @@ impl TestSetupPackageExpectations for TestBuildAction {
.withf(
move |command: &str,
args: &[&str],
_env_vars: &Option<&HashMap<&str, &str>>|
_env_vars: &Option<&HashMap<&str, &str>>,
_working_dir: &Option<&Path>|
-> bool {
println!("command: {command}, args: {args:?}");
println!(
Expand All @@ -2731,7 +2733,7 @@ impl TestSetupPackageExpectations for TestBuildAction {
},
)
.once()
.returning(move |_, _, _| match override_output.clone() {
.returning(move |_, _, _, _| match override_output.clone() {
Some(output) => match output.status.code() {
Some(0) => Ok(Output {
status: ExitStatus::from_raw(0),
Expand Down Expand Up @@ -2786,7 +2788,8 @@ impl TestSetupPackageExpectations for TestBuildAction {
.withf(
move |command: &str,
args: &[&str],
_env_vars: &Option<&HashMap<&str, &str>>|
_env_vars: &Option<&HashMap<&str, &str>>,
_working_dir: &Option<&Path>|
-> bool {
println!("command: {command}, args: {args:?}");
println!(
Expand All @@ -2797,7 +2800,7 @@ impl TestSetupPackageExpectations for TestBuildAction {
},
)
.once()
.returning(move |_, _, _| match override_output.clone() {
.returning(move |_, _, _, _| match override_output.clone() {
Some(output) => match output.status.code() {
Some(0) => Ok(Output {
status: ExitStatus::from_raw(0),
Expand Down Expand Up @@ -2825,13 +2828,14 @@ impl TestSetupPackageExpectations for TestBuildAction {
.withf(
move |command: &str,
args: &[&str],
_env_vars: &Option<&HashMap<&str, &str>>|
_env_vars: &Option<&HashMap<&str, &str>>,
_working_dir: &Option<&Path>|
-> bool {
command == expected_certmgr_command && args == expected_certmgr_args
},
)
.once()
.returning(move |_, _, _| match override_output.clone() {
.returning(move |_, _, _, _| match override_output.clone() {
Some(output) => match output.status.code() {
Some(0) => Ok(Output {
status: ExitStatus::from_raw(0),
Expand Down Expand Up @@ -2875,13 +2879,14 @@ impl TestSetupPackageExpectations for TestBuildAction {
.withf(
move |command: &str,
args: &[&str],
_env_vars: &Option<&HashMap<&str, &str>>|
_env_vars: &Option<&HashMap<&str, &str>>,
_working_dir: &Option<&Path>|
-> bool {
command == expected_certmgr_command && args == expected_certmgr_args
},
)
.once()
.returning(move |_, _, _| match override_output.clone() {
.returning(move |_, _, _, _| match override_output.clone() {
Some(output) => match output.status.code() {
Some(0) => Ok(Output {
status: ExitStatus::from_raw(0),
Expand Down Expand Up @@ -2923,13 +2928,14 @@ impl TestSetupPackageExpectations for TestBuildAction {
.withf(
move |command: &str,
args: &[&str],
_env_vars: &Option<&HashMap<&str, &str>>|
_env_vars: &Option<&HashMap<&str, &str>>,
_working_dir: &Option<&Path>|
-> bool {
command == expected_makecert_command && args == expected_makecert_args
},
)
.once()
.returning(move |_, _, _| match override_output.clone() {
.returning(move |_, _, _, _| match override_output.clone() {
Some(output) => match output.status.code() {
Some(0) => Ok(Output {
status: ExitStatus::from_raw(0),
Expand Down Expand Up @@ -2983,13 +2989,14 @@ impl TestSetupPackageExpectations for TestBuildAction {
.withf(
move |command: &str,
args: &[&str],
_env_vars: &Option<&HashMap<&str, &str>>|
_env_vars: &Option<&HashMap<&str, &str>>,
_working_dir: &Option<&Path>|
-> bool {
command == expected_signtool_command && args == expected_signtool_args
},
)
.once()
.returning(move |_, _, _| match override_output.clone() {
.returning(move |_, _, _, _| match override_output.clone() {
Some(output) => match output.status.code() {
Some(0) => Ok(Output {
status: ExitStatus::from_raw(0),
Expand Down Expand Up @@ -3042,13 +3049,14 @@ impl TestSetupPackageExpectations for TestBuildAction {
.withf(
move |command: &str,
args: &[&str],
_env_vars: &Option<&HashMap<&str, &str>>|
_env_vars: &Option<&HashMap<&str, &str>>,
_working_dir: &Option<&Path>|
-> bool {
command == expected_signtool_command && args == expected_signtool_args
},
)
.once()
.returning(move |_, _, _| match override_output.clone() {
.returning(move |_, _, _, _| match override_output.clone() {
Some(output) => match output.status.code() {
Some(0) => Ok(Output {
status: ExitStatus::from_raw(0),
Expand Down Expand Up @@ -3094,13 +3102,14 @@ impl TestSetupPackageExpectations for TestBuildAction {
.withf(
move |command: &str,
args: &[&str],
_env_vars: &Option<&HashMap<&str, &str>>|
_env_vars: &Option<&HashMap<&str, &str>>,
_working_dir: &Option<&Path>|
-> bool {
command == expected_signtool_command && args == expected_signtool_verify_args
},
)
.once()
.returning(move |_, _, _| match override_output.clone() {
.returning(move |_, _, _, _| match override_output.clone() {
Some(output) => match output.status.code() {
Some(0) => Ok(Output {
status: ExitStatus::from_raw(0),
Expand Down Expand Up @@ -3146,13 +3155,14 @@ impl TestSetupPackageExpectations for TestBuildAction {
.withf(
move |command: &str,
args: &[&str],
_env_vars: &Option<&HashMap<&str, &str>>|
_env_vars: &Option<&HashMap<&str, &str>>,
_working_dir: &Option<&Path>|
-> bool {
command == expected_signtool_command && args == expected_signtool_verify_args
},
)
.once()
.returning(move |_, _, _| match override_output.clone() {
.returning(move |_, _, _, _| match override_output.clone() {
Some(output) => match output.status.code() {
Some(0) => Ok(Output {
status: ExitStatus::from_raw(0),
Expand Down Expand Up @@ -3208,13 +3218,14 @@ impl TestSetupPackageExpectations for TestBuildAction {
.withf(
move |command: &str,
args: &[&str],
_env_vars: &Option<&HashMap<&str, &str>>|
_env_vars: &Option<&HashMap<&str, &str>>,
_working_dir: &Option<&Path>|
-> bool {
command == expected_infverif_command && args == expected_infverif_args
},
)
.once()
.returning(move |_, _, _| match override_output.clone() {
.returning(move |_, _, _, _| match override_output.clone() {
Some(output) => match output.status.code() {
Some(0) => Ok(Output {
status: ExitStatus::from_raw(0),
Expand Down
4 changes: 2 additions & 2 deletions crates/cargo-wdk/src/actions/new/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ impl<'a> NewAction<'a> {
/// * `cwd` - The current working directory inside which driver project will
/// be created.
/// * `verbosity_level` - The verbosity level for logging.
/// * `command_exec` - The provider for command exection.
/// * `command_exec` - The provider for command execution.
/// * `fs` - The provider for file system operations.
///
/// # Returns
Expand Down Expand Up @@ -121,7 +121,7 @@ impl<'a> NewAction<'a> {
if let Some(flag) = trace::get_cargo_verbose_flags(self.verbosity_level) {
args.push(flag);
}
if let Err(e) = self.command_exec.run("cargo", &args, None) {
if let Err(e) = self.command_exec.run("cargo", &args, None, None) {
return Err(NewActionError::CargoNewCommand(e));
}
Ok(())
Expand Down
7 changes: 4 additions & 3 deletions crates/cargo-wdk/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ impl Cli {
command_exec: &CommandExec,
) -> Result<CpuArchitecture> {
command_exec
.run("rustc", &["--print", "host-tuple"], None)
.run("rustc", &["--print", "host-tuple"], None, None)
.map_or_else(
|e| Err(anyhow::anyhow!("Unable to read rustc host tuple: {e}")),
|output| {
Expand Down Expand Up @@ -306,7 +306,8 @@ mod tests {
.withf(
move |command: &str,
args: &[&str],
_env_vars: &Option<&HashMap<&str, &str>>|
_env_vars: &Option<&HashMap<&str, &str>>,
_working_dir: &Option<&std::path::Path>|
-> bool {
println!("command: {command}, args: {args:?}");
println!(
Expand All @@ -317,7 +318,7 @@ mod tests {
},
)
.once()
.return_once(|_, _, _| expected_cli_result);
.return_once(|_, _, _, _| expected_cli_result);

Cli::detect_default_target_arch_using_rustc(&mock_command_exec)
}
Expand Down
Loading
Loading