1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
//! Resolving the reference CPython the differential harnesses compare against.
//!
//! Every parity result is the sentence "pythonrs disagrees with THIS
//! interpreter", so *which* interpreter it was is part of the result, not
//! incidental setup. Two failure modes this module exists to close:
//!
//! * **A bare `python3` is not an identity.** It is a PATH lookup, and the PATH
//! a harness ran under is not the PATH whoever reads the report has. A shim, a
//! venv, a pyenv/conda shadow or a Homebrew/system split all answer to the same
//! four letters and are different toolchains. Only an absolute path names one.
//! * **A harness that never says what it resolved is unfalsifiable.** A run that
//! silently compared against the wrong CPython reports either a wall of
//! divergences that are really version drift, or a clean sheet that measured
//! the wrong thing. Neither is distinguishable from a correct run unless the
//! oracle is printed.
//!
//! So [`resolve`] always answers with an absolute path, and every harness prints
//! [`identify`] before it compares anything.
//!
//! `PYTHONRS_ORACLE` (or the older `PYTHONRS_FUZZ_PYTHON`) names the oracle
//! explicitly. If one is set but unusable that is a HARD error rather than a
//! fallback: silently comparing against a different CPython answers a different
//! question than the one that was asked.
use ;
use Command;
/// The environment variables that name an oracle explicitly, newest first.
pub const ORACLE_VARS: = ;
/// The candidates tried, in order, when nothing names an oracle.
const CANDIDATES: = ;
/// `<prog> --version` output, or `None` when the program cannot be run at all.
///
/// This doubles as a LIVENESS check, which is why it is the probe rather than a
/// mere `Path::exists`: a broken shim or a stub that prints a version and can
/// execute nothing fails here instead of being mistaken for a working oracle and
/// reported as a wall of divergences. CPython has printed the version to stdout
/// since 3.4 and to stderr before that, so both streams are read.
/// The absolute path `name` resolves to, or `None` when it is not runnable.
///
/// An already-absolute path is returned as given (not canonicalized: a
/// deliberately-named symlink such as a venv's `bin/python3` is the answer the
/// caller asked for, and resolving it through to the interpreter it points at
/// would report something they did not name). A bare name is looked up along
/// `PATH` exactly as the shell would, so the recorded path is the file that
/// actually ran.
/// The oracle to compare against, as an absolute path.
///
/// `Err` carries a message ready to print; every caller treats it as fatal,
/// except the integration test, which SKIPS on it — a machine with no CPython
/// has no oracle, and a test that measures nothing there is honest where a
/// failing one would only be noise.
/// `<absolute path> (<version>)` — what every harness prints before comparing,
/// and what a divergence record is stamped with, so a result can be attributed
/// to the exact interpreter that produced it.
/// `(major, minor)` of an oracle, parsed from `sys.version_info` rather than
/// from `--version` text.
///
/// A harness gates on this (traceback rendering settled in 3.13, so full-stderr
/// comparison only means something from there on), and a gate must not be
/// decided by string-scraping a banner that a distributor is free to reword.
/// Running code for it also re-proves the interpreter can execute, not merely
/// start.