Skip to content
This repository was archived by the owner on Nov 30, 2024. It is now read-only.

Allow ordering specs by modification time #2778

Merged
merged 8 commits into from
Dec 25, 2020

Conversation

MatheusRich
Copy link
Contributor

@MatheusRich MatheusRich commented Oct 30, 2020

Closes #2762

I'm not quite sure about the implementation, so I'll wait for your feedback

@MatheusRich MatheusRich marked this pull request as draft October 30, 2020 15:08
Copy link
Member

@benoittgt benoittgt left a comment

Choose a reason for hiding this comment

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

I find it clean and clear. LGTM

@MatheusRich MatheusRich marked this pull request as ready for review October 30, 2020 21:42
@MatheusRich MatheusRich force-pushed the order-specs-by-modification-time branch from f5ad6df to dbb5271 Compare October 31, 2020 19:53
@@ -13,6 +13,9 @@ order of groups at each level is randomized.

With `rand` you can also specify a seed.

Use `modification_time` to run the most recently modified files first. You can
combine it with `--next-failure` to find the most recent failing spec.
Copy link
Member

Choose a reason for hiding this comment

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

This is a bit confusing to me in several ways.

Firstly, --next-failure says it's "Equivalent to --only-failures --fail-fast --order defined". However, the new flag is overriding the defined order.

Another thing is that the random order is also randomizing examples/groups, not just the files, while the intent of the new flag is to specify the order of the files, and not necessarily dictate to use defined or random order inside the files. I see it as complementing random/defined, not replacing them. Do you think this would be possible?

How does the new flag work with a random seed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn't understand how this could work with a random seed. Do you mean running files by modification time, but the specs inside each file in random order?

Copy link
Member

Choose a reason for hiding this comment

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

It actually hit me by surprise that with the random order spec files are also run in random order. And I initially thought that the idea of the new flag was to change the "by load order" as in defined strategy to use mtime instead.

It looks like that those strategies are "dumb", they don't really care if it's a spec file (top-level example group) or examples from the same example group. So it's not an easy task to teach them to do one thing with specs, and another thing with examples/groups.
I suggest improving the documentation to make it clear how it all works, including the combination of the new flag with --order. I guess there's no warning that --order and the new flag (sorry for calling it like I'm a Silence of the lambs maniac, it's because we haven't settled on its name yet) are mutually exclusive right now, and they are mutually exclusive, right?.

Side observation: it's also surprising to me that if a file has several top-level example groups, random order can run them interleaved with examples from another file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've updated the description. WDYT?

@@ -13,6 +13,9 @@ order of groups at each level is randomized.

With `rand` you can also specify a seed.

Use `modification_time` to run the most recently modified files first. You can
combine it with `--next-failure` to find the most recent failing spec.

## Example usage

The `defined` option is only necessary when you have `--order rand` stored in a
Copy link
Member

Choose a reason for hiding this comment

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

Unrelated, but this statement seems to be contradictive to the default ordering setting from the project initializer:

config.order = :random

Copy link
Member

Choose a reason for hiding this comment

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

Thats not the default, defined is the default, but the convention overrides it, but this sentence is slightly misleading I agree.

@pirj
Copy link
Member

pirj commented Nov 1, 2020

Sorry for nitpicking, it's due to the feeling that in its current state this flag is not very consistent.
I'm all for introducing it, but there are some rough edges. Pretty sure we'll quickly settle on something, and that wouldn't really be a lot of code/docs for you to write.
Thanks for tackling this!

@MatheusRich MatheusRich force-pushed the order-specs-by-modification-time branch from ac1b312 to 42b0abf Compare November 3, 2020 15:40
@MatheusRich MatheusRich force-pushed the order-specs-by-modification-time branch from b825e0e to a9a3d38 Compare November 3, 2020 15:52
@pirj
Copy link
Member

pirj commented Nov 3, 2020

Sorry about that, but it may take me a couple of days to get to this review.

@MatheusRich
Copy link
Contributor Author

@pirj Sorry to ping you, but have you had the change to give this a second look?

Copy link
Member

@pirj pirj left a comment

Choose a reason for hiding this comment

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

Looks quite good.
Thanks!
And sorry for the late response, I lost track of this PR completely.

@pirj pirj requested a review from JonRowe December 4, 2020 22:14
@@ -13,6 +13,9 @@ order of groups at each level is randomized.

With `rand` you can also specify a seed.

Use `modification_time` to run the most recently modified files first. You can
combine it with `--next-failure` to find the most recent failing spec.

## Example usage

The `defined` option is only necessary when you have `--order rand` stored in a
Copy link
Member

Choose a reason for hiding this comment

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

Thats not the default, defined is the default, but the convention overrides it, but this sentence is slightly misleading I agree.

@MatheusRich MatheusRich requested a review from JonRowe December 5, 2020 20:21
@pirj
Copy link
Member

pirj commented Dec 23, 2020

@MatheusRich Sorry for yet another delay. There's a cleanup going on, going to get back to this PR when it's done.

@JonRowe JonRowe merged commit 1efad2f into rspec:main Dec 25, 2020
@JonRowe
Copy link
Member

JonRowe commented Dec 25, 2020

Thanks @MatheusRich

JonRowe added a commit that referenced this pull request Dec 25, 2020
JonRowe added a commit that referenced this pull request Jan 30, 2021
…-time

Allow ordering specs by modification time
JonRowe added a commit that referenced this pull request Jan 30, 2021
yujinakayama pushed a commit to yujinakayama/rspec-monorepo that referenced this pull request Oct 6, 2021
…r-specs-by-modification-time

Allow ordering specs by modification time

---
This commit was imported from rspec/rspec-core@1efad2f.
yujinakayama pushed a commit to yujinakayama/rspec-monorepo that referenced this pull request Oct 6, 2021
yujinakayama pushed a commit to yujinakayama/rspec-monorepo that referenced this pull request Oct 19, 2021
…r-specs-by-modification-time

Allow ordering specs by modification time

---
This commit was imported from rspec/rspec-core@4d3a9d2.
yujinakayama pushed a commit to yujinakayama/rspec-monorepo that referenced this pull request Oct 19, 2021
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.

Allow order specs by modification time
4 participants