@@ -246,15 +246,19 @@ Describe 'tests for resource discovery' {
246246 }
247247 }
248248
249- It ' Resource manifest using relative path to exe works' {
250- $manifest = @'
249+ It ' Resource manifest using relative path to exe: <path>' - TestCases @ (
250+ @ { path = ' ../dscecho' ; success = $true }
251+ @ { path = ' ../foo/dscecho' ; success = $false }
252+ ) {
253+ param ($path , $success )
254+ $manifest = @"
251255{
252- "$schema": "https://aka.ms/dsc/schemas/v3/bundled/resource/manifest.json",
256+ "` $ schema": "https://aka.ms/dsc/schemas/v3/bundled/resource/manifest.json",
253257 "type": "Microsoft.DSC.Debug/Echo",
254258 "version": "1.0.0",
255259 "description": "Echo resource for testing and debugging purposes",
256260 "get": {
257- "executable": "../dscecho ",
261+ "executable": "$path ",
258262 "args": [
259263 {
260264 "jsonInputArg": "--input",
@@ -264,24 +268,29 @@ Describe 'tests for resource discovery' {
264268 },
265269 "schema": {
266270 "command": {
267- "executable": "../dscecho "
271+ "executable": "$path "
268272 }
269273 }
270274}
271- ' @
275+ " @
272276 $dscEcho = Get-Command dscecho - ErrorAction Stop
273277 # copy to testdrive
274278 Copy-Item - Path " $ ( $dscEcho.Source ) " - Destination $testdrive
275279 # create manifest in subfolder
276280 $subfolder = Join-Path $testdrive ' subfolder'
277- New-Item - Path $subfolder - ItemType Directory | Out-Null
281+ New-Item - Path $subfolder - ItemType Directory - Force | Out-Null
278282 Set-Content - Path (Join-Path $subfolder ' test.dsc.resource.json' ) - Value $manifest
279283
280284 try {
281285 $env: DSC_RESOURCE_PATH = $subfolder
282286 $out = dsc resource get - r ' Microsoft.DSC.Debug/Echo' - i ' {"output":"RelativePathTest"}' 2> " $testdrive /error.txt" | ConvertFrom-Json
283- $LASTEXITCODE | Should - Be 0 - Because (Get-Content - Raw - Path " $testdrive /error.txt" )
284- $out.actualState.output | Should - BeExactly ' RelativePathTest'
287+ if ($success ) {
288+ $LASTEXITCODE | Should - Be 0 - Because (Get-Content - Raw - Path " $testdrive /error.txt" )
289+ $out.actualState.output | Should - BeExactly ' RelativePathTest'
290+ } else {
291+ $LASTEXITCODE | Should - Be 2 - Because (Get-Content - Raw - Path " $testdrive /error.txt" )
292+ (Get-Content - Raw - Path " $testdrive /error.txt" ) | Should -Match " ERROR.*?Executable '\.\./foo/dscecho(\.exe)?' not found"
293+ }
285294 }
286295 finally {
287296 $env: DSC_RESOURCE_PATH = $null
0 commit comments