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

add unified diff separator #2846

Merged

Conversation

olsonpm
Copy link
Contributor

@olsonpm olsonpm commented May 31, 2017

  • fix issue Base reporter, add unified diff separator #2295
  • the purpose of this feature is to make the unified diff
    format more readable. Without it, different portions
    of the same actual/expected diff look contiguous even
    though they are actually separated by the default
    context of four lines.

@jsf-clabot
Copy link

jsf-clabot commented May 31, 2017

CLA assistant check
All committers have signed the CLA.

@olsonpm
Copy link
Contributor Author

olsonpm commented May 31, 2017

I know the label said 'semver major' - but I didn't see a major branch to point the PR to. I figured master was the correct one, but please let me know if that's incorrect.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 88.288% when pulling 8cf2222 on olsonpm:feature/unified-diff-separator into a054380 on mochajs:master.

Copy link
Contributor

@ScottFreeCode ScottFreeCode left a comment

Choose a reason for hiding this comment

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

Thanks for the implementation! And especially for providing a test with it!

There's one thing about the test that really needs to be updated for full correctness; after that, we'll just have to figured out which branch we want to put semver-major changes in...


regexesToMatch.forEach(function (aRegex) {
errOut.should.match(aRegex);
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of matching each line's regex against the whole output string, which does not guarantee order as far as I am aware, let's either match a single regex covering multiple lines, or else use .forEach(function (aRegex, index) { <next line> errOut.split('\n')[index].should... instead of .forEach(function (aRegex) { <next line> errOut.should...

Copy link
Contributor Author

@olsonpm olsonpm Jun 4, 2017

Choose a reason for hiding this comment

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

When I PR - I try to avoid corrections like these and just stick with the patterns in the existing codebase. I too thought this pattern was weird, but it's what's in the code.

If you really want me to make it different for this particular test I will, but I suggest refactoring them all in a separate PR for more accurate test coverage.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ouch! My bad; I hadn't noticed those tests before.

In that case I'd be fine merging this as-is for consistency and then doing a separate thorough sweep to correct all instances of that pattern.

Thanks for identifying that!

@@ -393,7 +393,7 @@ function inlineDiff (err, escape) {
*/
function unifiedDiff (err, escape) {
var indent = ' ';
function cleanUp (line) {
function cleanUp (line, idx) {
Copy link
Contributor

Choose a reason for hiding this comment

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

The idx added here does not appear to be used?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Whoops - sorry about this. An artifact of my debugging.

@ScottFreeCode ScottFreeCode added the semver-major implementation requires increase of "major" version number; "breaking changes" label Jun 4, 2017
 - fix issue mochajs#2295
 - the purpose of this feature is to make the unified diff
   format more readable.  Without it, different portions
   of the same actual/expected diff look contiguous even
   though they are actually separated by the default
   context of four lines.
@olsonpm olsonpm force-pushed the feature/unified-diff-separator branch from 8cf2222 to 26aaf51 Compare June 4, 2017 16:33
@olsonpm
Copy link
Contributor Author

olsonpm commented Jun 4, 2017

@ScottFreeCode - Just pushed the removal of the unused idx you pointed out. All we need is a branch to push to now.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 88.395% when pulling 26aaf51 on olsonpm:feature/unified-diff-separator into f20de56 on mochajs:master.

@ScottFreeCode ScottFreeCode mentioned this pull request Jul 9, 2017
@ScottFreeCode ScottFreeCode merged commit eaad1e3 into mochajs:master Sep 29, 2017
@olsonpm olsonpm deleted the feature/unified-diff-separator branch September 29, 2017 00:16
@olsonpm
Copy link
Contributor Author

olsonpm commented Sep 29, 2017

i appreciate the time you spent with this. i know it wasn't a high priority nor highly visible issue.

sgilroy pushed a commit to TwineHealth/mocha that referenced this pull request Feb 27, 2019
- fix issue mochajs#2295
 - the purpose of this feature is to make the unified diff
   format more readable.  Without it, different portions
   of the same actual/expected diff look contiguous even
   though they are actually separated by the default
   context of four lines.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver-major implementation requires increase of "major" version number; "breaking changes"
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants