Skip to content

Fix problem with defining rules#139

Merged
Leont merged 1 commit intoPerl-Toolchain-Gang:masterfrom
KES777:Fix_rules_definition
Oct 13, 2025
Merged

Fix problem with defining rules#139
Leont merged 1 commit intoPerl-Toolchain-Gang:masterfrom
KES777:Fix_rules_definition

Conversation

@KES777
Copy link

@KES777 KES777 commented Mar 21, 2025

Fixes: #75

I suppose problem is here:
https://github.com/Perl-Toolchain-Gang/Test-Harness/blob/master/lib/App/Prove.pm#L371-L383

This code returns:

  rules => {
    par => [
      {
        seq => xx/start.t,
      },
      xx/t*,
      {
        seq => xx/finish.t,
      },
    ],
  },

For prove --jobs=5 xx/*.t --rules='seq=xx/start.t' --rules='par=xx/t*' --rules='seq=xx/finish.t command.

Though I am ok that tests are run in parallel by default. This line of code $args{rules} = { par => [@rules] }; breaks this state in documentation:

The option may be specified multiple times, and the order matters.

https://metacpan.org/dist/Test-Harness/view/bin/prove#-rules

Solution

With this fix I am able to achieve this behavior: https://perldoc.perl.org/TAP::Parser::Scheduler#Rules-examples

# Run some  startup tests in sequence, then some parallel tests then some
# teardown tests in sequence.
{
    seq => [
        { seq => 't/startup/*.t' },
        { par => ['t/a/*.t','t/b/*.t','t/c/*.t'], }
        { seq => 't/shutdown/*.t' },
    ],
},

For prove --jobs=5 xx/*.t --rules='seq=xx/start.t' --rules='par=xx/t*' --rules='seq=xx/finish.t command when options are read the structure look correct:

DBG> $args{rules}
{
  seq => [
    {
      seq => xx/start.t,
    },
    {
      par => xx/t*,
    },
    {
      seq => xx/finish.t,
    },
  ],
}

And the test t/start.t run before everything, xx/t* in parallel after it. When finished the t/finish.t is run.

@Leont Leont self-assigned this Mar 22, 2025
@Leont
Copy link
Member

Leont commented Mar 22, 2025

I think this makes sense. I have to double-check if there aren't any use-cases that would break with this change but if so they aren't immediately obvious to me.

@KES777
Copy link
Author

KES777 commented Sep 11, 2025

Hello, @Leont. How are you? Did you find any use-cases that would break with this change?

@Leont Leont merged commit 8b86956 into Perl-Toolchain-Gang:master Oct 13, 2025
16 checks passed
@KES777 KES777 deleted the Fix_rules_definition branch February 1, 2026 00:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

prove --rules does not work as advertised

2 participants