Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Path overhaul #272

Merged
merged 9 commits into from
Feb 1, 2015
Merged

Path overhaul #272

merged 9 commits into from
Feb 1, 2015

Conversation

dlwyatt
Copy link
Member

@dlwyatt dlwyatt commented Jan 27, 2015

Proposed fix for issues #270 and #271 .

As a side effect of these changes, we lose a little bit of console output ("Executing all tests in $Path...") and the Path property is gone from the PesterState object. We intend to add path information about each test script that is executed into the PesterState object in v4 (as a test suite, similar to Describe / Context), which is a better place for that anyway.

This is a first crack at resolving issues pester#270 and pester#271 .  I haven't written any tests around this new code yet, but it does successfully run all of Pester's existing tests (except for those looking specifically for the -Path parameter on New-PesterState; that's been removed since nothing but Invoke-Pester was actually looking at it.)
Testing the logic that's actually in Invoke-Pester is awkward, but I've manually verified that passing hashtables to the -Path parameter results in the proper splatting of the Arguments (for positional parameters) and/or Parameters (for named parameters) values to the script.
@@ -221,6 +230,85 @@ about_pester
if ($EnableExit) { Exit-WithCode -FailedCount $pester.FailedCount }
}

function ResolveTestScripts
{
param ([object[]] $Path)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we rename $Path to something different to represent that it may contain both path and arguments? Maybe create a separate Parameter set for it

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm okay with that, but we'd need to keep a Path alias to maintain backward compatibility. Maybe something like -Script or -TestScript?

@dlwyatt
Copy link
Member Author

dlwyatt commented Jan 27, 2015

What do you mean by "add line new line"?

@vors
Copy link
Member

vors commented Jan 27, 2015

I'm talking about this:
image

Why it's impotent for git.

@dlwyatt
Copy link
Member Author

dlwyatt commented Jan 27, 2015

Ah, gotcha. I can check that as well. Just added some tests to make sure there's no trailing whitespace in any file... build blew up, as you might imagine. :P

Build aborts for any file that doesn't end with a newline.
@vors
Copy link
Member

vors commented Jan 27, 2015

Yeah, we just need to fix all triling spaces, line ending once and never have this problem again :)

@dlwyatt
Copy link
Member Author

dlwyatt commented Jan 27, 2015

Will do that later tonight as part of this PR. It'll mean there's a mountain of changes in the diff, but oh well.

@vors
Copy link
Member

vors commented Jan 27, 2015

About teamcity github hook again:
image

Gray cross usually indicates "aborted". For "failed" common practice is to use red cross. (see Azure/azure-powershell#102 for example). I don't know how to express it on github hook level, so I just talking in terms of user interface. :)

It will be beneficial to align reporting mechanism with common practices, so new contributors will have a consistent experience.

@dlwyatt
Copy link
Member Author

dlwyatt commented Jan 28, 2015

I might be able to change that on the TeamCity server; will see what I can do.

@dlwyatt
Copy link
Member Author

dlwyatt commented Jan 28, 2015

Hmm, nevermind. I thought maybe I had set it up to "cancel build" if the dependencies failed, but it's actually set to "run build, but log problem." Beyond that, I don't seem to have any control over the GitHub hook.

It's interesting that the X is red down by the Merge pull request button, but is gray on the line with the commit itself.

@dlwyatt
Copy link
Member Author

dlwyatt commented Jan 28, 2015

Trying one thing... instead of reporting on build start / finish, I switched it to only report on finish. Right now the commits have both a Pending and a Failure status, and maybe that's somehow messing with the icons.

Added missing newlines at the end of files, and removed all trailing whitespace from ps1 / psm1 files.
@vors
Copy link
Member

vors commented Jan 28, 2015

Reporting only on finish will probably mean, that it will not report 'in progress status'.

@dlwyatt
Copy link
Member Author

dlwyatt commented Jan 28, 2015

That's probably fine. It's only a couple minutes from start to finish in our build anyway.

@vors
Copy link
Member

vors commented Jan 28, 2015

Maybe preserving -Path as string[] and adding -Target as a hashtable[].
It will be much harder to rename it, once people take dependencies.

Also, we definitely need an example in Invoke-Pester function definition.

@dlwyatt
Copy link
Member Author

dlwyatt commented Jan 28, 2015

I don't think I like the idea of having separate parameters. It's not consistent with the -CodeCoverage parameter (which already accepts strings or hashtables), as well as what people are already accustomed to in Select-Object and Format-*.

@vors
Copy link
Member

vors commented Jan 28, 2015

Ok. Please, update Pester.psm1 help.

Also added a check to make sure that explicit file paths at least end with a ps1 extension.
@dlwyatt
Copy link
Member Author

dlwyatt commented Jan 29, 2015

Done, but it's kind of wordy for a Parameter entry. By contrast, here's what Select-Object's help has to say about the Property parameter:

Specifies the properties to select. Wildcards are permitted.

Not a single mention of calculated properties or hashtables until you get down to the examples. Would that be better?

@vors
Copy link
Member

vors commented Jan 29, 2015

LGTM

dlwyatt added a commit that referenced this pull request Feb 1, 2015
@dlwyatt dlwyatt merged commit 2b18f1d into pester:master Feb 1, 2015
@dlwyatt dlwyatt deleted the PathOverhaul branch February 1, 2015 09:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants