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

Update to latest version of tap and tap-parser #314

Closed
wants to merge 23 commits into from

Conversation

nelsonic
Copy link
Contributor

@nelsonic nelsonic commented Aug 28, 2016

This pull request updates devDependencies to the latest version of tap & tap-parser
( as discussed in: #312 )

Had to remove tap.createConsumer in favour of concat-stream which is being used in: test/circular-things.js#L3

Hopefully the changes are self-explanatory and not too much diff.

ps.stdout.pipe(tc);
});
}));
});
Copy link
Collaborator

Choose a reason for hiding this comment

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

please make sure all files end in a trailing newline

@ljharb
Copy link
Collaborator

ljharb commented Aug 28, 2016

So far this looks good.

…mer (no longer available) updating to latest version of tap tape-testing#312
@nelsonic nelsonic changed the title [Work-in-Progress] Update to latest version of Tap Update to latest version of tap and tap-parser Aug 28, 2016
@nelsonic
Copy link
Contributor Author

@ljharb build passing. ready for feedback. (thanks!)


tt.equal(rs,
'TAP version 13\n'
Copy link
Collaborator

Choose a reason for hiding this comment

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

these might read cleaner if they were arrays with .join('\n')?

Copy link
Collaborator

Choose a reason for hiding this comment

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

or alternatively, .split('\n') on line 10

Copy link
Contributor Author

@nelsonic nelsonic Aug 28, 2016

Choose a reason for hiding this comment

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

@ljharb yeah, I saw several approaches in the existing tests:
test/circular-things.js#L11-L27 vs: test/skip.js#L11-L21 vs: stackTrace.js#L29-L51 ... happy to go with either, which is preferable?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Contributor Author

@nelsonic nelsonic Aug 28, 2016

Choose a reason for hiding this comment

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

Ok, cool I will loop through all the files this evening and change them to match the .join('\n') sample in test/skip.js (thanks again for the feedback!)

@nelsonic
Copy link
Contributor Author

nelsonic commented Aug 28, 2016

@ljharb tests updated to match the format in test/skip.js as discussed in. (ready for review. thanks!)


tap.test('default messages', function (t) {
t.plan(1);

var tc = tap.createConsumer();
var ps = spawn(process.execPath, [ __dirname + '/messages/defaults.js' ]);
Copy link
Collaborator

@ljharb ljharb Aug 29, 2016

Choose a reason for hiding this comment

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

let's use path.join here - ideally the / is never hardcoded, so things work on Windows (even though that's already the case in master)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ljharb, thanks for the tip on cross-platform compatibility. 👍
do we need to remove all forward slashes?
or is it enough to go from:

var ps = spawn(process.execPath, [ __dirname + '/messages/defaults.js' ]);

To:

var ps = spawn(process.execPath, [ require('path').join( __dirname, 'messages/defaults.js') ]);

From @domenic's Gist: https://gist.github.com/domenic/2790533#paths-and-urls I deduce that this should be enough.

Copy link
Contributor Author

@nelsonic nelsonic Aug 29, 2016

Choose a reason for hiding this comment

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

And if we change this one instance, should we change all (Five) occurrences:
https://github.com/substack/tape/search?utf8=%E2%9C%93&q=spawn%28process.execPath ? (just say the word and I'll update them all to be consistently windows-friendly)

Copy link
Collaborator

Choose a reason for hiding this comment

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

That gist uses slashes in path.relative (which also won't work, I think), but no, we'd want path.join(__dirname, 'messages', 'defaults.js') (you can verify because path.join('a', 'b\\c') doesn't result in a/b/c, so you can assume that the reverse wouldn't hold in Windows). Yes, it'd be great to update them all.

Copy link
Collaborator

Choose a reason for hiding this comment

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

The reverse does hold in Windows.

Domenic@Revan MINGW64 ~/Dropbox/Programming/WIP/custom-elements-copier (master)
$ node
> path.join("a", "b/c")
'a\\b\\c'

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah, that's fascinating, and good to know. So unix paths get special treatment that windows paths don't?

Copy link
Collaborator

Choose a reason for hiding this comment

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

The Windows OS treats / as \ in cases like this, so Node chooses to normalize since doing so has no effect besides making the string consistent. (POSIX does not act symmetrically.)

Copy link
Collaborator

Choose a reason for hiding this comment

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

@nelsonic in that case, path.join( __dirname, 'messages/defaults.js') is fine throughout. Thanks!

@nelsonic
Copy link
Contributor Author

@ljharb updates made as discussed in the in-line comments. #314 (comment) Thanks.

@nelsonic
Copy link
Contributor Author

nelsonic commented Sep 1, 2016

@ljharb please let me know if anything else is required. (thanks again!)


tap.test('default messages', function (t) {
t.plan(1);

var tc = tap.createConsumer();
var ps = spawn(process.execPath,
[ require('path').join(__dirname, 'messages', 'defaults.js') ]);
Copy link
Collaborator

Choose a reason for hiding this comment

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

i'd prefer this indentation to be such that if the entire invocation doesn't fit on one line, each argument goes on a line by itself, as does the closing invocation paren.

Copy link
Contributor Author

@nelsonic nelsonic Sep 2, 2016

Choose a reason for hiding this comment

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

@ljharb like this:

var ps = spawn(
  process.execPath,
  [ require('path').join(__dirname, 'messages', 'defaults.js') ]
);

There does not appear to be a line-length rule/guideline in the project.
in-lining the the code is 96 characters is that acceptable?

var ps = spawn(process.execPath, [ require('path').join(__dirname, 'messages', 'defaults.js') ]);

(I'm used to aiming for max 80 chars per line...)

Copy link
Collaborator

Choose a reason for hiding this comment

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

The first example is exactly what I had in mind.

Personally I find "max line length" restrictions silly. If your first example is too long for you, you could do:

var path = require('path');
var ps = spawn(
  process.execPath,
  [
    path.join(__dirname, 'messages', 'defaults.js')
  ]
);

(in either case, please move the require to a variable at the top level)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point!
Went with the single line with the `require('path') moved above its only 89 chars which I think is acceptable:

var ps = spawn(process.execPath, [path.join(__dirname, 'messages', 'defaults.js')]);

@ljharb
Copy link
Collaborator

ljharb commented Sep 2, 2016

Thanks, I think this looks great, and the work is very appreciated!

If you don't mind, it would be great to rebase this down to remove all the "tidy" kind of commits, so that each commit represents a single conceptual change - if that's too much trouble, it's OK, but it'd be nice :-)

After that I'll merge this!

@nelsonic
Copy link
Contributor Author

nelsonic commented Sep 2, 2016

@ljharb see: #318 (is that OK?)

@nelsonic nelsonic closed this Sep 2, 2016
@ljharb
Copy link
Collaborator

ljharb commented Sep 2, 2016

Thanks, that'll be fine - although I'd have preferred to merge this as-is rather than open a second PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants