Skip to content

Fix problem with defining rules #139

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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.

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