Skip to content

Safe.pm test suite has some broken-looking skip conditions #23114

Open
@mauke

Description

@mauke

Module: Safe

Description

Some of the tests in dist/Safe/t are conditional. Most of them just check whether $Config{extensions} lists Opcode as available, which makes sense since Safe uses Opcode. But a few of them add some extra conditions that make no sense to me.

The worst offender is probably dist/Safe/t/safe3.t:

BEGIN {
    require Config; Config->import;
    if ($Config{'extensions'} !~ /\bOpcode\b/
	&& $Config{'extensions'} !~ /\bPOSIX\b/
	&& $Config{'osname'} ne 'VMS')
    {
	print "1..0\n";
	exit 0;
    }
}

Essentially, what this is saying is:

  • On VMS, always run this test, regardless of whether Opcode/POSIX are available.
  • On non-VMS systems, run this test if either Opcode or POSIX are available.
  • Only skip this test if we're not on VMS and both Opcode and POSIX are unavailable.

I would've expected all those && to be ||, i.e. to skip the test if we're on VMS, or Opcode is unavailable, or POSIX is unavailable, because the following code then unconditionally loads POSIX and Safe (which pulls in Opcode).

The full list of test files with similar code is:

  • dist/Safe/t/safe1.t
  • dist/Safe/t/safe2.t
  • dist/Safe/t/safe3.t
  • dist/Safe/t/safeops.t
  • dist/Safe/t/safesort.t
  • dist/Safe/t/safeutf8.t
  • dist/Safe/t/safewrap.t

Steps to Reproduce

grep VMS dist/Safe/t/*

Expected behavior
The skip conditions should logically use ||, not &&.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions