Skip to content

Fix #142028 - #142930

Merged
Connor Peet (connor4312) merged 1 commit into
microsoft:mainfrom
stefanhaller:fix-142028
Feb 15, 2022
Merged

Fix #142028#142930
Connor Peet (connor4312) merged 1 commit into
microsoft:mainfrom
stefanhaller:fix-142028

Conversation

@stefanhaller

Copy link
Copy Markdown
Contributor

If a test is run multiple times during a single test run, don't allow to set
the state back to a lower one, e.g. if the first test run failed but the second
passed. See #142028 for a reproduction recipe.

Fixes #142028

this.fireUpdateAndRefresh(entry, index, state, duration);
// Ignore requests to set the state back to a "lower" one, e.g. from
// failed back to passed:
if (state >= entry.tasks[index].state) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Note that this also prevents the state from going back to running if it is passed or failed. This is not ideal, but it's necessary to solve the issue. In the concrete scenario in the linked issue, the sequence of states is actually running - failed - running - passed.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hm, previously we didn't prescribe meaning to the order of states in the enum. Maybe instead we just say errored, failed, and passed are terminal states and then don't update anything after a terminal state is reached?

@stefanhaller Stefan Haller (stefanhaller) Feb 15, 2022

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That alone wouldn't fix the problem; we need a "stronger" final state to override a "weaker" one. For example, setting passed and then failed needs to result in failed. Setting failed and then passed also needs to result in failed.

So what we'd have to do is something like this:

  if (old state is terminal and
    (new state is not terminal or new state is "weaker" than old state)) {
       // ignore the update
    }
  }

Does that make sense?

I'm a bit unclear how "skipped" plays into this; but I think skipped should be a terminal state too, and come between passed and failed. (Setting passed/skipped or skipped/passed should result in skipped, but setting failed/skipped or skipped/failed should result in failed.) It's a little academic and I think it can't happen in practice, at least not with the C++ extension, so I don't have a strong opinion on this.

Is it possible to change the order of the enum entries? That would make the implementation a bit easier, if we could put the terminal states at the end, and in the right order.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I pushed a new version that does this without reordering the enum entries. I'm not proud of the code, but I'm not an experienced Typescript coder. Let me know what you think.

[TestResultState.Skipped]: 1,
[TestResultState.Failed]: 2,
[TestResultState.Errored]: 3,
};

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this overall looks good, can you move this object into testingStates.ts?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done, I force-pushed a new version. I decided to rename it to terminalStatePriorities, that's a little more precise.

If a test is run multiple times during a single test run, don't allow to set
the state back to a lower one, e.g. if the first test run failed but the second
passed.

@connor4312 Connor Peet (connor4312) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the PR!

@connor4312
Connor Peet (connor4312) merged commit 8956522 into microsoft:main Feb 15, 2022
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 1, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

When setting the state of a TestRun more than once, the last one wins, not the "most failed" one

2 participants