https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124102

            Bug ID: 124102
           Summary: Inconsistency in target-supports.exp between
                    check-jsonschema and pytest
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: testsuite
          Assignee: unassigned at gcc dot gnu.org
          Reporter: nightstrike at gmail dot com
  Target Milestone: ---

Created attachment 63670
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=63670&action=edit
example patch for pytest

The gcc.dg/plugin.exp tests rely on multiple python tools, at least pytest and
check-jsonschema.  The question of using non-dejagnu tools as part of the
testsuite is a good one, but as long as they are going to be used, they should
be tested for consistently.  The pytest test, added in
r12-6629-g4460c638fafddef1df1d35efc52ca1e339b54342 looks for the following:

```
# Return 1 if pytest module is available for python3.

proc check_effective_target_pytest3 { } {
    set result [remote_exec host "python3 -m pytest --color=no -rap -s --tb=no
--version"]
    set status [lindex $result 0]
    if { $status == 0 } then {
        return 1;
    } else {
        return 0;
    }
}
```

while the check-jsonschema tool (initially added as jsonschema with
r15-1541-ga84fe222029ff21903283cc8ee4bc760ebf80ec2 and modified to
check-jsonschema in r15-1633-g17967907102099806dc80c71ee7665ffb22ffa23) instead
does this:

```
# Return 1 if check-jsonschema is available.

proc check_effective_target_check_jsonschema { } {
    set result [remote_exec host "check-jsonschema --version"]
    set status [lindex $result 0]
    if { $status == 0 } then {
        return 1;
    } else {
        return 0;
    }
}
```

The issue with the former test is that it hardcodes `python3`, whereas the
latter test allows $PATH to determine which version to use.  This is an issue
for example on RHEL 8, where multiple versions of python3 are available, and a
user may choose to install one vs the other.  If a user does `pip3.9 install
--user pytest`, that will not be detected by the testsuite, whereas `pip3.9
install --user check-jsonscheme` will work just fine.  For pytest to work, the
user MUST do `pip3 install --user pytest`, which prevents the use of newer
tools on an older OS.

There are ways to work around this on the user side, but since the testsuite is
already forgiving with respect to check-jsonscheme, it would be nice to use
that same logic on the pytest side.

An example patch for pytest is attached, but if there are other cases of tools
like this being required, it would be nice if they too followed the
check-jsonschema method.

Reply via email to