From d8c5756cbe98d20b55c42fa86a9c999ba1f3057b Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Mon, 25 Oct 2021 18:59:40 -0700 Subject: [PATCH] Add input file path to context for normalization --- src/normalize.rs | 2 ++ src/run.rs | 1 + src/tests.rs | 5 ++++- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/normalize.rs b/src/normalize.rs index a2111d1..2a034fb 100644 --- a/src/normalize.rs +++ b/src/normalize.rs @@ -4,12 +4,14 @@ mod tests; use crate::directory::Directory; use crate::run::PathDependency; +use std::path::Path; #[derive(Copy, Clone)] pub struct Context<'a> { pub krate: &'a str, pub source_dir: &'a Directory, pub workspace: &'a Directory, + pub input_file: &'a Path, pub path_dependencies: &'a [PathDependency], } diff --git a/src/run.rs b/src/run.rs index cc2f34e..cca7cf9 100644 --- a/src/run.rs +++ b/src/run.rs @@ -267,6 +267,7 @@ impl Test { krate: &name.0, source_dir: &project.source_dir, workspace: &project.workspace, + input_file: &self.path, path_dependencies: &project.path_dependencies, }, ); diff --git a/src/tests.rs b/src/tests.rs index 8c8b076..b4e432d 100644 --- a/src/tests.rs +++ b/src/tests.rs @@ -1,12 +1,14 @@ use crate::directory::Directory; use crate::run::PathDependency; +use std::path::Path; macro_rules! test_normalize { - ($name:ident $(DIR=$dir:literal)? $(WORKSPACE=$workspace:literal)? $original:literal $expected:literal) => { + ($name:ident $(DIR=$dir:literal)? $(WORKSPACE=$workspace:literal)? $(INPUT=$input:literal)? $original:literal $expected:literal) => { #[test] fn $name() { let context = super::Context { krate: "trybuild000", + input_file: Path::new({ "tests/ui/input.rs" $(; $input)? }), source_dir: &Directory::new({ "/git/trybuild/test_suite" $(; $dir)? }), workspace: &Directory::new({ "/git/trybuild" $(; $workspace)? }), path_dependencies: &[PathDependency { @@ -274,6 +276,7 @@ Additional crates such as `pyo3-asyncio` can be used to integrate async Rust and test_normalize! {test_dropshot_required_by DIR="/git/dropshot/dropshot" WORKSPACE="/git/dropshot" + INPUT="tests/fail/bad_endpoint4.rs" " error[E0277]: the trait bound `QueryParams: schemars::JsonSchema` is not satisfied --> /git/dropshot/dropshot/tests/fail/bad_endpoint4.rs:24:14