Skip to content

Commit

Permalink
📦 Enforce a single LF at EOF (#232)
Browse files Browse the repository at this point in the history
* tests to enforce single lf at eof

* AboutPSObjects.Koans.ps1 w LF at EOF
  • Loading branch information
vercellone authored and vexx32 committed Aug 31, 2019
1 parent 48060a7 commit 2b01ba4
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 9 deletions.
2 changes: 1 addition & 1 deletion PSKoans/Koans/Cmdlets 1/AboutNewObject.Koans.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ Describe 'New-Object' {
$Object | Should -BeOfType System.Management.Automation.PSObject
$Object2 | Should -BeOfType __
}
}
}
1 change: 0 additions & 1 deletion PSKoans/Koans/Cmdlets 1/AboutPSProviders.Koans.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -286,4 +286,3 @@ Describe 'Variable Provider' {
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ param()

<#
Advanced Functions
#>
#>
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,4 @@ Describe 'PSObject' {

@( '__', '__', '__') | Should -Be $PropertyTypes
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,4 @@ Describe 'Script Block' {
$Script | Should -Throw
$Script2 | Should -Throw
}
}
}
2 changes: 1 addition & 1 deletion PSKoans/Koans/Foundations/AboutTheStockChallenge.Koans.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,4 @@ Describe "The Stock Challenge" {

Get-GreatestVarianceDate -Data $StockData | Should -Be "2012-03-13"
}
}
}
2 changes: 1 addition & 1 deletion PSKoans/Koans/Testing Grounds/TestingArrays.Koans.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,4 @@ Context 'First Test: Arrays' {
Limit-ArrayItems -Data $Data -Number 3
}
}
}
}
1 change: 0 additions & 1 deletion PSKoans/Koans/Testing Grounds/TestingHashtables.Koans.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using module PSKoans
[Koan(Position = 115)]
param()

9 changes: 8 additions & 1 deletion Tests/KoanValidation.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ $KoanFolder = $ProjectRoot | Join-Path -ChildPath 'PSKoans' | Join-Path -ChildPa
Describe "Koan Assessment" {

$Scripts = Get-ChildItem -Path $KoanFolder -Recurse -Filter '*.Koans.ps1'

# TestCases are splatted to the script so we need hashtables
$TestCases = $Scripts | ForEach-Object { @{File = $_ } }
It "<File> koans should be valid powershell" -TestCases $TestCases {
Expand All @@ -16,4 +16,11 @@ Describe "Koan Assessment" {
[System.Management.Automation.Language.Parser]::ParseFile($file.FullName, [ref]$Tokens, [ref]$Errors) > $null
$Errors.Count | Should -Be 0
}

It "<File> should include one (and only one) line feed at end of file" -TestCases $TestCases {
param($File)
$crlf = [Regex]::Match(($File | Get-Content -Raw), '(\r?(?<lf>\n))+\Z')
$crlf.Groups['lf'].Captures.Count | Should -Be 1
}

}
6 changes: 6 additions & 0 deletions Tests/ModuleValidation.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ Describe "General project validation: $ModuleName" {
$Errors.Count | Should -Be 0
}

It "<File> should include one (and only one) line feed at end of file" -TestCases $TestCases {
param($File)
$crlf = [Regex]::Match(($File | Get-Content -Raw), '(\r?(?<lf>\n))+\Z')
$crlf.Groups['lf'].Captures.Count | Should -Be 1
}

It "'$ModuleName' can import cleanly" {
{Import-Module (Join-Path $ModuleRoot "$ModuleName.psm1") -Force} | Should -Not -Throw
}
Expand Down

0 comments on commit 2b01ba4

Please sign in to comment.