aws / aws-tools-for-powershell

The AWS Tools for PowerShell lets developers and administrators manage their AWS services from the PowerShell scripting environment.
Apache License 2.0
236 stars 78 forks source link

../Include/TestIncludes.ps1 not in repo #120

Closed bcdady closed 2 years ago

bcdady commented 4 years ago

Most (all?) Pester test scripts (within ../test/) reference ../Include/TestIncludes.ps1. Invoking a Pester test against a *.Tests.ps1 script writes an error to the console. (e.g. ./tests/Discovery/Get-AWSService.Tests.ps1

(For example, this Issue references Get-AWSService.Tests.ps1, but arguably any other script in /tests/ should behave consistently). Invoking Pester should cause no PowerShell runtime errors; only output results of test scripts

Current Behavior

Invoking Pester displays CommandNotFoundException:

Executing script ./aws-tools-for-powershell/tests/Discovery/Get-AWSCmdletName.Tests.ps1
  [-] Error occurred in test script './aws-tools-for-powershell/tests/Discovery/Get-AWSCmdletName.Tests.ps1' 0ms
    CommandNotFoundException: The term './aws-tools-for-powershell/Include/TestIncludes.ps1' is not recognized
as the name of a cmdlet, function, script file, or operable program.
    Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
    at <ScriptBlock>, ./aws-tools-for-powershell/tests/Discovery/Get-AWSCmdletName.Tests.ps1: line 1
    at <ScriptBlock>, ~/.local/share/powershell/Modules/Pester/4.9.0/Pester.psm1: line 1097
    at Invoke-Pester<End>, ~/.local/share/powershell/Modules/Pester/4.9.0/Pester.psm1: line 1123

Possible Solution

  1. Include the referenced / expected ./Include/TestIncludes.ps1 script file in this repository.
  2. Make TestIncludes a module and use a #requires statement instead of dot-sourcing it from a relative folder path

Steps to Reproduce

From within a local copy of this repo, and with the Pester module installed/imported:

Invoke-Pester -Script ./tests/Discovery/
...
Pester v4.9.0
Executing all tests in './tests/Discovery/'
...

Context

I discovered this issue while trying to validate modifications to Get-AWSService.Tests.ps1.

Here is a view showing all the Pester test scripts that expect to load this 'module': TestIncludes.ps1

Environment Detected while using AWS Tools for PowerShell version 4.0.2.0 on macOS ("Darwin 19.2.0"), with PowerShell Core version 7 RC1.

ashishdhingra commented 2 years ago

Observations:

EDIT: Looks like the include paths are coded in a way so that tests are executed from tests directory.

ashishdhingra commented 2 years ago

Hi @bcdady,

Good afternoon.

Based on my analysis on Windows and Mac, looks like the include paths are coded in a way so that tests are executed from tests directory. Kindly note that Deployment folder should have the necessary module AWSPowerShell.NetCore which is outcome of build output. Please try executing Invoke-Pester command from within <<PowerShell_RepoFolder>>/tests after successful build (using msbuild buildtools\build.proj, you might be able to build only on Windows).

Thanks, Ashish

github-actions[bot] commented 2 years ago

This issue has not recieved a response in 1 week. If you want to keep this issue open, please just leave a comment below and auto-close will be canceled.