Skip to content

Commit 0899801

Browse files
author
Steve Lee (POWERSHELL HE/HIM) (from Dev Box)
committed
fix using canonical path and test
1 parent 79c27ea commit 0899801

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

dsc/tests/dsc_extension_discover.tests.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ Describe 'Discover extension tests' {
138138
$out = dsc -l warn resource list 2> $TestDrive/error.log | ConvertFrom-Json
139139
$LASTEXITCODE | Should -Be 0
140140
$out.Count | Should -BeGreaterThan 0
141-
(Get-Content -Path "$TestDrive/error.log" -Raw) | Should -BeLike "*WARN Extension 'Microsoft.Windows.Appx/Discover' failed to discover resources: Command: Operation Executable 'powershell.exe' not found*" -Because (Get-Content -Path "$TestDrive/error.log" -Raw | Out-String)
141+
(Get-Content -Path "$TestDrive/error.log" -Raw) | Should -BeLike "*WARN Extension 'Microsoft.Windows.Appx/Discover' failed to discover resources: Command: Operation Executable 'powershell' not found*" -Because (Get-Content -Path "$TestDrive/error.log" -Raw | Out-String)
142142
} finally {
143143
$env:PATH = $oldPath
144144
}

lib/dsc-lib/locales/en-us.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -698,4 +698,5 @@ failedToGetExePath = "Can't get 'dsc' executable path"
698698
settingNotFound = "Setting '%{name}' not found"
699699
failedToAbsolutizePath = "Failed to absolutize path '%{path}'"
700700
invalidExitCodeKey = "Invalid exit code key '%{key}'"
701-
executableNotFound = "Executable '%{executable}' not found with working directory '%{cwd}'"
701+
executableNotFoundInWorkingDirectory = "Executable '%{executable}' not found with working directory '%{cwd}'"
702+
executableNotFound = "Executable '%{executable}' not found"

lib/dsc-lib/src/util.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,11 +242,12 @@ pub fn canonicalize_which(executable: &str, cwd: Option<&str>) -> Result<String,
242242
if which(executable).is_err() {
243243
if let Some(cwd) = cwd {
244244
let cwd_path = Path::new(cwd);
245-
if let Ok(canonical_path) = canonicalize(cwd_path.join(executable)) {
245+
if let Ok(canonical_path) = canonicalize(cwd_path.join(&executable_path)) {
246246
return Ok(canonical_path.to_string_lossy().to_string());
247247
}
248+
return Err(DscError::CommandOperation(t!("util.executableNotFoundInWorkingDirectory", executable = &executable, cwd = cwd_path.to_string_lossy()).to_string(), executable_path.to_string_lossy().to_string()));
248249
}
249-
return Err(DscError::CommandOperation(t!("util.executableNotFound", executable = &executable, cwd = cwd : {:?}).to_string(), executable.to_string()));
250+
return Err(DscError::CommandOperation(t!("util.executableNotFound", executable = &executable).to_string(), executable.to_string()));
250251
}
251252
Ok(executable.to_string())
252253
}

0 commit comments

Comments
 (0)