Skip to content

Commit 2e6490f

Browse files
authored
Merge pull request #446 from brendanzab/upgrade-crate-dependencies
Upgrade some dependencies
2 parents 6851538 + 8e936fa commit 2e6490f

File tree

8 files changed

+521
-511
lines changed

8 files changed

+521
-511
lines changed

Cargo.lock

Lines changed: 364 additions & 314 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

fathom/Cargo.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ version = "0.1.0"
44
authors = ["YesLogic Pty. Ltd. <[email protected]>"]
55
repository = "https://github.com/yeslogic/fathom"
66
edition = "2021"
7-
rust-version = "1.62.0"
7+
rust-version = "1.65.0"
88
publish = false
99

1010
description = "A language for declaratively specifying binary data formats"
@@ -19,14 +19,14 @@ harness = false
1919

2020
[dependencies]
2121
atty = "0.2.14"
22-
clap = { version = "3.2.5", features = ["derive"] }
22+
clap = { version = "4.0", features = ["derive"] }
2323
codespan-reporting = "0.11.1"
2424
fxhash = "0.2"
2525
itertools = "0.10"
2626
lalrpop-util = "0.19.5"
2727
logos = "0.12"
2828
pretty = "0.11.2"
29-
rpds = "0.11"
29+
rpds = "0.12.0"
3030
scoped-arena = "0.3"
3131
string-interner = "0.14.0"
3232
termsize = "0.1.6"
@@ -38,8 +38,8 @@ lalrpop = { git = "https://github.com/kmeakin/lalrpop", branch = "raw-identifier
3838
diff = "0.1.12"
3939
globwalk = "0.8"
4040
itertools = "0.10.1"
41-
libtest-mimic = "0.3.0"
41+
libtest-mimic = "0.6.0"
4242
serde = { version = "1.0", features = ["derive"] }
4343
toml = "0.5"
44-
trycmd = "0.13.4"
44+
trycmd = "0.14.10"
4545
walkdir = "2.3.2"

fathom/tests/source_tests.rs

Lines changed: 49 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,7 @@ fn main() {
1515
.chain(find_source_files("tests").map(extract_term_test))
1616
.collect();
1717

18-
libtest_mimic::run_tests(&args, tests, run_test).exit();
19-
}
20-
21-
pub struct TestData {
22-
input_file: PathBuf,
23-
mode: TestMode,
18+
libtest_mimic::run(&args, tests).exit();
2419
}
2520

2621
#[derive(Deserialize, Debug, Copy, Clone)]
@@ -138,73 +133,63 @@ pub fn find_source_files(root: impl AsRef<Path>) -> impl Iterator<Item = PathBuf
138133
.map(|entry| entry.into_path())
139134
}
140135

141-
fn extract_module_test(path: PathBuf) -> libtest_mimic::Test<TestData> {
142-
libtest_mimic::Test {
143-
name: path.display().to_string(),
144-
kind: String::new(),
145-
is_ignored: false,
146-
is_bench: false,
147-
data: TestData {
148-
input_file: path,
149-
mode: TestMode::Module,
150-
},
151-
}
136+
fn extract_module_test(path: PathBuf) -> libtest_mimic::Trial {
137+
extract_test(path, TestMode::Module)
152138
}
153139

154-
fn extract_term_test(path: PathBuf) -> libtest_mimic::Test<TestData> {
155-
libtest_mimic::Test {
156-
name: path.display().to_string(),
157-
kind: String::new(),
158-
is_ignored: false,
159-
is_bench: false,
160-
data: TestData {
161-
input_file: path,
162-
mode: TestMode::Term,
163-
},
164-
}
140+
fn extract_term_test(path: PathBuf) -> libtest_mimic::Trial {
141+
extract_test(path, TestMode::Term)
165142
}
166143

167-
fn run_test(test: &libtest_mimic::Test<TestData>) -> libtest_mimic::Outcome {
168-
let mut failures = Vec::new();
144+
fn extract_test(input_file: PathBuf, default_mode: TestMode) -> libtest_mimic::Trial {
145+
use itertools::Itertools;
169146

170-
let config: Config = {
171-
use itertools::Itertools;
147+
let test_name = input_file.display().to_string();
172148

173-
const CONFIG_COMMENT_START: &str = "//~";
149+
const CONFIG_COMMENT_START: &str = "//~";
174150

175-
let input_source = std::fs::read_to_string(&test.data.input_file).unwrap();
176-
// Collect the lines with CONFIG_COMMENT_START prefix, stripping the prefix in the process
177-
let config_source = input_source
178-
.lines()
179-
.filter_map(|line| line.split(CONFIG_COMMENT_START).nth(1))
180-
.join("\n");
151+
let input_source = std::fs::read_to_string(&input_file).unwrap();
152+
// Collect the lines with CONFIG_COMMENT_START prefix, stripping the prefix in the process
153+
let config_source = input_source
154+
.lines()
155+
.filter_map(|line| line.split(CONFIG_COMMENT_START).nth(1))
156+
.join("\n");
181157

182-
// Parse those lines as TOML
183-
match toml::from_str::<Config>(&config_source) {
184-
Ok(mut config) => {
185-
config.update_snapshots = env::var_os("FATHOM_UPDATE_SNAP").is_some();
186-
config
187-
}
188-
Err(error) => {
189-
failures.push(TestFailure {
190-
name: "config parse error",
191-
details: vec![("toml::de::Error", error.to_string())],
192-
});
158+
// Parse those lines as TOML
159+
match toml::from_str::<Config>(&config_source) {
160+
Ok(mut config) => {
161+
config.update_snapshots = env::var_os("FATHOM_UPDATE_SNAP").is_some();
193162

194-
return failures_to_outcome(&failures);
163+
if config.ignore {
164+
libtest_mimic::Trial::test(test_name, || Ok(())).with_ignored_flag(true)
165+
} else {
166+
libtest_mimic::Trial::test(test_name, move || {
167+
run_test(input_file, default_mode, config)
168+
})
195169
}
196170
}
197-
};
198-
199-
if config.ignore {
200-
return libtest_mimic::Outcome::Ignored;
171+
Err(error) => libtest_mimic::Trial::test(test_name, move || {
172+
failures_to_outcome(&[TestFailure {
173+
name: "config parse error",
174+
details: vec![("toml::de::Error", error.to_string())],
175+
}])
176+
}),
201177
}
178+
}
179+
180+
fn run_test(
181+
input_file: PathBuf,
182+
default_mode: TestMode,
183+
config: Config,
184+
) -> Result<(), libtest_mimic::Failed> {
185+
let mut failures = Vec::new();
202186

203187
let command = match config.mode {
204188
Some(mode) => mode.to_command(),
205-
None => test.data.mode.to_command(),
189+
None => default_mode.to_command(),
206190
};
207-
let test_command = TestCommand::new(command, &config, &test.data.input_file);
191+
192+
let test_command = TestCommand::new(command, &config, &input_file);
208193
match test_command.run() {
209194
Ok(mut test_failures) => failures.append(&mut test_failures),
210195
Err(error) => {
@@ -216,7 +201,7 @@ fn run_test(test: &libtest_mimic::Test<TestData>) -> libtest_mimic::Outcome {
216201
}
217202

218203
if config.test_normalisation {
219-
let test_command = TestCommand::new(Command::Normalise, &config, &test.data.input_file);
204+
let test_command = TestCommand::new(Command::Normalise, &config, &input_file);
220205
match test_command.run() {
221206
Ok(mut test_failures) => failures.append(&mut test_failures),
222207
Err(error) => {
@@ -228,13 +213,13 @@ fn run_test(test: &libtest_mimic::Test<TestData>) -> libtest_mimic::Outcome {
228213
}
229214
}
230215

231-
let base_dir = test.data.input_file.with_file_name("");
216+
let base_dir = input_file.with_file_name("");
232217
let example_data = globwalk::GlobWalkerBuilder::from_patterns(&base_dir, &config.example_data)
233218
.build()
234219
.unwrap();
235220

236221
for example_file in example_data.filter_map(Result::ok) {
237-
let command = Command::ParseData(&test.data.input_file, ExpectedOutcome::Success);
222+
let command = Command::ParseData(&input_file, ExpectedOutcome::Success);
238223
let test_command = TestCommand::new(command, &config, example_file.path());
239224
match test_command.run() {
240225
Ok(mut test_failures) => failures.append(&mut test_failures),
@@ -253,7 +238,7 @@ fn run_test(test: &libtest_mimic::Test<TestData>) -> libtest_mimic::Outcome {
253238
.unwrap();
254239

255240
for example_file in invalid_example_data.filter_map(Result::ok) {
256-
let command = Command::ParseData(&test.data.input_file, ExpectedOutcome::Failure);
241+
let command = Command::ParseData(&input_file, ExpectedOutcome::Failure);
257242
let test_command = TestCommand::new(command, &config, example_file.path());
258243
match test_command.run() {
259244
Ok(mut test_failures) => failures.append(&mut test_failures),
@@ -269,9 +254,9 @@ fn run_test(test: &libtest_mimic::Test<TestData>) -> libtest_mimic::Outcome {
269254
failures_to_outcome(&failures)
270255
}
271256

272-
fn failures_to_outcome(failures: &[TestFailure]) -> libtest_mimic::Outcome {
257+
fn failures_to_outcome(failures: &[TestFailure]) -> Result<(), libtest_mimic::Failed> {
273258
if failures.is_empty() {
274-
libtest_mimic::Outcome::Passed
259+
Ok(())
275260
} else {
276261
let mut msg = String::new();
277262

@@ -292,7 +277,7 @@ fn failures_to_outcome(failures: &[TestFailure]) -> libtest_mimic::Outcome {
292277
writeln!(msg, " {}", failure.name).unwrap();
293278
}
294279

295-
libtest_mimic::Outcome::Failed { msg: Some(msg) }
280+
Err(msg.into())
296281
}
297282
}
298283

flake.lock

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/cmd/fathom-data.md

Lines changed: 34 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,18 @@ Short help can be printed with `-h`
66

77
```console
88
$ fathom data -h
9-
fathom-data
109
Manipulate binary data based on a Fathom format
1110

12-
USAGE:
13-
fathom data [OPTIONS] <BINARY_FILE>
11+
Usage: fathom data [OPTIONS] <BINARY_FILE>
1412

15-
ARGS:
16-
<BINARY_FILE> Path to the binary data to read from
13+
Arguments:
14+
<BINARY_FILE> Path to the binary data to read from
1715

18-
OPTIONS:
19-
--module <MODULE_FILE> Path to a module to load when reading
20-
--format <FORMAT> Format used when reading the binary data [default: main]
21-
--allow-errors Continue even if errors were encountered
22-
-h, --help Print help information
16+
Options:
17+
--module <MODULE_FILE> Path to a module to load when reading
18+
--format <FORMAT> Format used when reading the binary data [default: main]
19+
--allow-errors Continue even if errors were encountered
20+
-h, --help Print help information (use `--help` for more detail)
2321

2422
Examples:
2523

@@ -33,34 +31,32 @@ Long help can be printed with `--help`
3331

3432
```console
3533
$ fathom data --help
36-
fathom-data
3734
Manipulate binary data based on a Fathom format
3835

39-
USAGE:
40-
fathom data [OPTIONS] <BINARY_FILE>
36+
Usage: fathom data [OPTIONS] <BINARY_FILE>
4137

42-
ARGS:
43-
<BINARY_FILE>
44-
Path to the binary data to read from
38+
Arguments:
39+
<BINARY_FILE>
40+
Path to the binary data to read from
4541

46-
OPTIONS:
47-
--module <MODULE_FILE>
48-
Path to a module to load when reading
42+
Options:
43+
--module <MODULE_FILE>
44+
Path to a module to load when reading
4945

50-
--format <FORMAT>
51-
Format used when reading the binary data
52-
53-
The term provided by `FORMAT` must be of type `Format`.
54-
55-
Required unless `--module` is present.
56-
57-
[default: main]
46+
--format <FORMAT>
47+
Format used when reading the binary data
48+
49+
The term provided by `FORMAT` must be of type `Format`.
50+
51+
Required unless `--module` is present.
52+
53+
[default: main]
5854

59-
--allow-errors
60-
Continue even if errors were encountered
55+
--allow-errors
56+
Continue even if errors were encountered
6157

62-
-h, --help
63-
Print help information
58+
-h, --help
59+
Print help information (use `-h` for a summary)
6460

6561
Binary data can be read using a term supplied by the `--format` option:
6662

@@ -190,12 +186,12 @@ Arguments must be provided to `fathom data`
190186
$ fathom data
191187
? failed
192188
error: The following required arguments were not provided:
193-
<BINARY_FILE>
189+
--format <FORMAT>
190+
<BINARY_FILE>
194191

195-
USAGE:
196-
fathom data [OPTIONS] <BINARY_FILE>
192+
Usage: fathom data --format <FORMAT> <BINARY_FILE>
197193

198-
For more information try --help
194+
For more information try '--help'
199195

200196
```
201197

@@ -205,12 +201,11 @@ The `--format` option must be present when `--module` is not supplied
205201
$ fathom data formats/data/edid/dell-P2415Q.edid
206202
? failed
207203
error: The following required arguments were not provided:
208-
--format <FORMAT>
204+
--format <FORMAT>
209205

210-
USAGE:
211-
fathom data --format <FORMAT> <BINARY_FILE>
206+
Usage: fathom data --format <FORMAT> <BINARY_FILE>
212207

213-
For more information try --help
208+
For more information try '--help'
214209

215210
```
216211

0 commit comments

Comments
 (0)