Skip to content

Conversation

@SimenB
Copy link
Member

@SimenB SimenB commented Oct 23, 2018

Requested by @MylesBorins in #560, I thought it'd be easier to land separately to reduce the diff.

This just added the eslint rule and runs autofix

Checklist
  • contribution guidelines followed here

@SimenB SimenB mentioned this pull request Oct 23, 2018
1 task
} else {
log.info(result.name + ' done', 'done - the test suite for ' + result.name
+ ' version ' + result.version + ' passed.');
log.info(`${result.name} done`, `done - the test suite for ${result.name
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 is pretty ugly... I can clean it up manually if you reject #612. If that is accepted, prettier deals with it

Copy link
Member

Choose a reason for hiding this comment

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

what does it look like when prettier is applied?

Copy link
Member Author

@SimenB SimenB Oct 23, 2018

Choose a reason for hiding this comment

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

Diff in this file after applying prettier on top of it:

diff --git c/bin/citgm-all.js w/bin/citgm-all.js
index 0582670..f68433b 100755
--- c/bin/citgm-all.js
+++ w/bin/citgm-all.js
@@ -39,11 +39,13 @@ const yargs = commonArgs(require('yargs'))
     type: 'array',
     description: 'Define which tags from the lookup to skip'
   })
-  .example('citgm-all -t /path/to/output.tap',
-           'Write test results as tap to file.')
+  .example(
+    'citgm-all -t /path/to/output.tap',
+    'Write test results as tap to file.'
+  )
   .example('citgm-all -l /path/to/lookup.json', 'Test a custom set of modules.')
   .example('citgm-all --includeTags express', 'Only test express.')
-  .example('citgm-all --excludeTags native', 'Don\'t test native modules.');
+  .example('citgm-all --excludeTags native', "Don't test native modules.");
 
 const app = yargs.argv;
 
@@ -56,7 +58,7 @@ update(log);
 
 if (!app.su) {
   require('root-check')(); // Silently downgrade if running as root...
-                           // Unless --su is passed
+  // Unless --su is passed
 } else {
   log.warn('root', 'Running as root! Use caution!');
 }
@@ -75,13 +77,17 @@ const options = {
   excludeTags: app.excludeTags || []
 };
 
-if (options.includeTags.length){
-  log.info('includeTags', `Only running tests matching these tags: ${
-       app.includeTags}`);
+if (options.includeTags.length) {
+  log.info(
+    'includeTags',
+    `Only running tests matching these tags: ${app.includeTags}`
+  );
 }
-if (options.excludeTags.length){
-  log.info('excludeTags', `Not running tests matching these tags: ${
-      app.excludeTags}`);
+if (options.excludeTags.length) {
+  log.info(
+    'excludeTags',
+    `Not running tests matching these tags: ${app.excludeTags}`
+  );
 }
 
 const lookup = getLookup(options);
@@ -95,7 +101,7 @@ if (app.autoParallel || (app.parallel && app.parallel > cpus)) {
   app.parallel = cpus;
   log.info('cores', `running tests using ${app.parallel} cores`);
 }
-if (app.parallel && ((app.parallel + 1) > process.getMaxListeners())) {
+if (app.parallel && app.parallel + 1 > process.getMaxListeners()) {
   process.setMaxListeners(app.parallel + 1);
 }
 
@@ -114,7 +120,7 @@ if (!citgm.windows) {
 
 const modules = [];
 
-function runCitgm (mod, name, next) {
+function runCitgm(mod, name, next) {
   if (isMatch(mod.skip)) {
     modules.push({
       name,
@@ -144,30 +150,43 @@ function runCitgm (mod, name, next) {
   process.on('SIGHUP', cleanup);
   process.on('SIGBREAK', cleanup);
 
-  runner.on('start', function(name) {
-    log.info('starting', name);
-  }).on('fail', function(err) {
-    log.error('failure', err.message);
-  }).on('data', function(type, key, message) {
-    log[type](key, message);
-  }).on('end', function(result) {
-    result.duration = new Date() - start;
-    log.info('duration', `test duration: ${result.duration}ms`);
-    if (result.error) {
-      log.error(`${result.name} done`, `done - the test suite for ${
-          result.name} version ${result.version} failed`);
-    } else {
-      log.info(`${result.name} done`, `done - the test suite for ${result.name
-           } version ${result.version} passed.`);
-    }
-    modules.push(result);
-    if (!bailed) {
-      process.removeListener('SIGINT', cleanup);
-      process.removeListener('SIGHUP', cleanup);
-      process.removeListener('SIGBREAK', cleanup);
-    }
-    return next(bailed);
-  }).run();
+  runner
+    .on('start', function(name) {
+      log.info('starting', name);
+    })
+    .on('fail', function(err) {
+      log.error('failure', err.message);
+    })
+    .on('data', function(type, key, message) {
+      log[type](key, message);
+    })
+    .on('end', function(result) {
+      result.duration = new Date() - start;
+      log.info('duration', `test duration: ${result.duration}ms`);
+      if (result.error) {
+        log.error(
+          `${result.name} done`,
+          `done - the test suite for ${result.name} version ${
+            result.version
+          } failed`
+        );
+      } else {
+        log.info(
+          `${result.name} done`,
+          `done - the test suite for ${result.name} version ${
+            result.version
+          } passed.`
+        );
+      }
+      modules.push(result);
+      if (!bailed) {
+        process.removeListener('SIGINT', cleanup);
+        process.removeListener('SIGHUP', cleanup);
+        process.removeListener('SIGBREAK', cleanup);
+      }
+      return next(bailed);
+    })
+    .run();
 }
 
 function runTask(task, next) {
@@ -187,7 +206,7 @@ function launch() {
 
   const q = async.queue(runTask, app.parallel || 1);
   q.push(collection);
-  function done () {
+  function done() {
     q.drain = null;
     reporter.logger(log, modules);
 
@@ -200,12 +219,12 @@ function launch() {
       // If not use `log.bypass` which is currently process.stdout.write
       // TODO check that we can write to that path, perhaps require a flag to
       // Overwrite
-      const tap = (typeof app.tap === 'string') ? app.tap : log.bypass;
+      const tap = typeof app.tap === 'string' ? app.tap : log.bypass;
       reporter.tap(tap, modules, app.append);
     }
 
     if (app.junit) {
-      const junit = (typeof app.junit === 'string') ? app.junit : log.bypass;
+      const junit = typeof app.junit === 'string' ? app.junit : log.bypass;
       reporter.junit(junit, modules, app.append);
     }
 

A bit hard to read the part I commented about due to the whitespace changes, so here's a screenshot with word highlighting:

image

@SimenB
Copy link
Member Author

SimenB commented Oct 23, 2018

Might consider using arrow functions as well. eslint autofixes that as well, want me to send a PR?

@targos
Copy link
Member

targos commented Oct 23, 2018

I'm personally all for it (this PR, prettier, arrow functions). The more we can automate code style, the better.

@nodejs/citgm any objection to doing that?

@SimenB
Copy link
Member Author

SimenB commented Oct 23, 2018

Cool, I'll open up a 3rd PR with arrows (can combine them if you want)

@MylesBorins
Copy link
Contributor

Going to let #560 land before landing this to avoid conflcits

Copy link
Member

@targos targos left a comment

Choose a reason for hiding this comment

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

The PR can be updated

@SimenB
Copy link
Member Author

SimenB commented Nov 24, 2018

I rebased this, the arrow function and the prettier PRs, so they should all be ready to land 🙂

@MylesBorins
Copy link
Contributor

landed in ec66f36

@SimenB SimenB deleted the templates branch November 29, 2018 06:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants