tests/rust: Add a test for structured inputs

pull/9339/head
Dylan Baker 4 years ago
parent 0d0a4fa0fe
commit 038d072364
  1. 0
      test cases/failing/121 structured source empty string/main.rs
  2. 13
      test cases/failing/121 structured source empty string/meson.build
  3. 7
      test cases/failing/121 structured source empty string/test.json
  4. 0
      test cases/failing/122 structured_sources conflicts/main.rs
  5. 17
      test cases/failing/122 structured_sources conflicts/meson.build
  6. 7
      test cases/failing/122 structured_sources conflicts/test.json
  7. 20
      test cases/rust/18 structured sources/gen.py
  8. 39
      test cases/rust/18 structured sources/meson.build
  9. 18
      test cases/rust/18 structured sources/no_copy_test.py
  10. 4
      test cases/rust/18 structured sources/src/foo.rs.in
  11. 5
      test cases/rust/18 structured sources/src/main.rs
  12. 4
      test cases/rust/18 structured sources/src2/foo/mod.rs
  13. 5
      test cases/rust/18 structured sources/src2/main-unique.rs

@ -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…
Cancel
Save