File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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+ }
You can’t perform that action at this time.
0 commit comments