Skip to content

Commit 4ec4999

Browse files
committed
feat: Allow '.md' extension
This makes it easier for text editors and github to format the files for human reading / editing. In doing this, we need to gracefully handle unrelated `.md` files. This means we allow, rather than error, if there are no test cases. We don't want syntax mistakes to cause tests to be silently ignored, so we elevate these cases as `ignored` in the UI.
1 parent 6f13c7a commit 4ec4999

File tree

5 files changed

+9
-6
lines changed

5 files changed

+9
-6
lines changed

examples/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Examples and example test cases
File renamed without changes.

src/runner.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,12 @@ impl Case {
146146
}
147147
};
148148

149+
if sequence.steps.is_empty() {
150+
let output = Output::sequence(self.path.clone());
151+
assert_eq!(output.spawn.status, SpawnStatus::Skipped);
152+
return vec![Ok(output)];
153+
}
154+
149155
let fs_context = match crate::FilesystemContext::new(
150156
&self.path,
151157
sequence.fs.base.as_deref(),

src/schema.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ impl TryCmd {
4646
sequence.steps[0].expected_stderr = stderr;
4747

4848
sequence
49-
} else if ext == std::ffi::OsStr::new("trycmd") {
49+
} else if ext == std::ffi::OsStr::new("trycmd") || ext == std::ffi::OsStr::new("md") {
5050
let raw = crate::File::read_from(path, false)?.into_utf8().unwrap();
5151
Self::parse_trycmd(&raw)?
5252
} else {
@@ -190,10 +190,6 @@ impl TryCmd {
190190
}
191191
}
192192

193-
if steps.is_empty() {
194-
return Err("No runs in trycmd file".into());
195-
}
196-
197193
Ok(Self {
198194
steps,
199195
..Default::default()

tests/example_tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
fn example_tests() {
44
let t = trycmd::TestCases::new();
55
t.register_bins(trycmd::cargo::compile_examples([]).unwrap());
6-
t.case("examples/*.trycmd");
6+
t.case("examples/*.md");
77
}

0 commit comments

Comments
 (0)