MCPcopy Index your code
hub / github.com/endbasic/endbasic / run_one_test

Function run_one_test

core/tests/testutils/mod.rs:585–610  ·  view source on GitHub ↗

Executes the test described in the `core/tests/ .md` file.

(name: &'static str)

Source from the content-addressed store, hash-verified

583
584/// Executes the test described in the `core/tests/<name>.md` file.
585pub(super) async fn run_one_test(name: &'static str) -> io::Result<()> {
586 let golden = src_path(&format!("core/tests/{}.md", name));
587 let line_ending = line_ending_for(&golden)?;
588
589 let mut generated = NamedTempFile::new()?;
590 regenerate(&golden, &mut generated).await?;
591 generated.flush()?;
592 rewrite_with_line_ending(generated.path(), line_ending)?;
593
594 let diff = diff(&golden, generated.path())?;
595 if !diff.is_empty() {
596 if matches!(env::var("REGEN").as_deref(), Ok("1") | Ok("true") | Ok("yes")) {
597 {
598 let mut output = File::create(golden)?;
599 generated.as_file_mut().seek(io::SeekFrom::Start(0))?;
600 io::copy(&mut generated, &mut output)?;
601 }
602 panic!("Golden data regenerated; flip REGEN back to false");
603 } else {
604 eprintln!("{}", diff);
605 panic!("Test failed; see stderr for details");
606 }
607 }
608
609 Ok(())
610}

Callers

nothing calls this directly

Calls 7

line_ending_forFunction · 0.85
regenerateFunction · 0.85
rewrite_with_line_endingFunction · 0.85
diffFunction · 0.85
src_pathFunction · 0.70
flushMethod · 0.45
is_emptyMethod · 0.45

Tested by

no test coverage detected