Skip to content

Commit

Permalink
(#88) Add instance name replacement of destination (#89)
Browse files Browse the repository at this point in the history
* (#88) Add instance name replacement of destination

Replace %{instance_name} with the instance name in the destination of
the downloads key.

Signed-off-by: Cory Knox <[email protected]>

* (#88) Add test results to Azure Pipelines

Add the test results to the Azure Pipelines runs.

Signed-off-by: Cory Knox <[email protected]>
  • Loading branch information
corbob authored Apr 3, 2022
1 parent 300c7bc commit 1c45062
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .kitchen.appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ verifier:
environment:
API_KEY: Some key value
PUSH_REPO: https://push.example.com
downloads:
"PesterTestResults.xml": "testresults/%{instance_name}/"

suites:
- name: default
2 changes: 2 additions & 0 deletions .kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ verifier:
environment:
API_KEY: Some key value
PUSH_REPO: https://push.example.com
downloads:
"PesterTestResults.xml": "testresults/%{instance_name}/"

suites:
- name: default
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,16 @@ This is necessary in certain cases, such as when `pwsh` is installed via `snap`

* `downloads`- map[string, string], defaults to `{"./PesterTestResults.xml" => "./testresults}"`.
Files to download from SUT to local system, used to download the pester results localy.
The key is the remote file (relative to verifier folder or absolute), the value is the directory (ends with / or \\) it should be saved to (relative to pwd or absolute).
The key is the remote file to download, while the value is the destination.
* The source can:
* Be relative to the verifier folder (by default `$TEMP/verifier`)
* Be absolute on the system (e.g. `/var/tmp/file.zip` or `C:\\Windows\\Temp\\file.zip`)
* The destination can:
* Include `%{instance_name}` to indicate the Test Kitchen instance name
* Be a directory (ends in `/` or `\\`)
* Be relative to the Current Working Directory
* Be absolute

```yaml
downloads:
PesterTestResults.xml: "./output/testResults/"
Expand Down
1 change: 1 addition & 0 deletions TESTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ The general steps to test your changes:
1. Build new gem: `chef gem build ./kitchen-pester.gemspec`
1. Install built gem: `chef gem install ./kitchen-pester-<version>.gem`
1. Test with `test-kitchen`: `kitchen test`
1. Ensure that `PesterTestResults.xml` is created in `./testresults/default-windows-2016`
4 changes: 4 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ stages:
displayName: Run Tests
env:
SPEC_OPTS: --format progress
- task: PublishTestResults@2
inputs:
testResultsFormat: NUnit
testResultsFiles: 'testresults/**/PesterTestResults.xml'
- job: Package
dependsOn: Validate
condition: and(succeeded(), eq(variables['build.sourceBranch'], 'refs/heads/main'), notIn(variables['Build.Reason'], 'PullRequest'))
Expand Down
3 changes: 2 additions & 1 deletion lib/kitchen/verifier/pester.rb
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ def resolve_downloads_paths!
config[:downloads] = config[:downloads]
.map do |source, destination|
source = source.to_s
destination = destination.gsub("%{instance_name}", instance.name)
info(" resolving remote source's absolute path.")
unless source.match?('^/|^[a-zA-Z]:[\\/]') # is Absolute?
info(" '#{source}' is a relative path, resolving to: #{File.join(config[:root_path], source)}")
Expand All @@ -203,7 +204,7 @@ def resolve_downloads_paths!
if !File.directory?(File.dirname(destination))
FileUtils.mkdir_p(File.dirname(destination))
else
info(" Directory #{File.dirname(destination)} seem to exist.")
info(" Directory #{File.dirname(destination)} seems to exist.")
end

[ source, destination ]
Expand Down

0 comments on commit 1c45062

Please sign in to comment.