diff --git a/test cases/failing/121 structured source empty string/main.rs b/test cases/failing/121 structured source empty string/main.rs new file mode 100644 index 000000000..e69de29bb diff --git a/test cases/failing/121 structured source empty string/meson.build b/test cases/failing/121 structured source empty string/meson.build new file mode 100644 index 000000000..071599147 --- /dev/null +++ b/test cases/failing/121 structured source empty string/meson.build @@ -0,0 +1,13 @@ +project('structured_source with empty string key') + +if not add_languages(['rust'], required : false, native : false) + error('MESON_SKIP_TEST: Rust is required but not found.') +endif + +executable( + 'main', + structured_sources( + 'main.rs', + {'' : 'main.rs'}, + ) +) diff --git a/test cases/failing/121 structured source empty string/test.json b/test cases/failing/121 structured source empty string/test.json new file mode 100644 index 000000000..feb2af9e7 --- /dev/null +++ b/test cases/failing/121 structured source empty string/test.json @@ -0,0 +1,7 @@ +{ + "stdout": [ + { + "line": "test cases/failing/121 structured source empty string/meson.build:7:0: ERROR: structured_sources: keys to dictionary argument may not be an empty string." + } + ] +} diff --git a/test cases/failing/122 structured_sources conflicts/main.rs b/test cases/failing/122 structured_sources conflicts/main.rs new file mode 100644 index 000000000..e69de29bb diff --git a/test cases/failing/122 structured_sources conflicts/meson.build b/test cases/failing/122 structured_sources conflicts/meson.build new file mode 100644 index 000000000..561ad86bc --- /dev/null +++ b/test cases/failing/122 structured_sources conflicts/meson.build @@ -0,0 +1,17 @@ +project('structured_source with empty string key') + +if not add_languages(['rust'], required : false, native : false) + error('MESON_SKIP_TEST: Rust is required but not found.') +endif + +executable( + 'main', + [ + structured_sources( + 'main.rs', + ), + structured_sources( + 'main.rs', + ), + ], +) diff --git a/test cases/failing/122 structured_sources conflicts/test.json b/test cases/failing/122 structured_sources conflicts/test.json new file mode 100644 index 000000000..4833f86b1 --- /dev/null +++ b/test cases/failing/122 structured_sources conflicts/test.json @@ -0,0 +1,7 @@ +{ + "stdout": [ + { + "line": "test cases/failing/122 structured_sources conflicts/meson.build:7:0: ERROR: Conflicting sources in structured sources: main.rs" + } + ] +} diff --git a/test cases/rust/18 structured sources/gen.py b/test cases/rust/18 structured sources/gen.py new file mode 100755 index 000000000..16e5c04e1 --- /dev/null +++ b/test cases/rust/18 structured sources/gen.py @@ -0,0 +1,20 @@ +#!/usr/bin/env python3 + +import argparse +import textwrap + + +def main() -> None: + parser = argparse.ArgumentParser() + parser.add_argument('output') + args = parser.parse_args() + + with open(args.output, 'w') as f: + f.write(textwrap.dedent('''\ + pub fn bar() -> () { + println!("Hello, World!"); + }''')) + + +if __name__ == "__main__": + main() diff --git a/test cases/rust/18 structured sources/meson.build b/test cases/rust/18 structured sources/meson.build new file mode 100644 index 000000000..8fa044364 --- /dev/null +++ b/test cases/rust/18 structured sources/meson.build @@ -0,0 +1,39 @@ +project('structured input', 'rust') + +foo_mod_rs = configure_file( + input : 'src/foo.rs.in', + output : 'mod.rs', + configuration : {'message' : 'Hello, World!'}, +) + +conf_file = executable( + 'main_conf_file', + structured_sources( + 'src/main.rs', + {'foo' : [foo_mod_rs]}, + ), +) + +ct = custom_target( + 'foo.rs', + output : 'foo.rs', + command : ['gen.py', '@OUTPUT@'], +) + +target = executable( + 'main_custom_target', + structured_sources( + ['src/main.rs', ct], + ), +) + +# Should not be coppied +executable( + 'no_copy_target', + structured_sources( + ['src2/main-unique.rs'], + {'foo': 'src2/foo/mod.rs'}, + ), +) + +test('no-copy', find_program('no_copy_test.py'), args : meson.current_build_dir()) diff --git a/test cases/rust/18 structured sources/no_copy_test.py b/test cases/rust/18 structured sources/no_copy_test.py new file mode 100755 index 000000000..91506b20f --- /dev/null +++ b/test cases/rust/18 structured sources/no_copy_test.py @@ -0,0 +1,18 @@ +#!/usr/bin/env python3 + +import argparse +import os + + +def main() -> None: + parser = argparse.ArgumentParser() + parser.add_argument('builddir') + args = parser.parse_args() + + for _, _, files in os.walk(args.builddir): + if 'main-unique.rs' in files: + exit(1) + + +if __name__ == "__main__": + main() diff --git a/test cases/rust/18 structured sources/src/foo.rs.in b/test cases/rust/18 structured sources/src/foo.rs.in new file mode 100644 index 000000000..4f3fc4263 --- /dev/null +++ b/test cases/rust/18 structured sources/src/foo.rs.in @@ -0,0 +1,4 @@ + +pub fn bar() -> () { + println!("@message@"); +} diff --git a/test cases/rust/18 structured sources/src/main.rs b/test cases/rust/18 structured sources/src/main.rs new file mode 100644 index 000000000..3ffeee2be --- /dev/null +++ b/test cases/rust/18 structured sources/src/main.rs @@ -0,0 +1,5 @@ +mod foo; + +fn main() { + foo::bar(); +} diff --git a/test cases/rust/18 structured sources/src2/foo/mod.rs b/test cases/rust/18 structured sources/src2/foo/mod.rs new file mode 100644 index 000000000..9463d95b8 --- /dev/null +++ b/test cases/rust/18 structured sources/src2/foo/mod.rs @@ -0,0 +1,4 @@ + +pub fn bar() -> () { + println!("Hello, World!"); +} diff --git a/test cases/rust/18 structured sources/src2/main-unique.rs b/test cases/rust/18 structured sources/src2/main-unique.rs new file mode 100644 index 000000000..3ffeee2be --- /dev/null +++ b/test cases/rust/18 structured sources/src2/main-unique.rs @@ -0,0 +1,5 @@ +mod foo; + +fn main() { + foo::bar(); +}