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: swaps var for let/const throughout common module #10177

Closed
wants to merge 1 commit into from
Closed

test: swaps var for let/const throughout common module #10177

wants to merge 1 commit into from

Conversation

homosaur
Copy link
Contributor

@homosaur homosaur commented Dec 8, 2016

Checklist
  • make -j8 test (UNIX), or vcbuild test nosign (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines
Affected core subsystem(s)
Description of change

Swaps var for let/const throughout the common.js module.

Also changes a rogue snake case var to camel case.

@nodejs-github-bot nodejs-github-bot added the test Issues and PRs related to the tests. label Dec 8, 2016
@Trott
Copy link
Member

Trott commented Dec 8, 2016

A bit of a tangent but: Not sure if this will get a 👍 or a 👎 from the maintainers, but either way, if the common.js file is of interest to you, one thing that we definitely need is improved documentation of its properties in test/README.md.

For example, current documentation for allowGlobals() says:

Takes whitelist and concats that with predefined knownGlobals.

That's a correct description of the algorithm, but it doesn't tell you what I might use the function for. (It appends whitelist to the list of known global variables so that variables listed in whitelist are not flagged as unintentionally leaked globals by common.js. It's a way of saying, "I know I'm leaking these global variables, don't warn me about them.")

(No disrespect to @paulgrock who put those initial descriptions there in the first place. Before that, we had nothing. Now, we have a starting point!)

Copy link
Contributor

@cjihrig cjihrig left a comment

Choose a reason for hiding this comment

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

LGTM if the CI passes.

Copy link
Member

@ChALkeR ChALkeR left a comment

Choose a reason for hiding this comment

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

LGTM if the CI check passes.

@ChALkeR
Copy link
Member

ChALkeR commented Dec 8, 2016

commit message follows commit guidelines

It doesn't though, please format the commit message according to https://github.com/nodejs/node/blob/master/CONTRIBUTING.md#step-3-commit

Atm, it is one-line and says:

test: swaps var for let/const throughout

@homosaur
Copy link
Contributor Author

homosaur commented Dec 8, 2016

@ChALkeR I enhanced the commit message with the explanation from this PR. Thought the commit was self explanatory but have read the commit guidelines more thoroughly. Thanks!

@Trott
Copy link
Member

Trott commented Dec 8, 2016

Tiny nit on the commit message (which someone can fix when landing if you don't get around to it): swaps -> swap on the first line. Guidelines say the verb should be "imperative mode" (or at least, that's what I recall) so swap (active command-like) rather than swaps (descriptive).

@Trott
Copy link
Member

Trott commented Dec 8, 2016

@homosaur
Copy link
Contributor Author

homosaur commented Dec 9, 2016

@Trott CI failures seem to be due to pull issues with Jenkins, not code

@Trott
Copy link
Member

Trott commented Dec 9, 2016

Jenkins was having issues. Let's try again.

CI: https://ci.nodejs.org/job/node-test-pull-request/5333/

@@ -165,7 +165,7 @@ Object.defineProperty(exports, 'opensslCli', {get: function() {

if (exports.isWindows) opensslCli += '.exe';

var openssl_cmd = child_process.spawnSync(opensslCli, ['version']);
const openssl_cmd = child_process.spawnSync(opensslCli, ['version']);
Copy link
Contributor

Choose a reason for hiding this comment

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

Now that you are changing this line, can you change the variable name to use camelCase?

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
Contributor

Choose a reason for hiding this comment

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

Thanks @homosaur :-)

@Trott
Copy link
Member

Trott commented Dec 9, 2016

@Trott
Copy link
Member

Trott commented Dec 10, 2016

Single CI failure seems unrelated, but since common.js is central to the tests, let's run again.

CI: https://ci.nodejs.org/job/node-test-pull-request/5348/

@homosaur
Copy link
Contributor Author

@Trott still seems like maybe some technical issues with CI

@Trott
Copy link
Member

Trott commented Dec 14, 2016

NEVER TOO MANY CI RUNS!

CI: https://ci.nodejs.org/job/node-test-pull-request/5397/

@Trott
Copy link
Member

Trott commented Dec 14, 2016

CAN'T GET ENOUGH CI!

CI: https://ci.nodejs.org/job/node-test-pull-request/5398/

@Trott
Copy link
Member

Trott commented Dec 14, 2016

(CI is ✅ even if the widget says otherwise.)

@lpinca
Copy link
Member

lpinca commented Dec 16, 2016

@homosaur I was reading your commit message

The exception is line 42 in the rimrafSync function. Both let and const are causing tons of test failures in that instance.

This seems to work

diff --git a/test/common.js b/test/common.js
index e231547fc5..d138310aa6 100644
--- a/test/common.js
+++ b/test/common.js
@@ -41,8 +41,9 @@ exports.rootDir = exports.isWindows ? 'c:\\' : '/';
 exports.buildType = process.config.target_defaults.default_configuration;
 
 function rimrafSync(p) {
+  let st;
   try {
-    var st = fs.lstatSync(p);
+    st = fs.lstatSync(p);
   } catch (e) {
     if (e.code === 'ENOENT')
       return;

are you ok with swapping that last var?

@homosaur
Copy link
Contributor Author

Sure, @lpinca, I'm glad you found a way around that. I'm curious what causes the variable to need to be instantiated outside the try/catch block but I think it's a way to remove that last bit. Thanks for taking a look at that line.

@homosaur
Copy link
Contributor Author

I'm guessing that try/catch is considered a scoping block for let, which is why it doesn't then understand the st call in the next try/catch block. That makes sense logically.

@lpinca
Copy link
Member

lpinca commented Dec 16, 2016

@homosaur that's because let is block scoped while var isn't.

@lpinca
Copy link
Member

lpinca commented Dec 16, 2016

@homosaur exactly :)

@homosaur
Copy link
Contributor Author

@lpinca Changed block to your suggestion, test suite does pass. Thanks!

@lpinca
Copy link
Member

lpinca commented Dec 16, 2016

@homosaur thanks, can I ask one last thing?

Would you mind updating the commit message to reflect the changes?
Something like this should work:

test: swap var for let/const in common.js module

* swap var for let/const throughout the common.js module
* change variable name from openssl_cmd to opensslCmd

// openssl command cannot be executed
const opensslCmd = child_process.spawnSync(opensslCli, ['version']);
if (opensslCmd.status !== 0 || opensslCmd.error !== undefined) {
// wopenssl command cannot be executed
Copy link
Member

Choose a reason for hiding this comment

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

Nit: typo on "wopenssl" ?

Swap var for let/const throughout the common.js module.
Change a snake case variable to camel case starting on line 168.
@jasnell
Copy link
Member

jasnell commented Dec 23, 2016

@jasnell jasnell self-assigned this Dec 23, 2016
@Trott
Copy link
Member

Trott commented Dec 23, 2016

Linter error was probably the one that was in master for a few hours and not in this PR. Running linter again: https://ci.nodejs.org/job/node-test-linter/6015/

jasnell pushed a commit that referenced this pull request Dec 27, 2016
Swap var for let/const throughout the common.js module.
Change a snake case variable to camel case starting on line 168.

PR-URL: #10177
Reviewed-By: Сковорода Никита Андреевич <[email protected]>
Reviewed-By: Sakthipriyan Vairamani <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
@jasnell
Copy link
Member

jasnell commented Dec 27, 2016

Landed in ecd11b6

@jasnell jasnell closed this Dec 27, 2016
evanlucas pushed a commit that referenced this pull request Jan 3, 2017
Swap var for let/const throughout the common.js module.
Change a snake case variable to camel case starting on line 168.

PR-URL: #10177
Reviewed-By: Сковорода Никита Андреевич <[email protected]>
Reviewed-By: Sakthipriyan Vairamani <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
evanlucas pushed a commit that referenced this pull request Jan 4, 2017
Swap var for let/const throughout the common.js module.
Change a snake case variable to camel case starting on line 168.

PR-URL: #10177
Reviewed-By: Сковорода Никита Андреевич <[email protected]>
Reviewed-By: Sakthipriyan Vairamani <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
@MylesBorins
Copy link
Contributor

This has landed cleanly in v6.x without any problems. Please feel free to manually backport to v4.x-staging

MylesBorins pushed a commit that referenced this pull request Jan 23, 2017
Swap var for let/const throughout the common.js module.
Change a snake case variable to camel case starting on line 168.

PR-URL: #10177
Reviewed-By: Сковорода Никита Андреевич <[email protected]>
Reviewed-By: Sakthipriyan Vairamani <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
MylesBorins pushed a commit that referenced this pull request Jan 24, 2017
Swap var for let/const throughout the common.js module.
Change a snake case variable to camel case starting on line 168.

PR-URL: #10177
Reviewed-By: Сковорода Никита Андреевич <[email protected]>
Reviewed-By: Sakthipriyan Vairamani <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
@MylesBorins MylesBorins mentioned this pull request Jan 24, 2017
MylesBorins pushed a commit that referenced this pull request Jan 31, 2017
Swap var for let/const throughout the common.js module.
Change a snake case variable to camel case starting on line 168.

PR-URL: #10177
Reviewed-By: Сковорода Никита Андреевич <[email protected]>
Reviewed-By: Sakthipriyan Vairamani <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
test Issues and PRs related to the tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants