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

test, build: add test-ci wrappers #12874

Closed
wants to merge 7 commits into from
Closed

Conversation

refack
Copy link
Contributor

@refack refack commented May 6, 2017

Ref: #12830 (comment)
Fixes: #12771

Added scripts that use the same args as the CI for use with single files or suites

Need help reviewing the change in Makefile whether it's safe as it bypasses the PYTHON var in config.mk

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

@nodejs-github-bot nodejs-github-bot added build Issues and PRs related to build files or the CI. test Issues and PRs related to the tests. tools Issues and PRs related to the tools directory. windows Issues and PRs related to the Windows platform. labels May 6, 2017
@refack
Copy link
Contributor Author

refack commented May 6, 2017

/cc @nodejs/build @nodejs/python

@refack
Copy link
Contributor Author

refack commented May 6, 2017

@refack refack added the help wanted Issues that need assistance from volunteers or PRs that need help to proceed. label May 6, 2017
tools/test-ci.sh Outdated
@@ -0,0 +1,3 @@
pushd `dirname $0`/.. > /dev/null
Copy link
Member

Choose a reason for hiding this comment

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

Please add a shebang line at the top of this file.

Also, just use cd, pushd isn’t a common feature of all POSIX shells (and there’s no need to do the redirect).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

tools/test-ci.sh Outdated
@@ -0,0 +1,3 @@
pushd `dirname $0`/.. > /dev/null
`which python` tools/test.py -J --mode=release $*
Copy link
Member

Choose a reason for hiding this comment

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

Regarding your question in the PR description, you may want to look into using $PYTHON here (and possible exporting that in the Makefile beforehand, I’m not sure)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Read, and found the way, thanks


test-valgrind: all
$(PYTHON) tools/test.py --mode=release --valgrind sequential parallel message

test-check-deopts: all
$(PYTHON) tools/test.py --mode=release --check-deopts parallel sequential -J
$(TEST_CI) --check-deopts parallel sequential
Copy link
Member

Choose a reason for hiding this comment

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

I have to admit I don’t quite get what the goal of these changes is?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Standardizing the calls to python tools\test.py
I admit that I'm not sure of the benefit of the changes in Makefile, especially if there is risk of breakage

vcbuild.ps1 Outdated

:exit
if not defined DISTTYPEDIR $DISTTYPEDIR=%DISTTYPE%
goto :EOF
Copy link
Member

Choose a reason for hiding this comment

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

Can I suggest adding this file in a second commit (or PR)? The changes don’t seem related?

@refack refack force-pushed the test-ci-wrappers branch from 7649cde to c8a62a0 Compare May 6, 2017 18:56
* Replace explicit use in `Makefile` and `vcbuild.bat`
@refack refack force-pushed the test-ci-wrappers branch from c8a62a0 to 7ff770c Compare May 6, 2017 18:59
@refack
Copy link
Contributor Author

refack commented May 6, 2017

@addaleax the .ps1 file leaked in, now replaced with the actual vcbuild.bat

@refack refack changed the title test, build, Test ci wrappers test, build: add test-ci wrappers May 6, 2017
Copy link
Member

@addaleax addaleax left a comment

Choose a reason for hiding this comment

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

This only seems to add abstraction that we don’t really need, so I’m -0 on it

tools/test-ci.sh Outdated
@@ -0,0 +1,4 @@
#!/bin/bash
cd `dirname $0`/.. > /dev/null
if [ -z ${PYTHON+x} ]; then export PYTHON=`which python`; fi
Copy link
Member

Choose a reason for hiding this comment

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

if [ -z "$PYTHON" ]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Yes, but I think setting PYTHON='' should give the default behaviour. Also, setting PYTHON=python in the then case here should be just fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

PYTHON=`which python` is for me, when running in WSL (Windows System for Linux) there's a bad behaviour where it'll try to run the windows python over the Ubuntu one 🤷‍♀️

@@ -0,0 +1,3 @@
pushd %~dp0\..
python tools\test.py -J --mode=release %*
popd
Copy link
Member

Choose a reason for hiding this comment

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

just curious, does the Windows cmd actually require this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, it doesn't spawn a subshell so it cd the caller

tools/test-ci.sh Outdated
#!/bin/bash
cd `dirname $0`/.. > /dev/null
if [ -z ${PYTHON+x} ]; then export PYTHON=`which python`; fi
${PYTHON} tools/test.py -J --mode=release $*
Copy link
Member

Choose a reason for hiding this comment

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

"$PYTHON" or "${PYTHON}"

@mscdex
Copy link
Contributor

mscdex commented May 6, 2017

I think I'm -1 on this. I'd rather not have command line arguments hidden. This would require you to go and look at the contents of the script to see what's currently being passed if you run into unexpected behavior, etc.

@addaleax
Copy link
Member

addaleax commented May 6, 2017

One more thing I just noticed: The wrapper scripts don’t forward errors from the test runner properly

@refack
Copy link
Contributor Author

refack commented May 6, 2017

One more thing I just noticed: The wrapper scripts don’t forward errors from the test runner properly

you mean ERRORLEVEL / exit code?

@refack
Copy link
Contributor Author

refack commented May 6, 2017

I'd rather not have command line arguments hidden.

I agree it's a mixed bag...
On the one hand you get standardization (as the thread in #12830 (comment) discusses) and gives one point of change
On the other hand there is the abstraction...

Something to think about....

@refack
Copy link
Contributor Author

refack commented May 6, 2017

@@ -12,6 +12,7 @@ LOGLEVEL ?= silent
OSTYPE := $(shell uname -s | tr '[A-Z]' '[a-z]')
COVTESTS ?= test
GTEST_FILTER ?= "*"
export PYTHON
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it necessary to export it? Modifying environment variables as a side effect of make may be an unexpected behavior. I'd rather require users to either export it explicitly or prepend each command with PYTHON=....

Copy link
Contributor Author

Choose a reason for hiding this comment

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

From what I read in the Makefile man it is only "exported" to subshells, no the caller.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Verified. It does not leak.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, okay. If that's the case, then fine.

@gibfahn
Copy link
Member

gibfahn commented May 6, 2017

To continue from #12830 (comment)

It'll take $*, so it's useful for single files, or single suites.
I don't know about make test-ci but vcbuild test-ci builds first (with Feet of clay), very demotivating.

I get the problem that this is trying to solve, but I think the downside of adding an extra level of indirection (and another file that people have to know about) outweighs the benefit of having a standard way to run things, especially as the CI runs tools/test.py with almost the default options. I'd rather either default to -J or drop my objection in #12830 (comment) than do this.

The windows build sounds like a problem, and I think it's definitely one we should look at. Does it still rebuild if you do vcbuild nobuild test-ci (from what I recall you have to tell vcbuild not to rebuild, it can't work it out itself)? If yes then we should fix that.


On another note if you've got a WIP version of vcbuild.ps1 I'd be interested in seeing it in PR form, and it might save time and effort to get feedback from Windows Node people earlier in the design process.

@refack
Copy link
Contributor Author

refack commented May 6, 2017

I get the problem that this is trying to solve, but I think the downside of adding an extra level of indirection

Actually I kind of started liking this, since it's self documenting code: "How does the CI call test.py" -> "as is written in test-ci.sh"

But If this gets -1 votes, I have no problem shelving it.

Although I'd ask you all to think about it some more, less then as "another tool" but more as "refactoring out" all those same calls from the files I touched.


@gibfahn as for the WIP vcbuild.ps1 I've started with @joaocgreis's advice to try to 1-1 convert the .bat file (which is mostly busy work, but it keeps me out of trouble 😉 ) https://gist.github.com/refack/969ecc6642981bfd7caef7d948d78076

@@ -43,6 +44,7 @@ NODE_EXE = node$(EXEEXT)
NODE ?= ./$(NODE_EXE)
NODE_G_EXE = node_g$(EXEEXT)
NPM ?= ./deps/npm/bin/npm-cli.js
TEST_CI = ./tools/test-ci.sh
Copy link
Member

Choose a reason for hiding this comment

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

If you made this something like:

TEST_CI = tools/test.py --mode=release -J

then wouldn't you get the same deduplication without the indirection of a separate file?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But what about vcbuild.bat and the case of #12830 & #12771
I was actually thinking of refactoring ALL the similar cases into tools/make to help alleviate #12425
But on the other hand Makefile can almost be read like a configuration file...

Anyway we should all move to ninja with one node.ninja for all ✊

Copy link
Member

@gibfahn gibfahn May 8, 2017

Choose a reason for hiding this comment

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

I'm pretty sure --mode=release is the default, so if we made -J the default as well then we definitely wouldn't need this indirection.

But what about vcbuild.bat

This doesn't help with that though, you still have the tools/test.py command duplicated in Windows and Unix files.

and the case of #12830 & #12771

I think people should run tools/test.py directly, this discourages them from doing that.

Anyway we should all move to ninja with one node.ninja for all ✊

SGTM

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But on the other hand Makefile can almost be read like a configuration file...

What about creating a mechanism with an explicit configuration file, that all script derive from...
(could be a Template filled by GYP)
something like:

test-cl:
  "${PYTHON}" tools/test.py -J --mode=release $*
test-seq:
  "${PYTHON}" tools/test.py --mode=release $*
test-deopt:
  ${test-cl} --check-deopts $*

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Or hooking it into git (since it's already a requirement, and is platform uniform), then we could do

$ git tool test-cl parallel/test-stream2-transform
$ git tool lint
$ git tool benchmark buffers/buffer-tostring.js len=1024

Copy link
Member

Choose a reason for hiding this comment

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

@refack git is not a requirement for testing, tho

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@refack git is not a requirement for testing, tho

so a dual runner, git tool and node tool. One for bootstrapping, one for post-build tooling.
Could even throw in a python tool for the extreme minimalists...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@addaleax for the whole concept?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, I don’t think we should duplicate the same functionality over 2 or even 3 implementations.


If you want honest advice: Close this PR, or at least let it rest until you find somebody that thinks this is a good idea. Multiple people here have expressed doubt about the usefulness of this, and in a consensus-seeking model that’s a sign that it’s just not going to happen. And so the chances are, the more work you put into this, the more frustrated you’re going to be when the PR just stalls and doesn’t go anywhere.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If you want honest advice: Close this PR

Yeah I've already put it on the back burner #12874 (comment)

Just kicking around the idea...

@@ -0,0 +1,5 @@
#!/bin/bash
Copy link
Contributor

Choose a reason for hiding this comment

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

#!/usr/bin/env bash

would be more portable, right?

Copy link
Member

Choose a reason for hiding this comment

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

Yep. But here it should be #!/bin/sh anyway, not bash.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

does sh have if [ -z?

Copy link
Member

Choose a reason for hiding this comment

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

Yes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ack

@refack
Copy link
Contributor Author

refack commented Jul 22, 2017

Not really need

@refack refack closed this Jul 22, 2017
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. help wanted Issues that need assistance from volunteers or PRs that need help to proceed. test Issues and PRs related to the tests. tools Issues and PRs related to the tools directory. windows Issues and PRs related to the Windows platform.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

doc, test: question about test.py -v key in CONTRIBUTING.md
7 participants