Crates.io | minimizer |
lib.rs | minimizer |
version | 2.0.3 |
source | src |
created_at | 2024-08-04 15:25:29.314958 |
updated_at | 2024-11-13 14:30:36.909306 |
description | Minimize files to find minimal test case |
homepage | https://github.com/qarmin/minimizer |
repository | https://github.com/qarmin/minimizer |
max_upload_size | |
id | 1325060 |
size | 60,639 |
Minimizer is a program that is able to minimize the size of files so that they still meet the set requirements.
It is the best suited for minimizing files for fast app, which one iteration takes less than second.
Currently it works only on Linux.
cargo install --path .
or just compile it with crates.io
cargo install minimizer
minimizer --input-file input.txt --output-file output.txt --command "echo {}" --attempts 300 --broken-info "BROKEN"
to get info about each argument, read source code or run
minimizer --help
echo "ABCDEFGH" > input.txt
echo "gABCDEFFGH" >> input.txt
echo "BCDERF" >> input.txt
echo "ABCD" >> input.txt
echo "BDCE" >> input.txt
running
minimizer --input-file input.txt --output-file output.txt --command "cat {}" --attempts 300 --broken-info "AB" -e -v
will probably give you output.txt with content
AB
algorithms are not deterministic so not always the same result will be achieved
Using bigger number of attempts will increase the chance of getting smaller output file and will enable additional mode which rely on removing line/byte/char one by one.
At start minimizer reads file and checks if this file returns expected output.
If yes, then app continue to run.
At first app checks if file contains valid utf-8 characters, if yes, then two additional modes are enabled, which works on lines and characters.
Each mode(which works on Vec<> of lines, chars and bytes) at start, tries to remove items from start/end of file.
Later in loop random elements from middle/start/end are removed to check if file still returns expected output.
Basing on different files, different strategies can be used to minimize file.
In repo only one general strategy is implemented, which should be good for most of the files.
But if you have some specific file, you can implement your own strategy
minimizer --input-file /home/rafal/Desktop/RunEveryCommand/C/PY_FILE_TEST_25518.py --output-file a.py --command "red_knot" --attempts 1000 --broken-info "RUST_BACKTRACE" -z "not yet implemented" -z "failed to parse" -z "SyntaxError" -z "Sorry:" -z "IndentationError" -k "python3 -m compileall {}" -r -v
or shorter
minimizer -i /home/rafal/Desktop/RunEveryCommand/C/PY_FILE_TEST_25518.py -o a.py -c "red_knot" -a 1000 -b "RUST_BACKTRACE" -z "not yet implemented" -z "failed to parse" -z "SyntaxError" -z "Sorry:" -z "IndentationError" -k "python3 -m compileall {}" -r -v
minimizer --input-file /home/rafal/Desktop/RunEveryCommand/C/PY_FILE_TEST_25518.py --output-file a.py --command "red_knot" --attempts 1000 --broken-info "RUST_BACKTRACE" -z "not yet implemented" -z "failed to parse" -z "SyntaxError" -z "Sorry:" -z "IndentationError" -k "python3 -m compileall {}" -r -v
minimizer --input-file input.mp3 --output-file output.mp3 --command "lofty {}" --attempts 100000 -r --broken-info "RUST_BACKTRACE" -v --max-time 200 --strategy pedantic
or sho
minimizer -i input.mp3 -o output.mp3 -c "lofty {}" -a 100000 -r -b "RUST_BACKTRACE" -v -t 200 -s pedantic
I just needed this - I doubt that it will be useful for anyone else, but feel free to use this.
MIT License