Skip to content

Commit 3962f0b

Browse files
committedSep 5, 2023
chore: Update dependencies, switch from structop to clap v3
1 parent 44c7a14 commit 3962f0b

File tree

4 files changed

+18
-35
lines changed

4 files changed

+18
-35
lines changed
 

‎Cargo.toml

+5-4
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22
edition = "2021"
33
name = "testsuite-adaptor"
44
version = "0.1.0"
5+
56
[dependencies]
67
anyhow = "1.0"
8+
clap = { version = "4.4.2", features = ["derive"] }
79
colored = "2.0"
8-
rayon = "1.5"
9-
structopt = "0.3"
10+
rayon = "1.7"
1011
thiserror = "1.0"
1112
wait-timeout = "0.2"
12-
walkdir = "2.0"
13-
which = "4.2"
13+
walkdir = "2.3"
14+
which = "4.4"

‎src/args.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,28 @@ use crate::passes::PassKind;
22

33
use std::path::PathBuf;
44

5-
use structopt::StructOpt;
5+
use clap::Parser;
66

7-
#[derive(StructOpt)]
7+
#[derive(Parser)]
88
pub struct Args {
9-
#[structopt(
9+
#[arg(
1010
short,
1111
long,
1212
help = "output directory which will contain the new tests"
1313
)]
1414
pub(crate) output_dir: PathBuf,
15-
#[structopt(short, long, help = "generated YAML ftf file name")]
15+
#[arg(short, long, help = "generated YAML ftf file name")]
1616
pub(crate) yaml: PathBuf,
17-
#[structopt(short, long, help = "path to the rustc compiler to use")]
17+
#[arg(short, long, help = "path to the rustc compiler to use")]
1818
pub(crate) rustc: PathBuf,
19-
#[structopt(short, long, help = "path to the gccrs compiler to use")]
19+
#[arg(short, long, help = "path to the gccrs compiler to use")]
2020
pub(crate) gccrs: PathBuf,
21-
#[structopt(long, help = "path to a cloned rust repository")]
21+
#[arg(long, help = "path to a cloned rust repository")]
2222
pub(crate) rust_path: PathBuf,
23-
#[structopt(long, help = "path to a cloned gccrs repository")]
23+
#[arg(long, help = "path to a cloned gccrs repository")]
2424
pub(crate) gccrs_path: PathBuf,
25-
#[structopt(short, long, help = "pass to to run in the adaptor")]
25+
#[arg(short, long, help = "pass to to run in the adaptor")]
2626
pub(crate) pass: PassKind,
27-
#[structopt(short, long, help = "amount of threads to use", default_value = "1")]
27+
#[arg(short, long, help = "amount of threads to use", default_value = "1")]
2828
pub(crate) jobs: usize,
2929
}

‎src/main.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ use args::Args;
1414
use error::Error;
1515
use passes::{Pass, PassKind};
1616

17+
use clap::Parser;
1718
use rayon::prelude::*;
1819
use steps::CompileStep;
19-
use structopt::StructOpt;
2020
use walkdir::WalkDir;
2121
use which::which;
2222

@@ -124,7 +124,7 @@ fn warn_on_file_not_found(name: &str, path: &Path) {
124124
}
125125

126126
fn main() -> anyhow::Result<()> {
127-
let args = Args::from_args();
127+
let args = Args::parse();
128128
maybe_create_output_dir(&args.output_dir)?;
129129
if !args.rust_path.exists() {
130130
return Err(Error::NoRust(args.rust_path).into());

‎src/passes.rs

+1-19
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ pub use rustc_dejagnu::RustcDejagnu;
1515
use std::ffi::OsStr;
1616
use std::fmt::Display;
1717
use std::path::{Path, PathBuf};
18-
use std::str::FromStr;
1918

2019
use crate::compiler::Compiler;
2120
use crate::{args::Args, error::Error};
@@ -154,6 +153,7 @@ pub trait Pass: Sync {
154153

155154
/// Passes to run when generating the test-suite file. One can chose to run only
156155
/// a specific pass, or multiple of them
156+
#[derive(Clone, Copy, clap::ValueEnum)]
157157
pub enum PassKind {
158158
/// Generates test cases for running gccrs and rustc in parse-only mode on
159159
/// the rustc test suite
@@ -183,24 +183,6 @@ impl Display for InvalidPassKind {
183183
}
184184
}
185185

186-
impl FromStr for PassKind {
187-
type Err = InvalidPassKind;
188-
189-
fn from_str(s: &str) -> Result<PassKind, Self::Err> {
190-
match s {
191-
"gccrs-parsing" => Ok(PassKind::GccrsParsing),
192-
"rustc-dejagnu" => Ok(PassKind::RustcDejagnu),
193-
"gccrs-rustc-success" => Ok(PassKind::GccrsRustcSucess),
194-
"gccrs-rustc-success-no-std" => Ok(PassKind::GccrsRustcSucessNoStd),
195-
"gccrs-rustc-success-no-core" => Ok(PassKind::GccrsRustcSucessNoCore),
196-
"blake3" => Ok(PassKind::Blake3),
197-
"libcore" => Ok(PassKind::LibCore),
198-
"ast-export" => Ok(PassKind::AstExport),
199-
s => Err(InvalidPassKind(s.to_string())),
200-
}
201-
}
202-
}
203-
204186
impl Display for PassKind {
205187
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
206188
let s = match &self {

0 commit comments

Comments
 (0)