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

'timeout' events have different structure than e.g. 'test-passed' #2645

Closed
TimDaub opened this issue Jan 13, 2021 · 7 comments
Closed

'timeout' events have different structure than e.g. 'test-passed' #2645

TimDaub opened this issue Jan 13, 2021 · 7 comments

Comments

@TimDaub
Copy link

TimDaub commented Jan 13, 2021

consumeStateChange expects events of a specific type to be submitted. These get then passed on to functions that will log the outcome of the test run (endRun and writeTestSummary.

However, an event of type timeout (and maybe also type interrupt) cannot be passed to e.g. writeTestSummary, as their shape is different than e.g. a type test-passed. For comparison, here's a type test-passed event

{
  type: 'test-passed',
  title: 'another test that is simply passing',
  duration: 0,
  knownFailing: false,
  logs: [],
  testFile: '/Users/user/Projects/ava-test-timed-out/test/index_test.js'
}

and here's a type timeout.

{
  type: 'timeout',
  period: 10000,
  pendingTests: Map(2) {
    '/Users/user/Projects/ava-test-timed-out/test/index_test.js' => Set(2) { 'a test that times out', 'a second test that times out' },
    '/Users/user/Projects/ava-test-timed-out/test/index_test2.js' => Set(1) { 'a third test that times out' }
  }
}

Not that also a timeout is logically on another level to a test-passed. A timeout event is sent once and contains all timed-out tests in pendingTests whereas each failed test gets their own test-passed event.
To improve the output of timed-out tests as I've outlined in #2639, I was wondering if it would hence make sense to convert the structure of timeout into a similar one from test-passed. Meaning that for each test that times out, a new event is sent with the properties type, title, duration, knownFailing, logs, testFile.

If so, would you mind telling me which file dictates the structure of a timeout event?

@novemberborn
Copy link
Member

Sounds good.

ava/lib/api.js

Line 84 in 32c5425

runStatus.emitStateChange({type: 'timeout', period: timeout});

Also:

ava/lib/api.js

Line 107 in 32c5425

runStatus.emitStateChange({type: 'interrupt'});

@TimDaub
Copy link
Author

TimDaub commented Jan 15, 2021

I think I'm really close. But for both L84 and L107, I can't find a way to get the test's title. It seems I can only access it after the worker has stopped on during selected-test. Both occurrences seem really tricky to access it. Anywhere I could get the title from otherwise?

@novemberborn
Copy link
Member

Sorry what title do you need to acces in what circumstance?

@TimDaub
Copy link
Author

TimDaub commented Jan 17, 2021

The proposed event "test-timeout" that is created in emitStateChange is supposed to contain the test's title in the same way that an event of type "test-passed" contains a title property. Along the event's lifecycle, I want to add the test's title somehow.

@novemberborn
Copy link
Member

Is this for individual test timeouts? Through t.timeout? Though those may be emitted as test failures. The other timeouts are due to inactivity and thus not attributable to specific tests.

Apologies if I didn't make this clear enough. Trying to remember it all myself 😀

@TimDaub
Copy link
Author

TimDaub commented Jan 18, 2021

The other timeouts are due to inactivity and thus not attributable to specific tests.

Actually, I was contemplating if they're attributable or not too. But from my understanding, the current timeout event is created from a pendingWorkers list. What my previous questions were all concerned with mapping a title to a worker. IMO, I'd just need the title somehow when forking the worker. Any ideas?

@novemberborn
Copy link
Member

The worker runs test files, which contain tests, which have titles.

#2501 mentions this issue:

We print pending tests when AVA times out. We should print just those tests (and hooks) that have started. Originally reported in #2421.

Perhaps solving that makes it easier to achieve your goal here.

As I'm also discussing in #2647 the reporter code is quite messy at this point and I'm having a hard time remembering what it's supposed to do for what reason. Let's keep that in mind as we expend all this energy trying to tweak it… perhaps a more radical approach is necessary.

@novemberborn novemberborn closed this as not planned Won't fix, can't repro, duplicate, stale Jul 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants