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: make 'make test' run linter and build docs #22031

Closed
wants to merge 1 commit into from

Conversation

rubys
Copy link
Member

@rubys rubys commented Jul 30, 2018

Before this change, the comment for 'make test' read as follows:

## Runs default tests, linters, and builds docs

What it actually did was:

  • run build-addons twice
  • run build-addons-napi twice
  • run cctest once
  • run jstest once
  • not run linters
  • not build docs

Arguably, one could make the comments match the code, or the code match the
comments. Given that there is a separate make target named test-only that
does exactly what test did, I went the other way.

Along the way, other fixes were made:

  • build-addons and build-addons-napi were listed as .PHONY, but had
    no commands defined. I removed the .PHONY markers and moved them to
    test/addons/.buildstamp and test/addons-napi/.buildstamp where they
    would have the desired effect.
  • tools/doc/node_modules was listed as .PHONY and did not depend on
    tools/doc/package.json. This caused it to unnecessary run every time
    it was referenced.

After these changes, make test will:

  • run build-addons once
  • run build-addons-napi once
  • run cctest once
  • run jstest once
  • run linters once
  • build docs once
Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • commit message follows commit guidelines

Before this change, the comment for 'make test' read as follows:

    ## Runs default tests, linters, and builds docs

What it actually did was:

 * run build-addons twice
 * run build-addons-napi twice
 * run cctest once
 * run jstest once
 * not run linters
 * not build docs

Arguably, one could make the comments match the code, or the code match the
comments.  Given that there is a separate make target named `test-only` that
does exactly what `test` did, I went the other way.

Along the way, other fixes were made:

 * `build-addons` and `build-addons-napi` were listed as `.PHONY`, but had
   no commands defined.  I removed the `.PHONY` markers and moved them to
   `test/addons/.buildstamp` and `test/addons-napi/.buildstamp` where they
   would have the desired effect.
 * `tools/doc/node_modules` was listed as `.PHONY` and did not depend on
   `tools/doc/package.json`.  This caused it to unnecessary run every time
   it was referenced.

After these changes, `make test` will:

 * run build-addons once
 * run build-addons-napi once
 * run cctest once
 * run jstest once
 * run linters once
 * build docs once
@nodejs-github-bot nodejs-github-bot added the build Issues and PRs related to build files or the CI. label Jul 30, 2018
@vsemozhetbyt
Copy link
Contributor

@@ -276,7 +281,7 @@ test-only: all ## For a quick test, does not run linter or build docs.
$(MAKE) build-addons
$(MAKE) build-addons-napi
$(MAKE) cctest
$(MAKE) jstest
$(MAKE) test-js
Copy link
Member

Choose a reason for hiding this comment

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

Would it not be better to remove the addon parts from this task and keep jstest? Just the cctest would have to move below. The same for the other entries.

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 make rule is designed to run a number of steps serially. Depending on jstest would enable make to run these commands in parallel; and in particular, before all is completed. Note that the definition of build-addons does not require $(NODE_EXE) to be present.

build-addons: | $(NODE_EXE) test/addons/.buildstamp

@refack refack added the tools Issues and PRs related to the tools directory. label Jul 30, 2018
@refack
Copy link
Contributor

refack commented Jul 30, 2018

build-addons and build-addons-napi were listed as .PHONY, but had
no commands defined. I removed the .PHONY markers and moved them to
test/addons/.buildstamp and test/addons-napi/.buildstamp where they
would have the desired effect.

I understand that empirically this change achieves the desired result, but I'm not sure I understand why. AFAICT .PHONY targets are for targets that are "commands" and don't actuly output files. But in this case test/addons/.buildstamp and test/addons-napi/.buildstamp are files, while build-addons and build-addons-napi aren't.

/CC @nodejs/build-files

@rubys
Copy link
Member Author

rubys commented Jul 30, 2018

@refack at this point, the @touch $@ statements in these two rules are superfluous. Once a rule is marked as .PHONY, it matters not whether there is a corresponding file or what its timestamp might be.

@@ -356,7 +362,6 @@ test/addons/.buildstamp: config.gypi \
"$$PWD/deps/npm/node_modules/node-gyp/bin/node-gyp.js" "$$PWD/test/addons"
touch $@

.PHONY: build-addons
Copy link
Member

Choose a reason for hiding this comment

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

build-addons should remain .PHONY as it does not refer to a file.

@@ -387,7 +393,6 @@ test/addons-napi/.buildstamp: config.gypi \
"$$PWD/test/addons-napi"
touch $@

.PHONY: build-addons-napi
Copy link
Member

Choose a reason for hiding this comment

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

build-addons-napi should remain .PHONY as it does not refer to a file.

@@ -342,6 +347,7 @@ ADDONS_BINDING_SOURCES := \
$(filter-out test/addons/??_*/*.cc, $(wildcard test/addons/*/*.cc)) \
$(filter-out test/addons/??_*/*.h, $(wildcard test/addons/*/*.h))

.PHONY: test/addons/.buildstamp
Copy link
Member

Choose a reason for hiding this comment

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

If we're going to make this target .PHONY, I would remove the touch so it's no longer a file and probably rename the target so it doesn't look like a file either.

@@ -374,6 +379,7 @@ ADDONS_NAPI_BINDING_SOURCES := \
$(filter-out test/addons-napi/??_*/*.cc, $(wildcard test/addons-napi/*/*.cc)) \
$(filter-out test/addons-napi/??_*/*.h, $(wildcard test/addons-napi/*/*.h))

.PHONY: test/addons-napi/.buildstamp
Copy link
Member

Choose a reason for hiding this comment

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

If we're going to make this target .PHONY, I would remove the touch so it's no longer a file and probably rename the target so it doesn't look like a file either.

@Trott
Copy link
Member

Trott commented Aug 5, 2018

Not sure when it changed, but make test used to run linters like the comment says. It would be great to have that behavior restored before Code + Learn in October. It will be an annoyance otherwise.

@maclover7
Copy link
Contributor

ping @rubys

@maclover7 maclover7 added the wip Issues and PRs that are still a work in progress. label Aug 11, 2018
@BridgeAR
Copy link
Member

BridgeAR commented Sep 6, 2018

This needs a rebase and the comments have to be looked at.

@Trott
Copy link
Member

Trott commented Nov 20, 2018

@rubys Still working on this?

@BridgeAR
Copy link
Member

Closing due to long inactivity. @rubys please feel free to reopen or open a new PR in case you would like to continue working on this.

@BridgeAR BridgeAR closed this Mar 10, 2019
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. tools Issues and PRs related to the tools directory. wip Issues and PRs that are still a work in progress.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants