Can the Perl script test determine if it runs in parallel with the harness?

The problem is this:

Manipulating the external state in a test file reduces the potential parallelism of your test suite.

What I'm testing precisely controls the external state (and then resets it).

I would still like to work in parallel most of the time. I just would like to skip tests that will manipulate the external state, which can lead to the failure of others.

So, I would get around this problem by detecting the parallelism condition, and then skip the test, which will manipulate the external state, thereby causing the loss of others. Is this doable? How?

Note that simply parsing the environment variable HARNESS_OPTIONSfrom your script is not enough to detect a condition: prove -j3for example, it will not set it.

Update

Although there are many ways for your test script to know that it is running in parallel binding (see Brian's answer below), there is no standard way to do this, which I thought could be (but did not formulate it correctly in my question) .

I thought of something like, hmm, well, I read it in your (great!) Effective Perl programming book, Brian, something like support tests, not sure what you are using now, you are a supporter of the module , but not during installation on the user's computer. It is clear that for this there is an agreement on the use of any environement variable.

+5
4

prove , ( TAP::Harness). .

:

  • prove, , -j3.
  • Test::Harness, , jobs prove.
  • prove ( ).
  • , ,
  • , , -
+4

: , Perl?.

- prove, , --serial-tests FILE, , . " ", "-j" . , , .

, .

, . Q/A.

0

, caller - (caller (4)) [0] , , - j3 - caller,

, , , , (caller) [1] , , , -

0

I had a somewhat similar need for detecting executions within prove. I wanted to suppress the output from Test::More::diag()if I ran the entire test suite using the command prove. But when I do the test individually manually, I want to see these diagnostic messages. I do this by checking if STDERR is connected to the terminal.

diag("prove will not see this message") if (-t STDERR);

I think that this makes sense not only for use in the proveenvironment, the idea is that if STDERR is shown to a person, then accept interactive use and be more chatty.

0
source

All Articles