8000 Fix tests and test cases · PoshCode/PSGit@4f92eca · GitHub
[go: up one dir, main page]

Skip to content

Commit 4f92eca

Browse files
committed
Fix tests and test cases
1 parent 64645a8 commit 4f92eca

File tree

5 files changed

+184
-178
lines changed

5 files changed

+184
-178
lines changed

.gitignore

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
# ignore packages (this is for nuget stuff)
2-
/packages/*
3-
# ignore output (because we put stuff there)
4-
/output/*
5-
# Ignore version number folders (these are our intermediate "output" directories for testing)
6-
/[0-9]*/
7-
# ignore PSTools for VisualStudio files and folders
8-
/bin/*
9-
/obj/*
10-
*.suo
1+
Tests/.Do.Not.COMMIT.This.Steps.ps1
2+
# ignore packages (this is for nuget stuff)
3+
/packages/*
4+
# ignore output (because we put stuff there)
5+
/output/*
6+
# Ignore version number folders (these are our intermediate "output" directories for testing)
7+
/[0-9]*/
8+
# ignore PSTools for VisualStudio files and folders
9+
/bin/*
10+
/obj/*
11+
*.suo

Build.ps1

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ function build {
216216

217217
$PackageSource = Get-Item $targets -ErrorAction SilentlyContinue | Select -First 1 -Expand FullName
218218
if(!$PackageSource) {
219-
throw "Could not find a lib folder for $($Package.id) from package. You may need to run Setup.ps1"
219+
throw "Could not find a lib folder for $($Package.id) from package. You may need to run Build -Step Update"
220220
}
221221

222222
Trace-Message "robocopy $PackageSource $LibPath /E /NP /LOG+:'$OutputPath\build.log' /R:2 /W:15"
@@ -314,28 +314,29 @@ function test {
314314
Trace-Message "TESTING $ModuleName v$Version" -Verbose:(!$Quiet)
315315
Remove-Module $ModuleName -ErrorAction SilentlyContinue
316316

317-
$Options = @{
317+
$PesterOptions = @{
318318
OutputFormat = "NUnitXml"
319319
OutputFile = (Join-Path $OutputPath TestResults.xml)
320320
}
321-
if($Quiet) { $Options.Quiet = $Quiet }
322-
if(!$ShowWip){ $Options.ExcludeTag = @("wip") }
321+
if($Quiet) { $PesterOptions.Quiet = $Quiet }
322+
if(!$ShowWip){ $PesterOptions.ExcludeTag = @("wip") }
323323

324324
Set-Content "$TestPath\.Do.Not.COMMIT.This.Steps.ps1" "Import-Module $ReleasePath\${ModuleName}.psd1 -Force"
325325

326326
# Show the commands they would have to run to get these results:
327327
Write-Host "C:\PS> " -NoNewLine
328328
Write-Host Import-Module $ReleasePath\${ModuleName}.psd1 -Force
329-
Write-Host "C:\PS> " -NoNewLine
330329

331330
# TODO: Update dependency to Pester 4.0 and use just Invoke-Pester
332331
if(Get-Command Invoke-Gherkin -ErrorAction SilentlyContinue) {
333-
Write-Host Invoke-Gherkin -Path $TestPath -CodeCoverage "$ReleasePath\*.psm1" -PassThru @Options
334-
$TestResults = Invoke-Gherkin -Path $TestPath -CodeCoverage "$ReleasePath\*.psm1" -PassThru @Options
332+
Write-Host "C:\PS> " -NoNewLine
333+
Write-Host Invoke-Gherkin -Path $TestPath -CodeCoverage "$ReleasePath\*.psm1" -PassThru @PesterOptions
334+
$TestResults = @(Invoke-Gherkin -Path $TestPath -CodeCoverage "$ReleasePath\*.psm1" -PassThru @PesterOptions)
335335
}
336336

337-
Write-Host Invoke-Pester -Path $TestPath -CodeCoverage "$ReleasePath\*.psm1" -PassThru @Options
338-
$TestResults = Invoke-Pester -Path $TestPath -CodeCoverage "$ReleasePath\*.psm1" -PassThru @Options
337+
Write-Host "C:\PS> " -NoNewLine
338+
Write-Host Invoke-Pester -Path $TestPath -CodeCoverage "$ReleasePath\*.psm1" -PassThru @PesterOptions
339+
$TestResults += @(Invoke-Pester -Path $TestPath -CodeCoverage "$ReleasePath\*.psm1" -PassThru @PesterOptions)
339340

340341
Remove-Module $ModuleName -ErrorAction SilentlyContinue
341342
Remove-Item "$TestPath\.Do.Not.COMMIT.This.Steps.ps1"
@@ -381,15 +382,15 @@ function test {
381382
}
382383

383384
if(${JobID}) {
384-
if(Test-Path $Options.OutputFile) {
385+
if(Test-Path $PesterOptions.OutputFile) {
385386
Trace-Message "Sending Test Results to AppVeyor backend" -Verbose:(!$Quiet)
386387
$wc = New-Object 'System.Net.WebClient'
387-
$response = $wc.UploadFile("https://ci.appveyor.com/api/testresults/nunit/${JobID}", $Options.OutputFile)
388+
$response = $wc.UploadFile("https://ci.appveyor.com/api/testresults/nunit/${JobID}", $PesterOptions.OutputFile)
388389
if($response) {
389390
Trace-Message ([System.Text.Encoding]::ASCII.GetString($response)) -Verbose:(!$Quiet)
390391
}
391392
} else {
392-
Write-Warning "Couldn't find Test Output: $($Options.OutputFile)"
393+
Write-Warning "Couldn't find Test Output: $($PesterOptions.OutputFile)"
393394
}
394395
}
395396

Tests/Save-Change.feature

Lines changed: 154 additions & 154 deletions
Original file line numberDiff line numberDiff line change
@@ -1,155 +1,155 @@
1-
@wip
2-
Feature: Commit staged changes to the Repository
3-
As a PowerShell user
4-
I want to save the changes I made in my repository
5-
So that I can restore a previous state of my work whenever I need to
6-
7-
Scenario: Save-Change should have similar paramteres as git commit
8-
Given we have a command Save-Change
9-
Then it should have parameters:
10-
| Name | Type |
11-
| Message | String[] |
12-
| CopyAuthorshipAndMessageFromChange | String |
13-
| CopyAuthorshipAndEditMessageFromChange | String |
14-
| MessageTemplate | String |
15-
| Author | String |
16-
| ModifyLastSavedChange | Switch |
17-
| EditMessage | Switch |
18-
| KeepMessage | Switch |
19-
20-
# -Message maps to -m/--message
21-
# -CopyAuthorshipAndMessageFromChange maps to -C/--reuse-message
22-
# -CopyAuthorshipAndEditMessageFromChange maps to -c/reedit-message
23-
# -MessageTemplate maps to -t/--template
24-
# -Author maps to --author
25-
# -EditMessage maps to -e/--edit
26-
# -KeepMessage maps to --no-edit
27-
# ignoring pathspecs, --all, --patch, --fixup, --squash, --reset-author,
28-
# --signoff, --no-verify, --allow-empty, --allow-empty-message,
29-
# --no-post-rewrite, --include, --gpg-sign, --no-gpg-sign, -F/--file for the time being
30-
# pathspec will not be provided with PSGit. Any selection of what to commit should be done using Add-Change instead
31-
32-
@wip
33-
Scenario: Commit all staged changes
34-
Given we have a repository with
35-
| ChangeState | FileName |
36-
| staged | stagedFile.txt |
37-
| staged | other/stagedFile.txt |
38-
| modified | modifiedFile.txt |
39-
When I call Save-Change -Message "Saving all staged changes"
40-
Then the output shows a summary line for the saved change
41-
And the summary line contains the branch name,
42-
And the summary line contains the short commit id
43-
And the summary line contains the commit message
44-
And the status info shows
45-
| ChangeState | FileName |
46-
| modified | modifiedFile.txt |
47-
48-
@wip
49-
Scenario: Commit with a multipart message
50-
Given we have a repository with
51-
| ChangeState | FileName |
52-
| staged | stagedFile.txt |
53-
| staged | other/stagedFile.txt |
54-
| modified | modifiedFile.txt |
55-
When I call Save-Change -Message "Saving all staged changes" "with additional message text"
56-
Then the output shows a summary line for the saved change
57-
And the summary line contains the branch name,
58-
And the summary line contains the short commit id
59-
And the summary line contains the commit message
60-
And the status info shows
61-
| ChangeState | FileName |
62-
| modified | modifiedFile.txt |
63-
And the status info shows both parts of the commit message as individual paragraphs
64-
65-
@wip
66-
Scenario: Use an editor to enter a commit message
67-
Given we have a repository with
68-
| ChangeState | FileName |
69-
| staged | stagedFile.txt |
70-
| staged | other/stagedFile.txt |
71-
| modified | modifiedFile.txt |
72-
And I have configured notepad as my default editor for git
73-
When I call Save-Change
74-
Then notepad is opened for entering a commit message
75-
76-
@wip
77-
Scenario: Use a template for generating a commit message
78-
Given we have a repository with
79-
| ChangeState | FileName |
80-
| staged | stagedFile.txt |
81-
| staged | other/stagedFile.txt |
82-
| modified | modifiedFile.txt |
83-
And I have configured notepad as my default editor for git
84-
And I have configured a template.commitmsg as message template
85-
When I call Save-Change -MessageTemplate
86-
Then notepad is opened for entering a commit message
87-
And the content of template.commitmsg is displayed
88-
89-
@wip
90-
Scenario: supply author information for saving the change
91-
Given we have a repository with
92-
| ChangeState | FileName |
93-
| staged | stagedFile.txt |
94-
| staged | other/stagedFile.txt |
95-
| modified | modifiedFile.txt |
96-
When I call Save-Change -Message "using different author info" -Author "A U Thor <author@example.com>"
97-
Then the output shows a summary line for the saved change
98-
And the summary line contains the branch name
99-
And the summary line contains the short commit id
100-
And the summary line contains the commit message
101-
And the summary line shows A U Thor as the author of the saved change
102-
And the status info shows
103-
| ChangeState | FileName |
104-
| modified | modifiedFile.txt |
105-
106-
@wip
107-
Scenario: use the commit message from a previous commit
108-
Given we have a repository with
109-
| Commit | Message | Author |
110-
| First | Initial Commit | John Doe <J.Doe@unknown.com> |
111-
| Second | Grandparent commit message | A U Thor <author@example.com> |
112-
| Third | Parent commit message | Jane Doe <JaneD@unkown.com> |
113-
When I call Save-Change -CopyAuthorshipAndMessageFromChange HEAD~2
114-
Then the output shows a summary line for the saved change
115-
And the summary line contains the branch name
116-
And the summary line contains the short commit id
117-
And the summary line contains the commit message of the Second commit
118-
And the summary line shows A U Thor as the author of the saved change
119-
120-
@wip
121-
Scenario: use and edit the commit message from a previous commit
122-
Given we have a repository with
123-
| Commit | Message | Author |
124-
| First | Initial Commit | John Doe <J.Doe@unknown.com> |
125-
| Second | Grandparent commit message | A U Thor <author@example.com> |
126-
| Third | Parent commit message | Jane Doe <JaneD@unkown.com> |
127-
And I have configured notepad as my default editor for git
128-
When I call Save-Change -CopyAuthorshipAndEditMessageFromChange HEAD~2
129-
Then notepad is opened for entering a commit message
130-
And the commit message from the Second commit is displayed for editing
131-
132-
@wip
133-
Scenario: amend the the previous commit and keep the message as it is
134-
Given we have a repository with
135-
| Commit | Message | Author |
136-
| First | Initial Commit | John Doe <J.Doe@unknown.com> |
137-
| Second | Grandparent commit message | A U Thor <author@example.com> |
138-
| Third | Parent commit message | Jane Doe <JaneD@unkown.com> |
139-
When I call Save-Change -ModifyLastSavedChange -KeepMessage
140-
Then the output shows a summary line for the saved change
141-
And the summary line contains the branch name
142-
And the summary line contains the short commit id
143-
And the summary line contains the commit message of the Third commit
144-
145-
@wip
146-
Scenario: amend the the previous commit and edit the message
147-
Given we have a repository with
148-
| Commit | Message | Author |
149-
| First | Initial Commit | John Doe <J.Doe@unknown.com> |
150-
| Second | Grandparent commit message | A U Thor <author@example.com> |
151-
| Third | Parent commit message | Jane Doe <JaneD@unkown.com> |
152-
And I have configured notepad as my default editor for git
153-
When I call Save-Change -ModifyLastSavedChange -EditMessage
154-
Then notepad is opened for entering a commit message
1+
@wip
2+
Feature: Commit staged changes to the Repository
3+
As a PowerShell user
4+
I want to save the changes I made in my repository
5+
So that I can restore a previous state of my work whenever I need to
6+
7+
Scenario: Save-Change should have similar paramteres as git commit
8+
Given we have a command Save-Change
9+
Then it should have parameters:
10+
| Name | Type |
11+
| Message | String[] |
12+
| CopyAuthorshipAndMessageFromChange | String |
13+
| CopyAuthorshipAndEditMessageFromChange | String |
14+
| MessageTemplate | String |
15+
| Author | String |
16+
| ModifyLastSavedChange | Switch |
17+
| EditMessage | Switch |
18+
| KeepMessage | Switch |
19+
20+
# -Message maps to -m/--message
21+
# -CopyAuthorshipAndMessageFromChange maps to -C/--reuse-message
22+
# -CopyAuthorshipAndEditMessageFromChange maps to -c/reedit-message
23+
# -MessageTemplate maps to -t/--template
24+
# -Author maps to --author
25+
# -EditMessage maps to -e/--edit
26+
# -KeepMessage maps to --no-edit
27+
# ignoring pathspecs, --all, --patch, --fixup, --squash, --reset-author,
28+
# --signoff, --no-verify, --allow-empty, --allow-empty-message,
29+
# --no-post-rewrite, --include, --gpg-sign, --no-gpg-sign, -F/--file for the time being
30+
# pathspec will not be provided with PSGit. Any selection of what to commit should be done using Add-Change instead
31+
32+
@wip
33+
Scenario: Commit all staged changes
34+
Given we have a repository with
35+
| ChangeState | FileName |
36+
| staged | stagedFile.txt |
37+
| staged | other/stagedFile.txt |
38+
| modified | modifiedFile.txt |
39+
When I call Save-Change -Message "Saving all staged changes"
40+
Then the output shows a summary line for the saved change
41+
And the summary line contains the branch name,
42+
And the summary line contains the short commit id
43+
And the summary line contains the commit message
44+
And the status info shows
45+
| ChangeState | FileName |
46+
| modified | modifiedFile.txt |
47+
48+
@wip
49+
Scenario: Commit with a multipart message
50+
Given we have a repository with
51+
| ChangeState | FileName |
52+
| staged | stagedFile.txt |
53+
| staged | other/stagedFile.txt |
54+
| modified | modifiedFile.txt |
55+
When I call Save-Change -Message "Saving all staged changes" "with additional message text"
56+
Then the output shows a summary line for the saved change
57+
And the summary line contains the branch name,
58+
And the summary line contains the short commit id
59+
And the summary line contains the commit message
60+
And the status info shows
61+
| ChangeState | FileName |
62+
| modified | modifiedFile.txt |
63+
And the status info shows both parts of the commit message as individual paragraphs
64+
65+
@wip
66+
Scenario: Use an editor to enter a commit message
67+
Given we have a repository with
68+
| ChangeState | FileName |
69+
| staged | stagedFile.txt |
70+
| staged | other/stagedFile.txt |
71+
| modified | modifiedFile.txt |
72+
And I have configured notepad as my default editor for git
73+
When I call Save-Change
74+
Then notepad is opened for entering a commit message
75+
76+
@wip
77+
Scenario: Use a template for generating a commit message
78+
Given we have a repository with
79+
| ChangeState | FileName |
80+
| staged | stagedFile.txt |
81+
| staged | other/stagedFile.txt |
82+
| modified | modifiedFile.txt |
83+
And I have configured notepad as my default editor for git
84+
And I have configured a template.commitmsg as message template
85+
When I call Save-Change -MessageTemplate
86+
Then notepad is opened for entering a commit message
87+
And the content of template.commitmsg is displayed
88+
89+
@wip
90+
Scenario: supply author information for saving the change
91+
Given we have a repository with
92+
| ChangeState | FileName |
93+
| staged | stagedFile.txt |
94+
| staged | other/stagedFile.txt |
95+
| modified | modifiedFile.txt |
96+
When I call Save-Change -Message "using different author info" -Author "A U Thor <author@example.com>"
97+
Then the output shows a summary line for the saved change
98+
And the summary line contains the branch name
99+
And the summary line contains the short commit id
100+
And the summary line contains the commit message
101+
And the summary line shows A U Thor as the author of the saved change
102+
And the status info shows
103+
| ChangeState | FileName |
104+
| modified | modifiedFile.txt |
105+
106+
@wip
107+
Scenario: use the commit message from a previous commit
108+
Given we have a repository with
109+
| Commit | Message | Author |
110+
| First | Initial Commit | John Doe <J.Doe@unknown.com> |
111+
| Second | Grandparent commit message | A U Thor <author@example.com> |
112+
| Third | Parent commit message | Jane Doe <JaneD@unkown.com> |
113+
When I call Save-Change -CopyAuthorshipAndMessageFromChange HEAD~2
114+
Then the output shows a summary line for the saved change
115+
And the summary line contains the branch name
116+
And the summary line contains the short commit id
117+
And the summary line contains the commit message of the Second commit
118+
And the summary line shows A U Thor as the author of the saved change
119+
120+
@wip
121+
Scenario: use and edit the commit message from a previous commit
122+
Given we have a repository with
123+
| Commit | Message | Author |
124+
| First | Initial Commit | John Doe <J.Doe@unknown.com> |
125+
| Second | Grandparent commit message | A U Thor <author@example.com> |
126+
| Third | Parent commit message | Jane Doe <JaneD@unkown.com> |
127+
And I have configured notepad as my default editor for git
128+
When I call Save-Change -CopyAuthorshipAndEditMessageFromChange HEAD~2
129+
Then notepad is opened for entering a commit message
130+
And the commit message from the Second commit is displayed for editing
131+
132+
@wip
133+
Scenario: amend the the previous commit and keep the message as it is
134+
Given we have a repository with
135+
| Commit | Message | Author |
136+
| First | Initial Commit | John Doe <J.Doe@unknown.com> |
137+
| Second | Grandparent commit message | A U Thor <author@example.com> |
138+
| Third | Parent commit message | Jane Doe <JaneD@unkown.com> |
139+
When I call Save-Change -ModifyLastSavedChange -KeepMessage
140+
Then the output shows a summary line for the saved change
141+
And the summary line contains the branch name
142+
And the summary line contains the short commit id
143+
And the summary line contains the commit message of the Third commit
144+
145+
@wip
146+
Scenario: amend the the previous commit and edit the message
147+
Given we have a repository with
148+
| Commit | Message | Author |< 5F47 /div>
149+
| First | Initial Commit | John Doe <J.Doe@unknown.com> |
150+
| Second | Grandparent commit message | A U Thor <author@example.com> |
151+
| Third | Parent commit message | Jane Doe <JaneD@unkown.com> |
152+
And I have configured notepad as my default editor for git
153+
When I call Save-Change -ModifyLastSavedChange -EditMessage
154+
Then notepad is opened for entering a commit message
155155
And the commit message from the Second commit is displayed for editing

0 commit comments

Comments
 (0)
0