Skip to content
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

build,test: run v8 tests on windows #13992

Merged
merged 1 commit into from
Jul 27, 2017
Merged

Conversation

kunalspathak
Copy link
Member

This is a port of #4704 for windows.
Related discussion: nodejs/build#577 (comment)

vcbuild.bat test-v8 : Runs unit test from v8 repo
vcbuild.bat test-v8-intl : Runs intl test from v8 repo
vcbuild.bat test-v8 : Runs benchmarks from v8 repo

The runs needs depot_tools
installed on the machine expects environment variable DEPOT_TOOLS_PATH to be set to the path.

Set environment variable DISABLE_V8_I18N to disable i18n.

I verified this on my machine and it works as expected. But would love to setup a CI machine that contains depot_tools installation and try it out.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • documentation is changed or added
  • commit message follows commit guidelines
Affected core subsystem(s)

build

@nodejs-github-bot nodejs-github-bot added build Issues and PRs related to build files or the CI. windows Issues and PRs related to the Windows platform. labels Jun 29, 2017
@kunalspathak
Copy link
Member Author

kunalspathak commented Jun 29, 2017

cc: @nodejs/build , @joaocgreis , @refack

@refack
Copy link
Contributor

refack commented Jun 30, 2017

Could it be moved to in a separate .bat file (in tools/ or tools/msvs/)?

  1. more tests yeah !!! 👍 🎉 💃 but:
  2. vcbuild.bat is already a hot mess
  3. depot_tools is a new dependency that only a subset of people want/have/not-discussed-by, so it makes sense to me to partition this to a new file. Maybe with an if not defined DEPOT_TOOLS_PATH exit /b 0 at the top...

@bnoordhuis
Copy link
Member

depot_tools is a new dependency that only a subset of people want/have/not-discussed-by

@refack That's no different from the existing tools/make-v8.sh script though: it checks out depot_tools when you run make test-v8.

Tangential: I don't think depot_tools is needed to build d8 (could use ./configure --enable-d8 for that) but it also downloads things like test262 that are used in V8's test suite.

@kunalspathak This needs a rebase.

@refack
Copy link
Contributor

refack commented Jul 2, 2017

Could it be moved to in a separate .bat file (in tools/ or tools/msvs/)?

@refack That's no different from the existing tools/make-v8.sh script though: it checks out depot_tools when you run make test-v8.

Just to explain myself: I ment a new batch file that could be called from vcbuild.bat (or on it's own if that's effortless).

@kunalspathak
Copy link
Member Author

Could it be moved to in a separate .bat file (in tools/ or tools/msvs/)?

@refack - Yes, makes sense. I will rebase and update the PR with review comments.

@joaocgreis
Copy link
Member

I believed the objective of running the V8 tests from our tree was to test our floating patches using the V8 test suite (as mentioned in nodejs/build#199, this would be used to test a PR that adds a floating patch to V8). So, I didn't understand the rd /S /Q v8 in this PR, but then I noticed a similar rm -rf v8 was added to make-v8.sh in #9393, which is currently in master.

Doesn't this completely defeat the purpose of testing V8 from our tree? Can't we trust that the V8 branch this ends up testing has been fully tested upstream? Shouldn't this tool use the V8 test suite on the V8 tree without removing our floating patches?

(also cc @jbajwa @mhdawson)

@kunalspathak
Copy link
Member Author

Thanks @joaocgreis for bring this up. While I was working on refactoring to move make v8 part in separate script, i realized that in unix version, cleanup happens inside make-v8.sh before building and running v8 test. I am not sure if I follow this completely. Isn't it undoing the fetch/sync part or am i missing something?

@jbajwa
Copy link
Contributor

jbajwa commented Jul 9, 2017

Hi,
The idea of the script is to get the DEPS needed by V8 make and the run-tests.py script. I'll just briefly explain the script below:

  • git stash // preserve any local uncommitted changes
  • rm -rf v8 // need to remove v8 copy to fetch the latest v8 copy, with all DEPS
  • git checkout BRANCH // branch being the v8 version used in node
  • gclient sync // update the deps to that specific V8 version
  • git reset --hard HEAD // resets to current git HEAD, which will include any local committed changes
  • git clean -fdq // will clean any untracked src files, but deps will be ignored as its part of .gitignore
  • stash pop // will restore any uncommitted changes

So, it should test the V8 which is part of Node (including any floating patches).

@refack
Copy link
Contributor

refack commented Jul 9, 2017

So, it should test the V8 which is part of Node (including any floating patches).

@jbajwa If I understand you correctly, here we do not need all the depot_tools actions, as the code in the node tree should be tested as is, right?

@jbajwa
Copy link
Contributor

jbajwa commented Jul 9, 2017 via email

@joaocgreis
Copy link
Member

@jbajwa I see now, thanks for the explanation! That's cleverly done.

@kunalspathak cleanup returns to the version of V8 in node with the floating patches, but keeping all the necessary files for building and testing V8 (because they are conveniently gitignored). So, this PR is missing that step before building. In the Unix version, cleanup is registered with trap to run if the script is cancelled. I don't think this is straightforward to do in cmd, but is not essential. You might also consider running make-v8.sh with Git Bash - we already require the git tools for testing and what this is doing actually increases the dependency on git. While for actually running tests it is always better to use cmd (to avoid tty being a pipe), for a setup stage I believe reusing the script would be better.

@refack
Copy link
Contributor

refack commented Jul 10, 2017

running make-v8.sh with Git Bash - we already require the git tools for testing

Just backing up @joaocgreis - I'm using the Git-for-Windows make to run make lint and some git hooks, works very well.
Also AFAICT this is a opt-in operation so I would have considered adding the GfW toolset even as new requirement just like depot_tools.

@kunalspathak
Copy link
Member Author

You might also consider running make-v8.sh with Git Bash

@joaocgreis - Thanks for the suggestion, i didn't realize that we could do this. I will test it out and if it works then I will re-use make-v8.sh.

So, this PR is missing that step before building

Yes, I realized it when i was refactoring. I mis-read cleanup function and was calling at the end of test. I will fix it.

@joaocgreis
Copy link
Member

@kunalspathak just to be sure we're on the same page: those are mutually exclusive steps, if you re-use make-v8.sh then cleanup is not needed in vcbuild.bat.

@kunalspathak
Copy link
Member Author

Yep, i understand that 😄

@kunalspathak
Copy link
Member Author

ping. any other comments?

Copy link
Member

@gibfahn gibfahn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some questions (not really sure about any of them, I don't know enough about batch).

vcbuild.bat Outdated
echo Failed to find a suitable depot tools to test v8
goto exit

:restorepath
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe restorecwd or similar? I thought this was changing the %PATH%.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure.

vcbuild.bat Outdated
@@ -216,6 +222,10 @@ echo Try to run in a "Developer Command Prompt" or consult
echo https://github.com/nodejs/node/blob/master/BUILDING.md#windows-1
goto exit

:depot-tools-not-found
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason this is defined twice?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One of them need to go

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should not be defined twice. I will remove one.

vcbuild.bat Outdated
call python tools\run-tests.py %common_v8_test_options% benchmarks --junitout ./v8-benchmarks-tap.xml
goto restorepath

:depot-tools-not-found
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Second definition here.

Follow on question, as it's only called once, is there a need for a separate goto for it at all? IDK what others think, but for me every goto adds significant mental complexity, so if it's avoidable I'd like to avoid it.

vcbuild.bat Outdated
goto exit

:restorepath
cd %~dp0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this should be part of the exit process for vcbuild.bat. I see we cd %~dp0 at the beginning, is there a reason not do do it at the end as well (cc/ @joaocgreis )?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

popd

vcbuild.bat Outdated
echo running 'ninja -C out.gn/%test_args% %v8_build_options%'
call ninja -C out.gn/%test_args% %v8_build_options% > nul 2> nul
if errorlevel 1 goto exit
set path=%savedpath%
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AIUI if any of the above commands fail then the user's PATH is not restored. Same question as for %dp0, should we be doing this as part of exit?

I guess you could do:

if defined savedpath set path=%savedpath%

and then any other part of the script that modifies the path wouldn't have to worry about resetting it.

vcbuild.bat Outdated
if "%config%"=="Debug" set test_args=%target_arch%.debug
if "%config%"=="Release" set test_args=%target_arch%.release
set savedpath=%path%
set path=%DEPOT_TOOLS_PATH%;%path%
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason you went with CAPS for %DEPOT_TOOLS_PATH% but not elsewhere? I know Windows env vars are case-agnostic, but I'm not sure if there are any common defaults people use (e.g. lowercase for local, uppercase for global).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

%DEPOT_TOOLS_PATH% if defined by depot_tools so it's not our call.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But if %DEPOT_TOOLS_PATH% is defined, doesn't that mean that %depot_tools_path% is also defined?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah but that's not cricket.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gibfahn - I followed the syntax of environment variables defined outside the script to be all caps. e.g. VS140COMNTOOLS, PROCESSOR_ARCHITEW6432, etc. I see that some tooling related environment variables are also all caps, e.g. GYP_MSVS_VERSION. But again i am open to change if you strongly feel like that.

vcbuild.bat Outdated
call python tools\dev\v8gen.py %test_args% > nul 2> nul
if errorlevel 1 goto exit
echo running 'ninja -C out.gn/%test_args% %v8_build_options%'
call ninja -C out.gn/%test_args% %v8_build_options% > nul 2> nul
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So for these two commands if something fails then will there be any output? I assume you're &> nul because otherwise it spews too much out to the screen, but (e.g. if we start running this in CI) it might be useful to know what went wrong. Or maybe it just doesn't really fail?

I guess you could output to a logfile, and then echo something at the beginning saying errors logged to blah.log (or whatever it should be).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see no reason to swallow or log to file. Let it flow just like in the call to MSbuild

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, primary reason was it was outputing a lot. I like @refack suggestion and will let it flow like msbuild.

vcbuild.bat Outdated
@@ -216,6 +222,10 @@ echo Try to run in a "Developer Command Prompt" or consult
echo https://github.com/nodejs/node/blob/master/BUILDING.md#windows-1
goto exit

:depot-tools-not-found
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One of them need to go

vcbuild.bat Outdated
call python tools\dev\v8gen.py %test_args% > nul 2> nul
if errorlevel 1 goto exit
echo running 'ninja -C out.gn/%test_args% %v8_build_options%'
call ninja -C out.gn/%test_args% %v8_build_options% > nul 2> nul
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see no reason to swallow or log to file. Let it flow just like in the call to MSbuild

vcbuild.bat Outdated
echo calling: tools\make-v8.sh
sh tools\make-v8.sh
if errorlevel 1 goto exit
cd %~dp0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not needed as it's a precondition for this whole script and done in L3

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep.

vcbuild.bat Outdated
if "%config%"=="Debug" set test_args=%target_arch%.debug
if "%config%"=="Release" set test_args=%target_arch%.release
set savedpath=%path%
set path=%DEPOT_TOOLS_PATH%;%path%
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather require this as a precondition for running.
Test, and if it's not set, err, like with if not defined DEPOT_TOOLS_PATH

If all you need is ninja you could

where ninja > nul 2>nul
if errorlevel 1 echo depot_tools not set-up & goto exit

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't follow you. if not defined DEPOT_TOOLS_PATH would make sure depot_tools are in path. If ninja is not there, it will anyway fail when invoked. I know it is better to check upfront, but sync script calls other tools/scripts that also have to be in path and if not, things will fail when invoked.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIK when depot_tools are set-up Path already includes DEPOT_TOOLS_PATH, so if you could test that and fail, it would be nicer than manipulation the Path.
If it's not simple, then current solution is Ok.

vcbuild.bat Outdated
cd %~dp0
cd deps\v8
echo running 'python tools\dev\v8gen.py %test_args%'
call python tools\dev\v8gen.py %test_args% > nul 2> nul
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let the output flow

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure.

@@ -83,6 +85,10 @@ if /i "%1"=="test-async-hooks" set test_args=%test_args% async-hooks&goto arg-o
if /i "%1"=="test-all" set test_args=%test_args% gc internet pummel %common_test_suites%&set build_testgc_addon=1&set cpplint=1&set jslint=1&goto arg-ok
if /i "%1"=="test-node-inspect" set test_node_inspect=1&goto arg-ok
if /i "%1"=="test-check-deopts" set test_check_deopts=1&goto arg-ok
if /i "%1"=="test-v8" set test_v8=1&set custom_v8_test=1&goto arg-ok
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not: I'd prefer you align to if /i "%1"=="test-check-deopts"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are other checks that are not aligned. e.g. test-all above. test-v8 aligns to test-all and other shorter if checks.

vcbuild.bat Outdated
sh tools\make-v8.sh
if errorlevel 1 goto exit
cd %~dp0
cd deps\v8
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pushd

vcbuild.bat Outdated
goto exit

:restorepath
cd %~dp0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

popd

goto test-v8

:test-v8
if not defined custom_v8_test goto cpplint
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd still would like this block to move to tools\test-v8.cmd
and here leave

call tools\test-v8.cmd
goto cpplint

AFAICT everything else will fall into place.

vcbuild.bat Outdated
@@ -513,9 +525,15 @@ echo %cmd1%
%cmd1%
exit /b %ERRORLEVEL%

:test-v8-exit
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this still needed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

weird, I thought I removed this and moved it to test-v8.bat. I will remove it. Sorry about that.

if "%config%"=="Debug" set test_args=%target_arch%.debug
if "%config%"=="Release" set test_args=%target_arch%.release
set savedpath=%path%
set path=%DEPOT_TOOLS_PATH%;%path%
Copy link
Contributor

@refack refack Jul 18, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now you can SETLOCAL and ENDLOCAL in :test-v8-exit and then I don't care what monstrosities you do to poor old Path

@refack
Copy link
Contributor

refack commented Jul 18, 2017

Ohhhh, so pretty. If only we used the sub-script approach earlier....

@kunalspathak
Copy link
Member Author

@gibfahn - Do you have any other comments or should we land this?

@kunalspathak
Copy link
Member Author

I will land this PR tomorrow if no one objects.

`vcbuild.bat test-v8` : Runs unit test from v8 repo
`vcbuild.bat test-v8-intl` : Runs intl test from v8 repo
`vcbuild.bat test-v8` : Runs benchmarks from v8 repo

The runs needs
https://www.chromium.org/developers/how-tos/install-depot-tools
installed on the machine expects environment variable
`DEPOT_TOOLS_PATH` to be set to the path.

Set environment variable `DISABLE_V8_I18N` to disable i18n.

PR-URL: nodejs#13992
Refs: nodejs#4704
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
@kunalspathak
Copy link
Member Author

@kunalspathak kunalspathak merged commit 09dd6bb into nodejs:master Jul 27, 2017
addaleax pushed a commit that referenced this pull request Jul 27, 2017
`vcbuild.bat test-v8` : Runs unit test from v8 repo
`vcbuild.bat test-v8-intl` : Runs intl test from v8 repo
`vcbuild.bat test-v8` : Runs benchmarks from v8 repo

The runs needs
https://www.chromium.org/developers/how-tos/install-depot-tools
installed on the machine expects environment variable
`DEPOT_TOOLS_PATH` to be set to the path.

Set environment variable `DISABLE_V8_I18N` to disable i18n.

PR-URL: #13992
Refs: #4704
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
@addaleax addaleax mentioned this pull request Aug 2, 2017
@MylesBorins
Copy link
Contributor

Should this be backported to v6.x-staging? If yes please follow the guide and raise a backport PR, if no let me know or add the dont-land-on label.

@MylesBorins
Copy link
Contributor

ping @nodejs/platform-windows

@joaocgreis
Copy link
Member

I don't think this needs to be backported to v6. This is mainly to test floating patches on V8, I believe those will not be common in v6 in the future.

@MylesBorins
Copy link
Contributor

MylesBorins commented Oct 24, 2017 via email

@refack refack self-assigned this Oct 24, 2017
@refack
Copy link
Contributor

refack commented Oct 24, 2017

I'll backport.

@refack refack removed their assignment Oct 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build Issues and PRs related to build files or the CI. windows Issues and PRs related to the Windows platform.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants