Skip to content

Commit

Permalink
make all the tooling a workspace
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed Sep 28, 2023
1 parent 0d7da61 commit c5193dd
Show file tree
Hide file tree
Showing 12 changed files with 48 additions and 520 deletions.
8 changes: 8 additions & 0 deletions tooling/minimize/Cargo.lock → tooling/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions tooling/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[workspace]
resolver = "2"
members = ["minirust-rs", "miniutil", "minitest", "minimize"]
9 changes: 0 additions & 9 deletions tooling/minimize/build.rs

This file was deleted.

3 changes: 1 addition & 2 deletions tooling/minimize/src/bb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,7 @@ fn translate_terminator<'cx, 'tcx>(
Terminator::Goto(fcx.bb_name_map[&target])
}
x => {
dbg!(x);
todo!()
unimplemented!("terminator not supported: {x:?}")
}
}
}
Expand Down
36 changes: 12 additions & 24 deletions tooling/minimize/src/get.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,19 @@ use rustc_driver::{Callbacks, Compilation, RunCompiler};
use rustc_interface::{interface::Compiler, Queries};
use rustc_session::EarlyErrorHandler;

pub fn get_mini(file: String, callback: impl FnOnce(Program) + Send + Copy) {
if !Path::new(&file).exists() {
eprintln!("File `{file}` not found.");
std::process::exit(1);
}
pub const DEFAULT_ARGS: &[&str] = &[
"--cfg=miri",
"-Zalways-encode-mir",
"-Zmir-opt-level=0",
// This generates annoying checked operators containing Asserts.
"-Cdebug-assertions=off",
// This removes Resume and similar stuff.
"-Cpanic=abort",
];

let args = [
".".to_string(),
file,
"-L".to_string(),
"./intrinsics/target/debug".to_string(),
"-l".to_string(),
"intrinsics".to_string(),
// flags taken from miri (see https://github.com/rust-lang/miri/blob/master/src/lib.rs#L116)
"-Zalways-encode-mir".to_string(),
"-Zmir-emit-retag".to_string(),
"-Zmir-opt-level=0".to_string(),
"--cfg=miri".to_string(),
"-Zextra-const-ub-checks".to_string(),
// miri turns this on.
// But this generates annoying checked operators containing Asserts.
"-Cdebug-assertions=off".to_string(),
// This removes Resume and similar stuff
"-Cpanic=abort".to_string(),
];
pub fn get_mini(callback: impl FnOnce(Program) + Send + Copy) {
let mut args: Vec<_> = std::env::args().collect();
args.splice(1..1, DEFAULT_ARGS.iter().map(ToString::to_string));
RunCompiler::new(&args, &mut Cb { callback }).run().unwrap();
}

Expand Down
9 changes: 1 addition & 8 deletions tooling/minimize/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,9 @@ mod chunks;
use chunks::calc_chunks;

use std::collections::HashMap;
use std::path::Path;

fn main() {
let file = std::env::args()
.skip(1)
.filter(|x| !x.starts_with('-'))
.next()
.unwrap_or_else(|| String::from("file.rs"));

get_mini(file, |prog| {
get_mini(|prog| {
let dump = std::env::args().skip(1).any(|x| x == "--dump");
if dump {
dump_program(prog);
Expand Down
8 changes: 5 additions & 3 deletions tooling/minimize/tests/compiletest.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::path::PathBuf;

fn cfg(path: &str) -> ui_test::Config {
let bless = std::env::var_os("BLESS").is_some_and(|v| v != "0");
let output_conflict_handling = if bless {
Expand All @@ -12,12 +14,12 @@ fn cfg(path: &str) -> ui_test::Config {
target: None,
stderr_filters: Vec::new(),
stdout_filters: Vec::new(),
root_dir: std::path::PathBuf::from(path),
root_dir: PathBuf::from(path),
mode: ui_test::Mode::Pass,
program: std::path::PathBuf::from("./target/debug/minimize"),
program: PathBuf::from(env!("CARGO_BIN_EXE_minimize")),
output_conflict_handling,
path_filter: Vec::new(),
dependencies_crate_manifest_path: None,
dependencies_crate_manifest_path: Some(PathBuf::from("./tests/deps/Cargo.toml")),
dependency_builder: ui_test::DependencyBuilder::default(),
quiet: false,
num_test_threads: std::thread::available_parallelism().unwrap(),
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions tooling/minimize/tests/deps/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[package]
description = "dependencies that unit tests can have"
name = "dependencies"
version = "0.1.0"

[workspace]
# keeps it out of the `tooling` workspace

[dependencies]
intrinsics = { path = "../../intrinsics/" }
1 change: 1 addition & 0 deletions tooling/minimize/tests/deps/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fn main() {}
241 changes: 0 additions & 241 deletions tooling/minitest/Cargo.lock

This file was deleted.

Loading

0 comments on commit c5193dd

Please sign in to comment.