-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMeta.tests.ps1
More file actions
49 lines (43 loc) · 1.53 KB
/
Copy pathMeta.tests.ps1
File metadata and controls
49 lines (43 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
BeforeAll {
Set-StrictMode -Version 'Latest'
# Make sure MetaFixers.psm1 is loaded - it contains Get-TextFilesList
Import-Module (Join-Path -Path $PSScriptRoot -ChildPath 'MetaFixers.psm1') -Verbose:$false -Force
$projectRoot = $Env:BHProjectPath
if (-not $projectRoot) {
$projectRoot = $PSScriptRoot
}
$allTextFiles = Get-TextFilesList $projectRoot
$unicodeFilesCount = 0
$totalTabsCount = 0
foreach ($textFile in $allTextFiles) {
if (Test-FileUnicode $textFile) {
$unicodeFilesCount++
Write-Warning (
"File $($textFile.FullName) contains 0x00 bytes." +
' It probably uses Unicode/UTF-16 and needs to be converted to UTF-8.' +
' Use Fixer "Get-UnicodeFilesList $pwd | ConvertTo-UTF8".'
)
}
$unicodeFilesCount | Should -Be 0
$fileName = $textFile.FullName
(Get-Content -Path $fileName -Raw) | Select-String "`t" | Foreach-Object {
Write-Warning (
"There are tabs in $fileName." +
' Use Fixer "Get-TextFilesList `$pwd | ConvertTo-SpaceIndentation".'
)
$totalTabsCount++
}
}
}
Describe 'Text files formatting' {
Context 'File encoding' {
It 'No text file uses Unicode/UTF-16 encoding' {
$unicodeFilesCount | Should -Be 0
}
}
Context 'Indentations' {
It 'No text file use tabs for indentations' {
$totalTabsCount | Should -Be 0
}
}
}