oct
Loading...
Searching...
No Matches
oct.testing.parallel._Tracer Class Reference
Collaboration diagram for oct.testing.parallel._Tracer:
[legend]

Public Member Functions

None __init__ (self, Path root)
None record (self, str resource)
None record_path (self, Any target)
None record_launch (self, Any argv, *, Any cwd=None)
dict[str, set[str]] resources (self)
None install (self)
None remove (self)

Public Attributes

 root = Path(root).resolve()
dict records = {}
set[str] env_writers = set()
set[str] spawners = set()
str|None current = None

Static Public Attributes

tuple TRACE_REQUIRES_SERIAL

Protected Member Functions

bool _git_is_temporary (self, Sequence[Any] argv, Any cwd)
None _patch (self, Any owner, str name, Callable factory)
Callable _open_wrapper (self, Callable original)
Callable _chdir_wrapper (self, Callable original)
Callable _env_wrapper (self, Callable original)
Callable _bind_wrapper (self, Callable original)
Callable _popen_wrapper (self, Callable original)

Protected Attributes

list _installed = []
 _temp
 _pid = str(os.getpid())
 _open_wrapper
 _chdir_wrapper
 _env_wrapper
 _bind_wrapper
 _popen_wrapper

Static Protected Attributes

_Tracer _TRACER = None
Path _TRACE_PATH = None

Detailed Description

Wrap the process-global seams and attribute them to a file.

Only WRITE-shaped events are recorded - a read cannot collide.
Every observation is attributed to the test file that was running
when it happened, so the trace shares the static pass's key space.

Every wrapper is ``functools.wraps``-ed onto the seam it replaces,
so a wrapped function still reports the original's ``__name__``,
``__qualname__``, ``__doc__`` and ``__wrapped__``: code under test
that inspects the identity of a patched binding must see what it
would see untraced (gate finding R2).

Definition at line 2623 of file parallel.py.

Constructor & Destructor Documentation

◆ __init__()

None oct.testing.parallel._Tracer.__init__ ( self,
Path root )

Definition at line 2637 of file parallel.py.

Member Function Documentation

◆ _bind_wrapper()

Callable oct.testing.parallel._Tracer._bind_wrapper ( self,
Callable original )
protected

Definition at line 2811 of file parallel.py.

Here is the call graph for this function:

◆ _chdir_wrapper()

Callable oct.testing.parallel._Tracer._chdir_wrapper ( self,
Callable original )
protected

Definition at line 2795 of file parallel.py.

Here is the call graph for this function:

◆ _env_wrapper()

Callable oct.testing.parallel._Tracer._env_wrapper ( self,
Callable original )
protected

Definition at line 2802 of file parallel.py.

Here is the call graph for this function:

◆ _git_is_temporary()

bool oct.testing.parallel._Tracer._git_is_temporary ( self,
Sequence[Any] argv,
Any cwd )
protected
Vouch for Git only when cwd and every -C remain temporary.

Global configuration and explicit repository overrides can target
locations outside cwd and therefore keep the launch unattributed.

Definition at line 2704 of file parallel.py.

Here is the caller graph for this function:

◆ _open_wrapper()

Callable oct.testing.parallel._Tracer._open_wrapper ( self,
Callable original )
protected

Definition at line 2785 of file parallel.py.

Here is the call graph for this function:

◆ _patch()

None oct.testing.parallel._Tracer._patch ( self,
Any owner,
str name,
Callable factory )
protected
Replace ``owner.name`` with ``factory(original)``.

Definition at line 2754 of file parallel.py.

◆ _popen_wrapper()

Callable oct.testing.parallel._Tracer._popen_wrapper ( self,
Callable original )
protected

Definition at line 2824 of file parallel.py.

Here is the call graph for this function:

◆ install()

None oct.testing.parallel._Tracer.install ( self)
Wrap every traced seam.

Definition at line 2761 of file parallel.py.

◆ record()

None oct.testing.parallel._Tracer.record ( self,
str resource )
Attribute *resource* to the file under test.

Definition at line 2650 of file parallel.py.

Here is the caller graph for this function:

◆ record_launch()

None oct.testing.parallel._Tracer.record_launch ( self,
Any argv,
* ,
Any cwd = None )
Attribute a child launch to the file under test (P3).

The tracer sees the REAL argv, so it keys what the static pass
can only guess at; an argv whose family the committed table
does not vouch for still contributes the bare wildcard.

Definition at line 2687 of file parallel.py.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ record_path()

None oct.testing.parallel._Tracer.record_path ( self,
Any target )
Attribute a write to *target* to the file under test.

Definition at line 2655 of file parallel.py.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ remove()

None oct.testing.parallel._Tracer.remove ( self)
Restore every wrapped seam, newest first.

Definition at line 2773 of file parallel.py.

◆ resources()

dict[str, set[str]] oct.testing.parallel._Tracer.resources ( self)
The trace as recorded.

The P2 env/subprocess join happens at the seam now:
:meth:`record_launch` records the family's own tokens, or the
bare one, at the moment of the launch, and the environment
seam records :data:`RES_ENV_MUTATION` (Plan 276 P1) - which is
process-local, so it never groups anything. :attr:`spawners`
and :attr:`env_writers` stay as the diagnostic record of WHICH
files launched a child and WHICH wrote the environment.

Definition at line 2740 of file parallel.py.

Member Data Documentation

◆ _bind_wrapper

oct.testing.parallel._Tracer._bind_wrapper
protected

Definition at line 2769 of file parallel.py.

◆ _chdir_wrapper

oct.testing.parallel._Tracer._chdir_wrapper
protected

Definition at line 2766 of file parallel.py.

◆ _env_wrapper

oct.testing.parallel._Tracer._env_wrapper
protected

Definition at line 2767 of file parallel.py.

◆ _installed

oct.testing.parallel._Tracer._installed = []
protected

Definition at line 2643 of file parallel.py.

◆ _open_wrapper

oct.testing.parallel._Tracer._open_wrapper
protected

Definition at line 2764 of file parallel.py.

◆ _pid

oct.testing.parallel._Tracer._pid = str(os.getpid())
protected

Definition at line 2647 of file parallel.py.

◆ _popen_wrapper

oct.testing.parallel._Tracer._popen_wrapper
protected

Definition at line 2770 of file parallel.py.

◆ _temp

oct.testing.parallel._Tracer._temp
protected
Initial value:
= os.path.realpath(
os.environ.get("TEMP") or os.environ.get("TMPDIR") or "/tmp",
).replace("\\", "/").lower()

Definition at line 2644 of file parallel.py.

◆ _TRACE_PATH

Path oct.testing.parallel._Tracer._TRACE_PATH = None
staticprotected

Definition at line 2842 of file parallel.py.

◆ _TRACER

_Tracer oct.testing.parallel._Tracer._TRACER = None
staticprotected

Definition at line 2839 of file parallel.py.

◆ current

oct.testing.parallel._Tracer.current = None

Definition at line 2642 of file parallel.py.

◆ env_writers

set[str] oct.testing.parallel._Tracer.env_writers = set()

Definition at line 2640 of file parallel.py.

◆ records

dict oct.testing.parallel._Tracer.records = {}

Definition at line 2639 of file parallel.py.

◆ root

oct.testing.parallel._Tracer.root = Path(root).resolve()

Definition at line 2638 of file parallel.py.

◆ spawners

set[str] oct.testing.parallel._Tracer.spawners = set()

Definition at line 2641 of file parallel.py.

◆ TRACE_REQUIRES_SERIAL

tuple oct.testing.parallel._Tracer.TRACE_REQUIRES_SERIAL
static
Initial value:
= (
"--oct-trace requires a SERIAL run: re-run with -n 0. The tracer "
"wraps process-global seams, so under xdist it would record only "
"this process's activity and write a partial trace, and a partial "
"trace silently misclassifies the files it never saw."
)

Definition at line 2846 of file parallel.py.


The documentation for this class was generated from the following file: