diff --git a/tools/test-npm.ps1 b/tools/test-npm.ps1 new file mode 100644 index 00000000000000..683dd112a516f8 --- /dev/null +++ b/tools/test-npm.ps1 @@ -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" diff --git a/vcbuild.bat b/vcbuild.bat index f95cfca8b390a9..9a0884e41024cb 100644 --- a/vcbuild.bat +++ b/vcbuild.bat @@ -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 @@ -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' @@ -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