Skip to content

improvements/changes relating to #169 #170

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

Test: Uses Atom and atom-grammar-test to run tests against specs and sample files to guard against regression.

.EXAMPLE Build
.EXAMPLE
PS C:\EditorSyntax> .\build.ps1
[Starting] Converting ../PowerShellSyntax.tmLanguage to json.
... Reading source file.
Expand All @@ -16,7 +16,7 @@
... Creating directory: ./grammars
[Finished] File written to: ../grammars/powershell.tmLanguage.json

.EXAMPLE Test
.EXAMPLE
PS C:\EditorSyntax> .\build.ps1 Test
Running specs...

Expand All @@ -25,9 +25,7 @@
Finished in 0.281 seconds
2 tests, 5 assertions, 0 failures, 0 skipped
#>
[cmdletbinding()]
param(
[parameter()]
[switch]
$Test
)
Expand All @@ -38,19 +36,20 @@ param(

SyntaxBanner

if (-not(& npm -v)) {
if (-not (npm -v)) {
throw 'Requires Node.js - Could not find npm.'
}

& npm install
npm install

# helper tasks
function RunBuild() {
BuildBanner
try {
Write-Host "Building grammar file(s)..."
& npm run build-grammar
} catch {
npm run build-grammar
}
catch {
$PSCmdlet.ThrowTerminatingError($PSItem)
}
}
Expand Down
49 changes: 28 additions & 21 deletions tools/build-helpers.ps1
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
function DownloadAtom {
Write-Host "Downloading latest Atom release..."

$Source = "https://atom.io/download/windows_zip?channel=stable"
$Source = "https://atom.io/download/windows_zip?channel=stable"
$Destination = Join-Path . '\atom.zip'

try {
Invoke-WebRequest $Source -OutFile $Destination -ErrorAction Stop
} catch {
}
catch {
$PSCmdlet.ThrowTerminatingError($PSItem)
}

Expand All @@ -24,7 +25,8 @@ function ExtractAtom {
try {
Add-Type -AssemblyName System.IO.Compression.FileSystem
[System.IO.Compression.ZipFile]::ExtractToDirectory($ZipFile, $OutPath)
} catch {
}
catch {
$PSCmdlet.ThrowTerminatingError($PSItem)
}

Expand All @@ -35,24 +37,27 @@ function ExtractAtom {
Write-Host "Atom.zip deleted..."
}

function ParseJasmine ($String) {
if ($String -match "^\s+at.*$") {
' '
return
}
filter ParseJasmine {
switch -regex ($_) {
^\s+at {
''
break
}

if ($_ -match "^\s+it.*$") {
$_ -replace '^(\s+)(it)','$1[-] It'
return
}
^\s+it {
$_ -replace '^(\s+)(it)', '$1[-] It'
break
}

if ($_ -match "^\s+Expected.*$") {
$x = $_ -replace '^(\s*)(Expected)(.*)\s(to equal .*)','$1$2$3%%$1$4'
$x.Replace('%%',"`n ")
return
}
^\s+Expected {
$_ -replace '^(\s*)(Expected.*?)\s(instead found .*)', "`$1`$2`n`$1`$3"
break
}

$_
default {
$_
}
}
}

function ExitWithCode {
Expand All @@ -70,15 +75,17 @@ function RunSpecs {
$specpath = Join-Path . '\spec'

if (Test-Path $specpath) {
& "$script:ATOM_EXE_PATH" --test spec *>&1 | ForEach-Object { ParseJasmine $_ }
} else {
& $script:ATOM_EXE_PATH --test $specpath *>&1 | ParseJasmine
}
else {
throw '.\spec\ not found.'
}

if ($LASTEXITCODE -ne 0) {
if ($Env:APPVEYOR) {
ExitWithCode -exitcode $LASTEXITCODE
} else {
}
else {
throw "One or more tests failed."
}
}
Expand Down