Skip to content

Commit 4022bb4

Browse files
committed
add failing test for issue #145
1 parent 5295c19 commit 4022bb4

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

tests/e2e/bindings.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,3 +147,35 @@ build foo: write_file
147147
assert_eq!(space.read("foo")?, b"Hello, world!\n");
148148
Ok(())
149149
}
150+
151+
// Test for https://github.com/evmar/n2/issues/145: a variable in one file is visible
152+
// in an included file.
153+
#[test]
154+
fn across_files() -> anyhow::Result<()> {
155+
let space = TestSpace::new()?;
156+
space.write(
157+
"build.ninja",
158+
&[
159+
ECHO_RULE,
160+
"
161+
var = hello
162+
include other.ninja
163+
",
164+
]
165+
.join("\n"),
166+
)?;
167+
space.write(
168+
"other.ninja",
169+
"
170+
build out: echo $var/world
171+
",
172+
)?;
173+
174+
let out = space.run(&mut n2_command(vec!["out"]))?;
175+
assert_output_contains(&out, "input /world missing");
176+
177+
// TODO: should instead be something like:
178+
// let out = space.run_expect(&mut n2_command(vec!["out"]))?;
179+
// assert_output_contains(&out, "echo hello/world");
180+
Ok(())
181+
}

0 commit comments

Comments
 (0)