shrinkray 0.0.2__tar.gz → 25.12.26.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- shrinkray-25.12.26.1/LICENSE +21 -0
- shrinkray-25.12.26.1/PKG-INFO +187 -0
- shrinkray-25.12.26.1/README.md +148 -0
- shrinkray-25.12.26.1/pyproject.toml +112 -0
- shrinkray-25.12.26.1/src/shrinkray/__init__.py +1 -0
- shrinkray-25.12.26.1/src/shrinkray/__main__.py +375 -0
- shrinkray-25.12.26.1/src/shrinkray/cli.py +70 -0
- shrinkray-25.12.26.1/src/shrinkray/display.py +75 -0
- shrinkray-25.12.26.1/src/shrinkray/formatting.py +108 -0
- shrinkray-25.12.26.1/src/shrinkray/passes/__init__.py +0 -0
- shrinkray-25.12.26.1/src/shrinkray/passes/bytes.py +754 -0
- shrinkray-25.12.26.1/src/shrinkray/passes/clangdelta.py +260 -0
- shrinkray-25.12.26.1/src/shrinkray/passes/definitions.py +132 -0
- shrinkray-25.12.26.1/src/shrinkray/passes/genericlanguages.py +331 -0
- shrinkray-25.12.26.1/src/shrinkray/passes/json.py +97 -0
- shrinkray-25.12.26.1/src/shrinkray/passes/patching.py +288 -0
- shrinkray-25.12.26.1/src/shrinkray/passes/python.py +219 -0
- shrinkray-25.12.26.1/src/shrinkray/passes/sat.py +590 -0
- shrinkray-25.12.26.1/src/shrinkray/passes/sequences.py +89 -0
- shrinkray-25.12.26.1/src/shrinkray/problem.py +497 -0
- shrinkray-25.12.26.1/src/shrinkray/process.py +49 -0
- shrinkray-25.12.26.1/src/shrinkray/py.typed +0 -0
- shrinkray-25.12.26.1/src/shrinkray/reducer.py +592 -0
- shrinkray-25.12.26.1/src/shrinkray/state.py +599 -0
- shrinkray-25.12.26.1/src/shrinkray/subprocess/__init__.py +24 -0
- shrinkray-25.12.26.1/src/shrinkray/subprocess/client.py +253 -0
- shrinkray-25.12.26.1/src/shrinkray/subprocess/protocol.py +190 -0
- shrinkray-25.12.26.1/src/shrinkray/subprocess/worker.py +491 -0
- shrinkray-25.12.26.1/src/shrinkray/tui.py +915 -0
- shrinkray-25.12.26.1/src/shrinkray/ui.py +72 -0
- shrinkray-25.12.26.1/src/shrinkray/work.py +245 -0
- shrinkray-25.12.26.1/src/shrinkray.egg-info/PKG-INFO +187 -0
- shrinkray-25.12.26.1/src/shrinkray.egg-info/SOURCES.txt +64 -0
- shrinkray-25.12.26.1/src/shrinkray.egg-info/entry_points.txt +3 -0
- shrinkray-25.12.26.1/src/shrinkray.egg-info/requires.txt +24 -0
- shrinkray-25.12.26.1/tests/test_byte_reduction_passes.py +240 -0
- shrinkray-25.12.26.1/tests/test_clang_delta.py +429 -0
- shrinkray-25.12.26.1/tests/test_cli.py +130 -0
- shrinkray-25.12.26.1/tests/test_definitions.py +90 -0
- shrinkray-25.12.26.1/tests/test_dimacs_cnf.py +342 -0
- shrinkray-25.12.26.1/tests/test_display.py +135 -0
- shrinkray-25.12.26.1/tests/test_formatting.py +223 -0
- shrinkray-25.12.26.1/tests/test_generic_language.py +382 -0
- shrinkray-25.12.26.1/tests/test_generic_shrinking_properties.py +237 -0
- shrinkray-25.12.26.1/tests/test_json_passes.py +292 -0
- shrinkray-25.12.26.1/tests/test_main.py +1609 -0
- shrinkray-25.12.26.1/tests/test_misc_reduction_performance.py +48 -0
- shrinkray-25.12.26.1/tests/test_patching.py +939 -0
- shrinkray-25.12.26.1/tests/test_problem.py +913 -0
- shrinkray-25.12.26.1/tests/test_process.py +242 -0
- shrinkray-25.12.26.1/tests/test_python_reducers.py +349 -0
- shrinkray-25.12.26.1/tests/test_reducer.py +1791 -0
- shrinkray-25.12.26.1/tests/test_reduction_passes.py +1155 -0
- shrinkray-25.12.26.1/tests/test_sat.py +221 -0
- shrinkray-25.12.26.1/tests/test_state.py +1864 -0
- shrinkray-25.12.26.1/tests/test_subprocess_client.py +1082 -0
- shrinkray-25.12.26.1/tests/test_subprocess_integration.py +150 -0
- shrinkray-25.12.26.1/tests/test_subprocess_protocol.py +268 -0
- shrinkray-25.12.26.1/tests/test_subprocess_worker.py +1856 -0
- shrinkray-25.12.26.1/tests/test_tui.py +3750 -0
- shrinkray-25.12.26.1/tests/test_tui_snapshots.py +276 -0
- shrinkray-25.12.26.1/tests/test_ui.py +89 -0
- shrinkray-25.12.26.1/tests/test_work.py +218 -0
- shrinkray-0.0.2/PKG-INFO +0 -19
- shrinkray-0.0.2/README.md +0 -61
- shrinkray-0.0.2/setup.py +0 -44
- shrinkray-0.0.2/src/shrinkray/__init__.py +0 -3
- shrinkray-0.0.2/src/shrinkray/__main__.py +0 -196
- shrinkray-0.0.2/src/shrinkray/cutting.py +0 -316
- shrinkray-0.0.2/src/shrinkray/junkdrawer.py +0 -141
- shrinkray-0.0.2/src/shrinkray/reducer.py +0 -321
- shrinkray-0.0.2/src/shrinkray.egg-info/PKG-INFO +0 -19
- shrinkray-0.0.2/src/shrinkray.egg-info/SOURCES.txt +0 -14
- shrinkray-0.0.2/src/shrinkray.egg-info/entry_points.txt +0 -3
- shrinkray-0.0.2/src/shrinkray.egg-info/not-zip-safe +0 -1
- shrinkray-0.0.2/src/shrinkray.egg-info/requires.txt +0 -2
- {shrinkray-0.0.2 → shrinkray-25.12.26.1}/setup.cfg +0 -0
- {shrinkray-0.0.2 → shrinkray-25.12.26.1}/src/shrinkray.egg-info/dependency_links.txt +0 -0
- {shrinkray-0.0.2 → shrinkray-25.12.26.1}/src/shrinkray.egg-info/top_level.txt +0 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright © 2023 David R. MacIver
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: shrinkray
|
|
3
|
+
Version: 25.12.26.1
|
|
4
|
+
Summary: Shrink Ray
|
|
5
|
+
Author-email: "David R. MacIver" <david@drmaciver.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/DRMacIver/shrinkray
|
|
8
|
+
Project-URL: Repository, https://github.com/DRMacIver/shrinkray
|
|
9
|
+
Project-URL: Documentation, https://shrinkray.readthedocs.io
|
|
10
|
+
Project-URL: Changelog, https://github.com/DRMacIver/shrinkray/releases
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Requires-Python: >=3.12
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
License-File: LICENSE
|
|
15
|
+
Requires-Dist: click>=8.0.1
|
|
16
|
+
Requires-Dist: chardet>=5.2.0
|
|
17
|
+
Requires-Dist: trio>=0.28.0
|
|
18
|
+
Requires-Dist: textual>=0.47.0
|
|
19
|
+
Requires-Dist: humanize>=4.9.0
|
|
20
|
+
Requires-Dist: libcst>=1.1.0
|
|
21
|
+
Requires-Dist: exceptiongroup>=1.2.0
|
|
22
|
+
Requires-Dist: binaryornot>=0.4.4
|
|
23
|
+
Requires-Dist: black
|
|
24
|
+
Provides-Extra: dev
|
|
25
|
+
Requires-Dist: coverage>=7.13.0; extra == "dev"
|
|
26
|
+
Requires-Dist: hypothesis>=6.92.1; extra == "dev"
|
|
27
|
+
Requires-Dist: hypothesmith>=0.3.1; extra == "dev"
|
|
28
|
+
Requires-Dist: pytest; extra == "dev"
|
|
29
|
+
Requires-Dist: pytest-trio; extra == "dev"
|
|
30
|
+
Requires-Dist: pytest-asyncio; extra == "dev"
|
|
31
|
+
Requires-Dist: pytest-textual-snapshot; extra == "dev"
|
|
32
|
+
Requires-Dist: coverage[toml]; extra == "dev"
|
|
33
|
+
Requires-Dist: pygments; extra == "dev"
|
|
34
|
+
Requires-Dist: basedpyright; extra == "dev"
|
|
35
|
+
Requires-Dist: ruff; extra == "dev"
|
|
36
|
+
Requires-Dist: pexpect>=4.9.0; extra == "dev"
|
|
37
|
+
Requires-Dist: pyte>=0.8.2; extra == "dev"
|
|
38
|
+
Dynamic: license-file
|
|
39
|
+
|
|
40
|
+
# Shrink Ray
|
|
41
|
+
|
|
42
|
+
Shrink Ray is a modern multiformat test-case reducer.
|
|
43
|
+
|
|
44
|
+
## What is test-case reduction?
|
|
45
|
+
|
|
46
|
+
Test-case reduction is the process of automatically taking a *test case* and *reducing* it to something close to a [minimal reproducible example](https://en.wikipedia.org/wiki/Minimal_reproducible_example).
|
|
47
|
+
|
|
48
|
+
That is, you have some file that has some interesting property (usually that it triggers a bug in some software),
|
|
49
|
+
but it is large and complicated and as a result you can't figure out what about the file actually matters.
|
|
50
|
+
You want to be able to trigger the bug with a small, simple, version of it that contains only the features of interest.
|
|
51
|
+
|
|
52
|
+
For example, the following is some Python code that [triggered a bug in libcst](https://github.com/Instagram/LibCST/issues/1061):
|
|
53
|
+
|
|
54
|
+
```python
|
|
55
|
+
() if 0 else(lambda:())
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
This was extracted from a large Python file (probably several thousand lines of code) and systematically reduced down to this example.
|
|
59
|
+
|
|
60
|
+
You would obtain this by running `shrinkray breakslibcst.py mytestcase.py`, where `breakslibcst.py` looks something like this:
|
|
61
|
+
|
|
62
|
+
```python
|
|
63
|
+
import libcst
|
|
64
|
+
import sys
|
|
65
|
+
|
|
66
|
+
if __name__ == '__main__':
|
|
67
|
+
try:
|
|
68
|
+
libcst.parse_module(sys.stdin.read())
|
|
69
|
+
except TypeError:
|
|
70
|
+
sys.exit(0)
|
|
71
|
+
sys.exit(1)
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
This script exits with 0 if the code passed to it on standard input triggers the relevant bug (that libcst raises a TypeError when parsing this code), and with a non-zero exit code otherwise.
|
|
75
|
+
|
|
76
|
+
shrinkray (or any other test-case reducer) then systematically tries smaller and simpler variants of your original source file until it reduces it to something as small as it can manage.
|
|
77
|
+
|
|
78
|
+
While it runs, you will see the following user interface:
|
|
79
|
+
|
|
80
|
+

|
|
81
|
+
|
|
82
|
+
When it finishes you will be left with the reduced test case in `mytestcase.py`.
|
|
83
|
+
|
|
84
|
+
Test-case reducers are useful for any tools that handle files with complex formats that can trigger bugs in them. Historically this has been particularly useful for compilers and other programming tools, but in principle it can be used for anything.
|
|
85
|
+
|
|
86
|
+
Most test-case reducers only work well on a few formats. Shrink Ray is designed to be able to support a wide variety of formats, including binary ones, although it's currently best tuned for "things that look like programming languages".
|
|
87
|
+
|
|
88
|
+
## What makes Shrink Ray distinctive?
|
|
89
|
+
|
|
90
|
+
It's designed to be highly parallel, and work with a very wide variety of formats, through a mix of good generic algorithms and format-specific reduction passes.
|
|
91
|
+
|
|
92
|
+
## Versioning and Releases
|
|
93
|
+
|
|
94
|
+
Shrink Ray uses calendar versioning (calver) in the format YY.M.D.N (e.g., 25.12.26.0 for the first release on December 26, 2025, 25.12.26.1 for the second, etc.).
|
|
95
|
+
|
|
96
|
+
New releases are published automatically when changes are pushed to main if there are any changes to the source code or pyproject.toml since the previous release.
|
|
97
|
+
|
|
98
|
+
Shrinkray makes no particularly strong backwards compatibility guarantees. I aim to keep its behaviour relatively stable between releases, but for example will not be particularly shy about dropping old versions of Python or adding new dependencies. The basic workflow of running a simple reduction will rarely, if ever, change, but the UI is likely to be continuously evolving for some time.
|
|
99
|
+
|
|
100
|
+
## Installation
|
|
101
|
+
|
|
102
|
+
Shrink Ray requires Python 3.12 or later, and can be installed using pip or uv like any other python package.
|
|
103
|
+
|
|
104
|
+
You can install the latest release from PyPI or run directly from the main branch:
|
|
105
|
+
|
|
106
|
+
```
|
|
107
|
+
pipx install shrinkray
|
|
108
|
+
# or
|
|
109
|
+
pipx install git+https://github.com/DRMacIver/shrinkray.git
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
(if you don't have or want [pipx](https://pypa.github.io/pipx/) you could also do this with pip or `uv pip` and it would work fine)
|
|
113
|
+
|
|
114
|
+
Shrink Ray requires Python 3.12 or later and won't work on earlier versions. If everything is working correctly, it should refuse to install
|
|
115
|
+
on versions it's incompatible with. If you do not have Python 3.12 installed, I recommend [pyenv](https://github.com/pyenv/pyenv) for managing
|
|
116
|
+
Python installs.
|
|
117
|
+
|
|
118
|
+
If you want to use it from the git repo directly, you can do the following:
|
|
119
|
+
|
|
120
|
+
```
|
|
121
|
+
git clone https://github.com/DRMacIver/shrinkray.git
|
|
122
|
+
cd shrinkray
|
|
123
|
+
python -m venv .venv
|
|
124
|
+
.venv/bin/pip install -e .
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
You will now have a shrinkray executable in .venv/bin, which you can also put on your path by running `source .venv/bin/activate`.
|
|
128
|
+
|
|
129
|
+
## Usage
|
|
130
|
+
|
|
131
|
+
Shrink Ray is run as follows:
|
|
132
|
+
|
|
133
|
+
```
|
|
134
|
+
shrinkray is_interesting.sh my-test-case
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
Where `my-test-case` is some file you want to reduce and `is_interesting.sh` can be any executable that exits with `0` when a test case passed to it is interesting and non-zero otherwise.
|
|
138
|
+
|
|
139
|
+
Variant test cases are passed to the interestingness test both on STDIN and as a file name passed as an argument. Additionally for creduce compatibility, the file has the same base name as the original test case and is in the current working directory the script is run with. This behaviour can be customised with the `--input-type` argument.
|
|
140
|
+
|
|
141
|
+
`shrinkray --help` will give more usage instructions.
|
|
142
|
+
|
|
143
|
+
## Supported formats
|
|
144
|
+
|
|
145
|
+
Shrink Ray is fully generic in the sense that it will work with literally any file you give it in any format. However, some formats will work a lot better than others.
|
|
146
|
+
|
|
147
|
+
It has a generic reduction algorithm that should work pretty well with any textual format, and an architecture that is designed to make it easy to add specialised support for specific formats as needed.
|
|
148
|
+
|
|
149
|
+
Additionally, Shrink Ray has special support for the following formats:
|
|
150
|
+
|
|
151
|
+
* C and C++ (via `clang_delta`, which you will have if creduce is installed)
|
|
152
|
+
* Python
|
|
153
|
+
* JSON
|
|
154
|
+
* Dimacs CNF format for SAT problems
|
|
155
|
+
|
|
156
|
+
Most of this support is quite basic and is just designed to deal with specific cases that the generic logic is known
|
|
157
|
+
not to handle well, but it's easy to extend with additional transformations.
|
|
158
|
+
It is also fairly easy to add support for new formats as needed.
|
|
159
|
+
|
|
160
|
+
If you run into a test case and interestingness test that you care about that shrink ray handles badly please let me know and I'll likely see about improving its handling of that format.
|
|
161
|
+
|
|
162
|
+
## Parallelism
|
|
163
|
+
|
|
164
|
+
You can control the number of parallel tasks shrinkray will run with the `--parallelism` flag. By default this will be the number of CPU cores you have available
|
|
165
|
+
|
|
166
|
+
Shrink Ray is designed to be able to run heavily in parallel, with a basic heuristic of aiming to be embarrassingly parallel when making no progress, mostly sequential when making progress, and smoothly scaling in between the two. It mostly succeeds at this.
|
|
167
|
+
|
|
168
|
+
Currently the bottleneck on scaling to a very large number of cores is how fast the controlling Python program can generate variant test cases to try and pass them to the interestingness test. This isn't well optimised at present and I don't currently have good benchmarks for it, but I'd expect you to be able to get linear speedups on most workflows while running 10-20 test cases in parallel, and to start to struggle past that.
|
|
169
|
+
|
|
170
|
+
This also depends on the performance of the interestingness test - the slower your test is to run, the more you'll be able to scale linearly with the number of cores available.
|
|
171
|
+
|
|
172
|
+
I'm quite interested in getting this part to scale well, so please let me know if you find examples where it doesn't seem to work.
|
|
173
|
+
|
|
174
|
+
## Bug Reports
|
|
175
|
+
|
|
176
|
+
Shrink Ray is still pretty new and under-tested software, so it definitely has bugs. If you run into any, [please file an issue](https://github.com/DRMacIver/shrinkray/issues).
|
|
177
|
+
|
|
178
|
+
As well as obvious bugs (crashes, etc) I'm also very interested in hearing about usability issues and cases where the reduced test case isn't very good.
|
|
179
|
+
|
|
180
|
+
Requests for new features, new supported formats, etc. also welcome although I'm less likely to jump right on them.
|
|
181
|
+
|
|
182
|
+
## Sponsorship
|
|
183
|
+
|
|
184
|
+
Shrink Ray is something of a labour of love - I wanted to have a tool that actually put into practice many of my ideas about test-case reduction, as I think the previous state of the art was well behind where I'd like it to be.
|
|
185
|
+
|
|
186
|
+
That being said, it is first and foremost designed to be a useful tool for practical engineering problems.
|
|
187
|
+
If you find it useful as such, please [consider sponsoring my development of it](https://github.com/sponsors/DRMacIver).
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
# Shrink Ray
|
|
2
|
+
|
|
3
|
+
Shrink Ray is a modern multiformat test-case reducer.
|
|
4
|
+
|
|
5
|
+
## What is test-case reduction?
|
|
6
|
+
|
|
7
|
+
Test-case reduction is the process of automatically taking a *test case* and *reducing* it to something close to a [minimal reproducible example](https://en.wikipedia.org/wiki/Minimal_reproducible_example).
|
|
8
|
+
|
|
9
|
+
That is, you have some file that has some interesting property (usually that it triggers a bug in some software),
|
|
10
|
+
but it is large and complicated and as a result you can't figure out what about the file actually matters.
|
|
11
|
+
You want to be able to trigger the bug with a small, simple, version of it that contains only the features of interest.
|
|
12
|
+
|
|
13
|
+
For example, the following is some Python code that [triggered a bug in libcst](https://github.com/Instagram/LibCST/issues/1061):
|
|
14
|
+
|
|
15
|
+
```python
|
|
16
|
+
() if 0 else(lambda:())
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
This was extracted from a large Python file (probably several thousand lines of code) and systematically reduced down to this example.
|
|
20
|
+
|
|
21
|
+
You would obtain this by running `shrinkray breakslibcst.py mytestcase.py`, where `breakslibcst.py` looks something like this:
|
|
22
|
+
|
|
23
|
+
```python
|
|
24
|
+
import libcst
|
|
25
|
+
import sys
|
|
26
|
+
|
|
27
|
+
if __name__ == '__main__':
|
|
28
|
+
try:
|
|
29
|
+
libcst.parse_module(sys.stdin.read())
|
|
30
|
+
except TypeError:
|
|
31
|
+
sys.exit(0)
|
|
32
|
+
sys.exit(1)
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
This script exits with 0 if the code passed to it on standard input triggers the relevant bug (that libcst raises a TypeError when parsing this code), and with a non-zero exit code otherwise.
|
|
36
|
+
|
|
37
|
+
shrinkray (or any other test-case reducer) then systematically tries smaller and simpler variants of your original source file until it reduces it to something as small as it can manage.
|
|
38
|
+
|
|
39
|
+
While it runs, you will see the following user interface:
|
|
40
|
+
|
|
41
|
+

|
|
42
|
+
|
|
43
|
+
When it finishes you will be left with the reduced test case in `mytestcase.py`.
|
|
44
|
+
|
|
45
|
+
Test-case reducers are useful for any tools that handle files with complex formats that can trigger bugs in them. Historically this has been particularly useful for compilers and other programming tools, but in principle it can be used for anything.
|
|
46
|
+
|
|
47
|
+
Most test-case reducers only work well on a few formats. Shrink Ray is designed to be able to support a wide variety of formats, including binary ones, although it's currently best tuned for "things that look like programming languages".
|
|
48
|
+
|
|
49
|
+
## What makes Shrink Ray distinctive?
|
|
50
|
+
|
|
51
|
+
It's designed to be highly parallel, and work with a very wide variety of formats, through a mix of good generic algorithms and format-specific reduction passes.
|
|
52
|
+
|
|
53
|
+
## Versioning and Releases
|
|
54
|
+
|
|
55
|
+
Shrink Ray uses calendar versioning (calver) in the format YY.M.D.N (e.g., 25.12.26.0 for the first release on December 26, 2025, 25.12.26.1 for the second, etc.).
|
|
56
|
+
|
|
57
|
+
New releases are published automatically when changes are pushed to main if there are any changes to the source code or pyproject.toml since the previous release.
|
|
58
|
+
|
|
59
|
+
Shrinkray makes no particularly strong backwards compatibility guarantees. I aim to keep its behaviour relatively stable between releases, but for example will not be particularly shy about dropping old versions of Python or adding new dependencies. The basic workflow of running a simple reduction will rarely, if ever, change, but the UI is likely to be continuously evolving for some time.
|
|
60
|
+
|
|
61
|
+
## Installation
|
|
62
|
+
|
|
63
|
+
Shrink Ray requires Python 3.12 or later, and can be installed using pip or uv like any other python package.
|
|
64
|
+
|
|
65
|
+
You can install the latest release from PyPI or run directly from the main branch:
|
|
66
|
+
|
|
67
|
+
```
|
|
68
|
+
pipx install shrinkray
|
|
69
|
+
# or
|
|
70
|
+
pipx install git+https://github.com/DRMacIver/shrinkray.git
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
(if you don't have or want [pipx](https://pypa.github.io/pipx/) you could also do this with pip or `uv pip` and it would work fine)
|
|
74
|
+
|
|
75
|
+
Shrink Ray requires Python 3.12 or later and won't work on earlier versions. If everything is working correctly, it should refuse to install
|
|
76
|
+
on versions it's incompatible with. If you do not have Python 3.12 installed, I recommend [pyenv](https://github.com/pyenv/pyenv) for managing
|
|
77
|
+
Python installs.
|
|
78
|
+
|
|
79
|
+
If you want to use it from the git repo directly, you can do the following:
|
|
80
|
+
|
|
81
|
+
```
|
|
82
|
+
git clone https://github.com/DRMacIver/shrinkray.git
|
|
83
|
+
cd shrinkray
|
|
84
|
+
python -m venv .venv
|
|
85
|
+
.venv/bin/pip install -e .
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
You will now have a shrinkray executable in .venv/bin, which you can also put on your path by running `source .venv/bin/activate`.
|
|
89
|
+
|
|
90
|
+
## Usage
|
|
91
|
+
|
|
92
|
+
Shrink Ray is run as follows:
|
|
93
|
+
|
|
94
|
+
```
|
|
95
|
+
shrinkray is_interesting.sh my-test-case
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Where `my-test-case` is some file you want to reduce and `is_interesting.sh` can be any executable that exits with `0` when a test case passed to it is interesting and non-zero otherwise.
|
|
99
|
+
|
|
100
|
+
Variant test cases are passed to the interestingness test both on STDIN and as a file name passed as an argument. Additionally for creduce compatibility, the file has the same base name as the original test case and is in the current working directory the script is run with. This behaviour can be customised with the `--input-type` argument.
|
|
101
|
+
|
|
102
|
+
`shrinkray --help` will give more usage instructions.
|
|
103
|
+
|
|
104
|
+
## Supported formats
|
|
105
|
+
|
|
106
|
+
Shrink Ray is fully generic in the sense that it will work with literally any file you give it in any format. However, some formats will work a lot better than others.
|
|
107
|
+
|
|
108
|
+
It has a generic reduction algorithm that should work pretty well with any textual format, and an architecture that is designed to make it easy to add specialised support for specific formats as needed.
|
|
109
|
+
|
|
110
|
+
Additionally, Shrink Ray has special support for the following formats:
|
|
111
|
+
|
|
112
|
+
* C and C++ (via `clang_delta`, which you will have if creduce is installed)
|
|
113
|
+
* Python
|
|
114
|
+
* JSON
|
|
115
|
+
* Dimacs CNF format for SAT problems
|
|
116
|
+
|
|
117
|
+
Most of this support is quite basic and is just designed to deal with specific cases that the generic logic is known
|
|
118
|
+
not to handle well, but it's easy to extend with additional transformations.
|
|
119
|
+
It is also fairly easy to add support for new formats as needed.
|
|
120
|
+
|
|
121
|
+
If you run into a test case and interestingness test that you care about that shrink ray handles badly please let me know and I'll likely see about improving its handling of that format.
|
|
122
|
+
|
|
123
|
+
## Parallelism
|
|
124
|
+
|
|
125
|
+
You can control the number of parallel tasks shrinkray will run with the `--parallelism` flag. By default this will be the number of CPU cores you have available
|
|
126
|
+
|
|
127
|
+
Shrink Ray is designed to be able to run heavily in parallel, with a basic heuristic of aiming to be embarrassingly parallel when making no progress, mostly sequential when making progress, and smoothly scaling in between the two. It mostly succeeds at this.
|
|
128
|
+
|
|
129
|
+
Currently the bottleneck on scaling to a very large number of cores is how fast the controlling Python program can generate variant test cases to try and pass them to the interestingness test. This isn't well optimised at present and I don't currently have good benchmarks for it, but I'd expect you to be able to get linear speedups on most workflows while running 10-20 test cases in parallel, and to start to struggle past that.
|
|
130
|
+
|
|
131
|
+
This also depends on the performance of the interestingness test - the slower your test is to run, the more you'll be able to scale linearly with the number of cores available.
|
|
132
|
+
|
|
133
|
+
I'm quite interested in getting this part to scale well, so please let me know if you find examples where it doesn't seem to work.
|
|
134
|
+
|
|
135
|
+
## Bug Reports
|
|
136
|
+
|
|
137
|
+
Shrink Ray is still pretty new and under-tested software, so it definitely has bugs. If you run into any, [please file an issue](https://github.com/DRMacIver/shrinkray/issues).
|
|
138
|
+
|
|
139
|
+
As well as obvious bugs (crashes, etc) I'm also very interested in hearing about usability issues and cases where the reduced test case isn't very good.
|
|
140
|
+
|
|
141
|
+
Requests for new features, new supported formats, etc. also welcome although I'm less likely to jump right on them.
|
|
142
|
+
|
|
143
|
+
## Sponsorship
|
|
144
|
+
|
|
145
|
+
Shrink Ray is something of a labour of love - I wanted to have a tool that actually put into practice many of my ideas about test-case reduction, as I think the previous state of the art was well behind where I'd like it to be.
|
|
146
|
+
|
|
147
|
+
That being said, it is first and foremost designed to be a useful tool for practical engineering problems.
|
|
148
|
+
If you find it useful as such, please [consider sponsoring my development of it](https://github.com/sponsors/DRMacIver).
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "shrinkray"
|
|
3
|
+
version = "25.12.26.1"
|
|
4
|
+
description = "Shrink Ray"
|
|
5
|
+
authors = [
|
|
6
|
+
{name = "David R. MacIver", email = "david@drmaciver.com"}
|
|
7
|
+
]
|
|
8
|
+
license = {text = "MIT"}
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
classifiers = [
|
|
11
|
+
"Development Status :: 4 - Beta",
|
|
12
|
+
]
|
|
13
|
+
requires-python = ">=3.12"
|
|
14
|
+
dependencies = [
|
|
15
|
+
"click>=8.0.1",
|
|
16
|
+
"chardet>=5.2.0",
|
|
17
|
+
"trio>=0.28.0",
|
|
18
|
+
"textual>=0.47.0",
|
|
19
|
+
"humanize>=4.9.0",
|
|
20
|
+
"libcst>=1.1.0",
|
|
21
|
+
"exceptiongroup>=1.2.0",
|
|
22
|
+
"binaryornot>=0.4.4",
|
|
23
|
+
"black",
|
|
24
|
+
]
|
|
25
|
+
|
|
26
|
+
[project.urls]
|
|
27
|
+
Homepage = "https://github.com/DRMacIver/shrinkray"
|
|
28
|
+
Repository = "https://github.com/DRMacIver/shrinkray"
|
|
29
|
+
Documentation = "https://shrinkray.readthedocs.io"
|
|
30
|
+
Changelog = "https://github.com/DRMacIver/shrinkray/releases"
|
|
31
|
+
|
|
32
|
+
[project.scripts]
|
|
33
|
+
shrinkray = "shrinkray.__main__:main"
|
|
34
|
+
shrinkray-worker = "shrinkray.__main__:worker_main"
|
|
35
|
+
|
|
36
|
+
[project.optional-dependencies]
|
|
37
|
+
dev = [
|
|
38
|
+
"coverage>=7.13.0",
|
|
39
|
+
"hypothesis>=6.92.1",
|
|
40
|
+
"hypothesmith>=0.3.1",
|
|
41
|
+
"pytest",
|
|
42
|
+
"pytest-trio",
|
|
43
|
+
"pytest-asyncio",
|
|
44
|
+
"pytest-textual-snapshot",
|
|
45
|
+
"coverage[toml]",
|
|
46
|
+
"pygments",
|
|
47
|
+
"basedpyright",
|
|
48
|
+
"ruff",
|
|
49
|
+
"pexpect>=4.9.0",
|
|
50
|
+
"pyte>=0.8.2",
|
|
51
|
+
]
|
|
52
|
+
|
|
53
|
+
[tool.setuptools.packages.find]
|
|
54
|
+
where = ["src"]
|
|
55
|
+
|
|
56
|
+
[tool.coverage.paths]
|
|
57
|
+
source = ["src", "*/site-packages"]
|
|
58
|
+
|
|
59
|
+
[tool.coverage.run]
|
|
60
|
+
branch = true
|
|
61
|
+
source = ["shrinkray"]
|
|
62
|
+
# Use ctrace core instead of sysmon to avoid Python 3.14 async for branch bug
|
|
63
|
+
core = "ctrace"
|
|
64
|
+
|
|
65
|
+
[tool.coverage.report]
|
|
66
|
+
show_missing = true
|
|
67
|
+
fail_under = 100
|
|
68
|
+
|
|
69
|
+
[tool.ruff]
|
|
70
|
+
line-length = 88
|
|
71
|
+
target-version = "py312"
|
|
72
|
+
|
|
73
|
+
[tool.ruff.lint]
|
|
74
|
+
select = ["E", "F", "W", "I", "B", "C4", "UP"]
|
|
75
|
+
ignore = [
|
|
76
|
+
"E501", # line too long - handled by formatter
|
|
77
|
+
"B007", # unused loop variable
|
|
78
|
+
"B023", # function definition in loop
|
|
79
|
+
"B904", # raise without from - intentional in some exception handling
|
|
80
|
+
"C408", # unnecessary dict() call - sometimes more readable
|
|
81
|
+
"UP031", # use format specifiers - % format is fine
|
|
82
|
+
"B018", # useless expression - sometimes intentional for side effects
|
|
83
|
+
"C403", # unnecessary list comprehension - sometimes more readable
|
|
84
|
+
"UP022", # prefer capture_output - explicit is fine
|
|
85
|
+
]
|
|
86
|
+
|
|
87
|
+
[tool.ruff.lint.isort]
|
|
88
|
+
force-single-line = false
|
|
89
|
+
lines-after-imports = 2
|
|
90
|
+
|
|
91
|
+
[tool.basedpyright]
|
|
92
|
+
include = ["src", "tests"]
|
|
93
|
+
exclude = ["build", "bugs", ".venv", ".venv2"]
|
|
94
|
+
typeCheckingMode = "strict"
|
|
95
|
+
reportMissingTypeStubs = false
|
|
96
|
+
# These are too noisy with third-party libraries that lack type stubs
|
|
97
|
+
reportUnknownVariableType = false
|
|
98
|
+
reportUnknownMemberType = false
|
|
99
|
+
reportUnknownParameterType = false
|
|
100
|
+
reportMissingParameterType = false
|
|
101
|
+
reportUnknownArgumentType = false
|
|
102
|
+
reportUnknownLambdaType = false
|
|
103
|
+
# These are often false positives or stylistic
|
|
104
|
+
reportUnusedFunction = false
|
|
105
|
+
reportMissingTypeArgument = false
|
|
106
|
+
reportPrivateUsage = false # Tests need to access private attributes
|
|
107
|
+
reportIncompatibleMethodOverride = false # Often false positives with textual
|
|
108
|
+
reportUnnecessaryIsInstance = false # Needed for runtime type checking of untrusted input
|
|
109
|
+
|
|
110
|
+
[build-system]
|
|
111
|
+
requires = ["setuptools>=61.0", "wheel"]
|
|
112
|
+
build-backend = "setuptools.build_meta"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Shrink Ray."""
|