Skip to content

Commit

Permalink
Add input file path to context for normalization
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Oct 26, 2021
1 parent db6e880 commit d8c5756
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/normalize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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],
}

Expand Down
1 change: 1 addition & 0 deletions src/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
);
Expand Down
5 changes: 4 additions & 1 deletion src/tests.rs
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit d8c5756

Please sign in to comment.