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_runner: update output TAP format to follow TAP 14 specs #44040

Closed
manekinekko opened this issue Jul 29, 2022 · 15 comments
Closed

test_runner: update output TAP format to follow TAP 14 specs #44040

manekinekko opened this issue Jul 29, 2022 · 15 comments
Assignees
Labels
good first issue Issues that are suitable for first-time contributors. test_runner

Comments

@manekinekko
Copy link
Contributor

manekinekko commented Jul 29, 2022

What steps will reproduce the bug?

  • create an index.js file with a few test cases:
const test = require('node:test');
const assert = require('node:assert');

test('top-level test 1', async (t) => {
  await t.test('level 1.1', () => {});
});

test('top-level test 2', () => {});
  • run the test: node index.js (note: node --test index.js gives an incorrect result)

How often does it reproduce? Is there a required condition?

No response

What is the expected behavior?

Even though the current output is syntactically valid TAP output. The expected output would be a TAP format that follows specs 14.

TAP version 14

# Subtest: top-level test 1
    ok 1 - sub test level 1.1
    1..1
ok 1 - top-level test 1

ok 2 - top-level test 2

1..2

Note the version header TAP version 14 (required by TAP14).

What do you see instead?

We currently output the following format (removed diagnostics for readability):

TAP version 13

# Subtest: top-level test 1
    # Subtest: sub-test level 1.1
    ok 1 - sub-test level 1.1
    1..1
ok 1 - top-level test 1

1..1

Top-level tests are incorrectly output as subtests: # Subtest: top-level test 1 and # Subtest: top-level test 2

Additional information

As a reference, using node-tap (v16.3.0) gives the following output:

TAP version 13
# Subtest: top-level test 1
    ok 1 - sub test level 1.1
    1..1
ok 1 - top-level test 1

ok 2 - top-level test 2
1..2

Here is the diff:

TAP version 13

# Subtest: top-level test 1
-    # Subtest: sub test level 1.1
    ok 1 - sub test level 1.1
    1..1
ok 1 - top-level test 1

+ ok 2 - top-level test 2

-1..1
+1..2

Related: #43417 #43525

@manekinekko
Copy link
Contributor Author

cc @benjamingr @cjihrig @MoLow

@anonrig
Copy link
Member

anonrig commented Jul 29, 2022

I've given this task a try, and opened a pull request. Happy to solve any issues I've missed or is introduced.

@manekinekko
Copy link
Contributor Author

Thanks @anonrig 👍

@aduh95
Copy link
Contributor

aduh95 commented Jul 29, 2022

/cc @nodejs/test_runner

@MoLow MoLow closed this as not planned Won't fix, can't repro, duplicate, stale Oct 15, 2022
@ljharb
Copy link
Member

ljharb commented Oct 15, 2022

Why is this not planned?

@MoLow
Copy link
Member

MoLow commented Oct 15, 2022

Why is this not planned?

The current output is a valid TAP output and currently more parsers support it better than the proposed changed.
Since @anonrig closed his PR, I thought the issue can be closed

@ljharb
Copy link
Member

ljharb commented Oct 15, 2022

Given that TAP 14 added better support for nested tests, it seems like a pretty critical thing to add. I agree outputting TAP 13 is a better default, but it still seems like something node should be allowing via an option, if it wants to be in the test runner business.

@MoLow
Copy link
Member

MoLow commented Oct 16, 2022

I amm reopening - but I think this should only be changed once there is an appropriate support for this change from tap parsers/reporters

@MoLow MoLow reopened this Oct 16, 2022
@manekinekko
Copy link
Contributor Author

FYI, the TAP parser from #43525 was designed initially based in TAP14. I have made changes to allow it to parse TAP13 (mainly for subtests). So I guess it should be able to handle valid TAP14 content.

@anonrig
Copy link
Member

anonrig commented Oct 16, 2022

IMHO Adding --tap-version=14 to test runner would resolve this issue. I’m changing countries in a couple of days, and can look into this issue a week from now.

@anonrig anonrig added the good first issue Issues that are suitable for first-time contributors. label Oct 16, 2022
@daltonna
Copy link

Can someone assign this issue to me?

@mattfysh
Copy link

Is this why userland reporters like tap-arc are not reporting any useful information?

i.e. node --test | tap-arc doesn't show any diff information and also says operator: undefined

  Subtest: /sandbox/test_runner/main.js
    ✖ 1) /sandbox/test_runner/main.js
      operator: undefined

@cjihrig
Copy link
Contributor

cjihrig commented Nov 26, 2022

Is this why userland reporters like tap-arc are not reporting any useful information?

No. The output of the CLI runner should be nicer in the next release (v19.2.0) due to #43525 being merged. For example:

$ ./node --test test.js | npx tap-arc
    ✖ 1) spies on async class static functions
      Expected to throw
      
    ✔ spies on async class functions

  cancelled 0

  duration_ms 95.023375

  Failed tests: There was 1 failure

    ✖ 1) /Users/cjihrig/iojs/node/test.js

  total:     1
  failing:   1
  34 ms

The operator: undefined thing is specific to tap-arc, and it looks like they have a WIP PR to better support node:test output. Node also landed e260b37 recently, which may help out here.

@eyitayoit-alt
Copy link

I see the following output
TAP version 13

Subtest: top-level test 1

# Subtest: level 1.1
ok 1 - level 1.1
  ---
  duration_ms: 0.0214175
  ...
1..1

ok 1 - top-level test 1

duration_ms: 0.0321595
...

Subtest: top-level test 2

ok 2 - top-level test 2

duration_ms: 0.0005513
...

@MoLow
Copy link
Member

MoLow commented May 22, 2023

I am closing this now as I don't think an issue is needed.
if someone opens a pr to change this it is fine - we don't parse TAP anymore so it is also less fragile

@MoLow MoLow closed this as completed May 22, 2023
@MoLow MoLow closed this as not planned Won't fix, can't repro, duplicate, stale May 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Issues that are suitable for first-time contributors. test_runner
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants