Skip to content

Commit

Permalink
build,test: add test-npm.ps1 to test npm on windows
Browse files Browse the repository at this point in the history
test-npm.ps1 should mimic test-npm.sh on Windows.

Also adds the test-npm target to vcbuild.bat
  • Loading branch information
gibfahn committed Aug 5, 2016
1 parent b98df1f commit d163126
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 0 deletions.
56 changes: 56 additions & 0 deletions tools/test-npm.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#Port of tools/test-npm.sh to windows

# Handle parameters
param (
[string]$progress = "classic",
[string]$logfile
)

#always change the working directory to the project's root directory
$dp0 = (Get-Item -Path ".\" -Verbose).FullName
cd $~dp0\..

# Use rmdir to get around long file path issues
Cmd /C "rmdir /S /Q test-npm"
Remove-Item test-npm.tap -ErrorAction SilentlyContinue

#make a copy of deps/npm to run the tests on
Copy-Item deps\npm test-npm -Recurse
cd test-npm

# do a rm first just in case deps/npm contained these
Remove-Item npm-cache -Force -Recurse -ErrorAction SilentlyContinue
Remove-Item npm-tmp -Force -Recurse -ErrorAction SilentlyContinue
Remove-Item npm-prefix -Force -Recurse -ErrorAction SilentlyContinue

New-Item -ItemType directory -Path npm-cache
New-Item -ItemType directory -Path npm-tmp
New-Item -ItemType directory -Path npm-prefix

#set some npm env variables to point to our new temporary folders
$pwd = (Get-Item -Path ".\" -Verbose).FullName
Set-Variable -Name npm_config_cache -value ("$pwd\npm-cache") -Scope Global
Set-Variable -Name npm_config_prefix -value ("$pwd\npm-prefix") -Scope Global
Set-Variable -Name npm_config_tmp -value ("$pwd\npm-tmp") -Scope Global

#ensure npm always uses the local node
Set-Variable -Name NODEPATH -value (Get-Item -Path "..\Release" -Verbose).FullName
$env:Path = ("$NODEPATH;$env:Path")
Remove-Variable -Name NODEPATH -ErrorAction SilentlyContinue

#make sure the binaries from the non-dev-deps are available
node cli.js rebuild
#install npm devDependencies and run npm's tests
node cli.js install --ignore-scripts

#run the tests with logging if set
if ($logfile -eq $null)
{
node cli.js run-script test-node -- --reporter=$progress
} else {
node cli.js run-script test-node -- --reporter=$progress 2>&1 | Tee-Object -FilePath "..\$logfile"
}

#clean up everything in one single shot
cd ..
Cmd /C "rmdir /S /Q test-npm"
9 changes: 9 additions & 0 deletions vcbuild.bat
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ if /i "%1"=="test-message" set test_args=%test_args% message&goto arg-ok
if /i "%1"=="test-gc" set test_args=%test_args% gc&set buildnodeweak=1&goto arg-ok
if /i "%1"=="test-internet" set test_args=%test_args% internet&goto arg-ok
if /i "%1"=="test-pummel" set test_args=%test_args% pummel&goto arg-ok
if /i "%1"=="test-npm" set test_args=%test_args% npm&goto arg-ok
if /i "%1"=="test-all" set test_args=%test_args% sequential parallel message gc internet pummel&set buildnodeweak=1&set jslint=1&goto arg-ok
if /i "%1"=="test-known-issues" set test_args=%test_args% known_issues&goto arg-ok
if /i "%1"=="jslint" set jslint=1&goto arg-ok
Expand Down Expand Up @@ -335,6 +336,13 @@ goto run-tests

:run-tests
if "%test_args%"=="" goto jslint

if "%test_args%"=="%test_args:npm=%" goto node-tests
set test_args="%test_args:npm=%"
powershell .\tools\test-npm.ps1 -progress tap -logfile test-npm.tap
goto exit

:node-tests
if "%config%"=="Debug" set test_args=--mode=debug %test_args%
if "%config%"=="Release" set test_args=--mode=release %test_args%
echo running 'cctest'
Expand Down Expand Up @@ -372,6 +380,7 @@ echo vcbuild.bat : builds release build
echo vcbuild.bat debug : builds debug build
echo vcbuild.bat release msi : builds release build and MSI installer package
echo vcbuild.bat test : builds debug build and runs tests
echo vcbuild.bat test-npm : builds debug build and runs test-npm.bat
echo vcbuild.bat build-release : builds the release distribution as used by nodejs.org
echo vcbuild.bat enable-vtune : builds nodejs with Intel VTune profiling support to profile JavaScript
goto exit
Expand Down

0 comments on commit d163126

Please sign in to comment.