mirror of
https://github.com/Noratrieb/cargo-minimize.git
synced 2026-01-16 17:25:03 +01:00
some docs
This commit is contained in:
parent
4f4afa627d
commit
e918248016
2 changed files with 45 additions and 4 deletions
27
README.md
27
README.md
|
|
@ -2,4 +2,29 @@
|
||||||
|
|
||||||
Install with `cargo install --git https://github.com/Nilstrieb/cargo-minimize` and use with `cargo minimize`.
|
Install with `cargo install --git https://github.com/Nilstrieb/cargo-minimize` and use with `cargo minimize`.
|
||||||
|
|
||||||
It's in a stage where it probably mostly works but is not very good and the output is unreadable if you don't know the internals.
|
## Idea
|
||||||
|
|
||||||
|
When encountering problems like internal compiler errors, it's often desirable to have a minimal reproduction that can be used by the people fixing the issue. Usually, these problems are found in big codebases. Getting from a big codebase to a small (<50 LOC) reproduction is non-trivial and requires a lot of manual work. `cargo-minimize` assists you with doing some minimization steps that can be easily automated for you.
|
||||||
|
|
||||||
|
## How to use
|
||||||
|
|
||||||
|
For minimizing an internal compiler error on a normal cargo project, `cargo minimize` works out of the box. There are many configuration options available though.
|
||||||
|
|
||||||
|
```
|
||||||
|
Usage: cargo minimize [OPTIONS] [PATH]
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
[PATH] The directory/file of the code to be minimited [default: src]
|
||||||
|
|
||||||
|
Options:
|
||||||
|
--cargo-args <CARGO_ARGS> Additional arguments to pass to cargo, seperated by whitespace
|
||||||
|
--no-color To disable colored output
|
||||||
|
--rustc This option bypasses cargo and uses rustc directly. Only works when a single file is passed as an argument
|
||||||
|
--no-verify Skips testing whether the regression reproduces and just does the most aggressive minimization. Mostly useful for testing an demonstration purposes
|
||||||
|
--verify-fn <VERIFY_FN> A Rust closure returning a bool that checks whether a regression reproduces. Example: `--verify_fn='|output| output.contains("internal compiler error")'`
|
||||||
|
--env <ENV> Additional environment variables to pass to cargo/rustc. Example: `--env NAME=VALUE --env ANOTHER_NAME=VALUE`
|
||||||
|
--project-dir <PROJECT_DIR> The working directory where cargo/rustc are invoked in. By default, this is the current working directory
|
||||||
|
--script-path <SCRIPT_PATH> NOTE: This is currently broken. A path to a script that is run to check whether code reproduces. When it exits with code 0, the problem reproduces
|
||||||
|
-h, --help Print help information
|
||||||
|
```
|
||||||
|
|
||||||
22
src/lib.rs
22
src/lib.rs
|
|
@ -31,30 +31,46 @@ pub enum Cargo {
|
||||||
|
|
||||||
#[derive(clap::Args, Debug)]
|
#[derive(clap::Args, Debug)]
|
||||||
pub struct Options {
|
pub struct Options {
|
||||||
#[arg(short, long)]
|
/// Additional arguments to pass to cargo, seperated by whitespace.
|
||||||
pub script_path: Option<PathBuf>,
|
|
||||||
|
|
||||||
#[arg(long)]
|
#[arg(long)]
|
||||||
pub cargo_args: Option<String>,
|
pub cargo_args: Option<String>,
|
||||||
|
|
||||||
|
/// To disable colored output.
|
||||||
#[arg(long)]
|
#[arg(long)]
|
||||||
pub no_color: bool,
|
pub no_color: bool,
|
||||||
|
|
||||||
|
/// This option bypasses cargo and uses rustc directly. Only works when a single file is passed as an argument.
|
||||||
#[arg(long)]
|
#[arg(long)]
|
||||||
pub rustc: bool,
|
pub rustc: bool,
|
||||||
|
|
||||||
|
/// Skips testing whether the regression reproduces and just does the most aggressive minimization. Mostly useful
|
||||||
|
/// for testing an demonstration purposes.
|
||||||
#[arg(long)]
|
#[arg(long)]
|
||||||
pub no_verify: bool,
|
pub no_verify: bool,
|
||||||
|
|
||||||
|
/// A Rust closure returning a bool that checks whether a regression reproduces.
|
||||||
|
/// Example: `--verify_fn='|output| output.contains("internal compiler error")'`
|
||||||
#[arg(long)]
|
#[arg(long)]
|
||||||
pub verify_fn: Option<RustFunction>,
|
pub verify_fn: Option<RustFunction>,
|
||||||
|
|
||||||
|
/// Additional environment variables to pass to cargo/rustc.
|
||||||
|
/// Example: `--env NAME=VALUE --env ANOTHER_NAME=VALUE`
|
||||||
#[arg(long)]
|
#[arg(long)]
|
||||||
pub env: Vec<EnvVar>,
|
pub env: Vec<EnvVar>,
|
||||||
|
|
||||||
|
/// The working directory where cargo/rustc are invoked in. By default, this is the current working directory.
|
||||||
#[arg(long)]
|
#[arg(long)]
|
||||||
pub project_dir: Option<PathBuf>,
|
pub project_dir: Option<PathBuf>,
|
||||||
|
|
||||||
|
/// The directory/file of the code to be minimited.
|
||||||
#[arg(default_value = "src")]
|
#[arg(default_value = "src")]
|
||||||
pub path: PathBuf,
|
pub path: PathBuf,
|
||||||
|
|
||||||
|
/// NOTE: This is currently broken.
|
||||||
|
/// A path to a script that is run to check whether code reproduces. When it exits with code 0, the
|
||||||
|
/// problem reproduces.
|
||||||
|
#[arg(long)]
|
||||||
|
pub script_path: Option<PathBuf>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue