Urgent.News

What's breaking now, across thousands of outlets.

Tech

Freeze returncode, Streams, and TimeoutExpired Before One Wrapper Extract

Extracting a command wrapper without a result snapshot breaks callers. Characterization tests must freeze returncode, streams, and timeout first. The smallest safe change starts after that freeze. Callers depend on exit codes and stream types together. They also depend on TimeoutExpired instead of CalledProcessError. A rewrite that simplifies subprocess.run will break those callers. Why success…

In order to extract a command wrapper without a result snapshot, it is crucial to freeze returncode, streams, and TimeoutExpired before making any changes. This is because callers depend on exit codes and stream types together, as well as TimeoutExpired instead of CalledProcessError. A rewrite that simplifies subprocess.run will break these callers.

The purpose of the extract is to record specific fields for every fixture command, such as argv or shell string, returncode, stdout type (bytes or str), stderr type (bytes or str), exception class name (or null), timeout value in seconds (or null), flag, encoding name, and the wrapper's actual read keys. Path is intentionally omitted in this harness for now. The goal is to freeze process results and exception names only.

To achieve this, the source material proposes the following steps:

1. Isolate one wrapper by picking a function that still calls subprocess.run and copying its signature into characterization tests. Do not modify production code in this initial step.

2. Write a recorder that calls the live wrapper and persists JSON files next to the characterization tests. Commit these JSON records before proceeding with any helper extract.

The JSON record should include:

- returncode as an integer (including zero)

- stdout type (bytes or str)

- stderr type (bytes or str)

- exception class name or null

- timeout value in seconds or null

- flag text

- encoding name

- wrapper's actual read keys

It is important to note that cwd should not be recorded in this particular setup, as path drift is a different failure class.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

More from Friday 11 September →