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

unexpected undefined failure message in output #39

Closed
Jheronymus opened this issue Jun 30, 2021 · 8 comments
Closed

unexpected undefined failure message in output #39

Jheronymus opened this issue Jun 30, 2021 · 8 comments
Assignees
Labels
bug 👾 researching 📡 This issue is being researched and looked into

Comments

@Jheronymus
Copy link

Describe the bug
The tap output from the markdownlint package looks like it is in the tap spec, however the output of the tool does not pick up the failure message.

To Reproduce
Steps to reproduce the behavior:

  1. On windows... npm i -D tap-junit
  2. Save below tap as file input.tap
  3. run npx tap-junit --pretty -o output/tests -n output.xml -i .\input.tap
  4. Compare output

Expected behavior
I expected the comments in the tap file between --- and ... to be in the <failure message="as in here" type="fail" />

Desktop (please complete the following information):

  • OS: Windows & Azure Pipline (running ubuntu latest)
  • Node Version: latest

Additional context
Input example tap

TAP version 13
1..4
not ok 1 - Manual/about.md
  ---
  message: /tmp/lint/Manual/about.md 9 MD025/single-title/single-h1 Multiple top-level headings in the same document [Context  "# About this manual"]
  ...
ok 2 - Manual/welcome.md
ok 3 - Media/README.md
not ok 4 - README.md
  ---
  message: /tmp/lint/README.md 4 MD025/single-title/single-h1 Multiple top-level headings in the same document [Context  "# Getting Started"]\n/tmp/lint/README.md 11 MD025/single-title/single-h1 Multiple top-level headings in the same document [Context  "# Build and Test"]\n/tmp/lint/README.md 17 MD025/single-title/single-h1 Multiple top-level headings in the same document [Context  "# Contribute"]
  ...

Generated output

<?xml version="1.0"?>
<testsuites failures="2" name="markdownlint-junit.xml" tests="4">
	<testsuite failures="2" name="Tap-Junit-Suite" skipped="0" tests="4">
		<testcase id="1" name="Manual/about.md">
			<failure message="undefined" type="fail"/>
		</testcase>
		<testcase id="2" name="Manual/welcome.md"/>
		<testcase id="3" name="Media/README.md"/>
		<testcase id="4" name="README.md">
			<failure message="undefined" type="fail"/>
		</testcase>
	</testsuite>
</testsuites>

Console output:

Tap-Junit: Finished! markdownlint-junit.xml created at -- output/tests

Error: Tap-Junit: Looks like some test suites failed
    at C:\Users\****\node_modules\tap-junit\src\index.js:42:23
@dhershman1
Copy link
Owner

Yeah, I was worried the parser wouldn't work right on this style.

I'll take a look and see what it's doing. Thanks for the report!

@dhershman1 dhershman1 self-assigned this Jun 30, 2021
@dhershman1 dhershman1 added bug 👾 researching 📡 This issue is being researched and looked into labels Jun 30, 2021
@Jheronymus
Copy link
Author

Actually, I'm not sure if my expected result here is the correct one. But that is how I understood the junit5 specification.

@dhershman1
Copy link
Owner

According to junit5 yeah I think you are correct, it should go into message, as far as I know.

@Jheronymus
Copy link
Author

In case of the tap example above, the inputs for the buildFailureParams functions are:

{
  comments: '',
  ok: false,
  id: 4,
  name: 'README.md',
  diag: {
    message: '/tmp/lint/README.md 4 MD025/single-title/single-h1 Multiple top-level headings in the same document [Context  "# Getting Started"]\\n/tmp/lint/README.md 11 MD025/single-title/single-h1 Multiple top-level headings in the same document [Context  "# Build and Test"]\\n/tmp/lint/README.md 17 MD025/single-title/single-h1 Multiple top-level headings in the same document [Context  "# Contribute"]'       
  },
  fullname: ''
}

Then, on

  if (fail.diag) {
    failObj['@message'] = fail.diag.message || fail.todo
      ? `${fail.todo}`
      : `
    ---
    ${formatDiag(fail.diag)}
    ...`
    failObj['@type'] = fail.diag.severity || 'fail'
  }

it sets the message to fail.todo (which is undefined) if either fail.diag.message or fail.todo exists.

I think this can easily be fixed with a if-else if contstruct if you want to have the fail.todo to have preference.
Hope this helps

@dhershman1
Copy link
Owner

Yeah, I just have been pretty swamped with work lately, it's also something I wanted to try and do dynamically if possible. But It should be an easy fix.

@alexandrebrg
Copy link

We currently have this issue with the version 5.0.0 of this package, so for now we rollbacked to 4.2.0.

@dhershman1
Copy link
Owner

v5.0.1 should address this issue now. Once LGTM finishes I'll publish the release.

@dhershman1
Copy link
Owner

5.0.1 released to NPM please re open or open a new ticket if problem persists.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 👾 researching 📡 This issue is being researched and looked into
Projects
None yet
Development

No branches or pull requests

3 participants