tests/rust: Add a test for structured inputs
This commit is contained in:
parent
0d0a4fa0fe
commit
038d072364
|
@ -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'},
|
||||
)
|
||||
)
|
|
@ -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."
|
||||
}
|
||||
]
|
||||
}
|
|
@ -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',
|
||||
),
|
||||
],
|
||||
)
|
|
@ -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"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -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()
|
|
@ -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())
|
|
@ -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()
|
|
@ -0,0 +1,4 @@
|
|||
|
||||
pub fn bar() -> () {
|
||||
println!("@message@");
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
mod foo;
|
||||
|
||||
fn main() {
|
||||
foo::bar();
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
|
||||
pub fn bar() -> () {
|
||||
println!("Hello, World!");
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
mod foo;
|
||||
|
||||
fn main() {
|
||||
foo::bar();
|
||||
}
|
Loading…
Reference in New Issue