Skip to content

Commit 0bd6659

Browse files
committed
Rust: test all combinaisons of crate and target types
1 parent ebbb580 commit 0bd6659

File tree

2 files changed

+68
-9
lines changed

2 files changed

+68
-9
lines changed

test cases/rust/4 polyglot/meson.build

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,40 @@ if host_machine.system() == 'darwin'
44
error('MESON_SKIP_TEST: does not work right on macos, please fix!')
55
endif
66

7-
l = shared_library('stuff', 'stuff.rs', rust_crate_type: 'cdylib', install : true)
8-
e = executable('prog', 'prog.c', link_with : l, install : true)
9-
test('polyglottest', e)
7+
# Test all combinaisons of crate and target types
8+
foreach crate_type : ['cdylib', 'staticlib', 'clib']
9+
foreach target_type : ['static_library', 'shared_library', 'both_libraries']
10+
name = f'stuff-@crate_type@-@target_type@'
11+
name_map = {name: 'stuff'}
12+
error = ''
13+
if crate_type == 'cdylib' and target_type in ['static_library', 'both_libraries']
14+
error = 'Crate type "cdylib" invalid for static libraries; must be "rlib" or "staticlib"'
15+
elif crate_type == 'staticlib' and target_type in ['shared_library', 'both_libraries']
16+
error = 'Crate type "staticlib" invalid for dynamic libraries; must be "dylib", "cdylib", or "proc-macro"'
17+
endif
18+
if error != ''
19+
# FIXME: The shared library part of both_libraries gets added into the list of
20+
# targets before raising error when doing the static library part. In real life
21+
# it means the setup would abort, but because of expect_error() in this test case,
22+
# the shared lib is still going to be built.
23+
testcase expect_error(error)
24+
build_target(name, 'stuff.rs',
25+
target_type: target_type,
26+
rust_crate_type: crate_type,
27+
rust_dependency_map: name_map,
28+
install: true)
29+
endtestcase
30+
continue
31+
endif
32+
l = build_target(name, 'stuff.rs',
33+
target_type: target_type,
34+
rust_crate_type: crate_type,
35+
rust_dependency_map: name_map,
36+
install: true)
37+
e = executable(f'prog-@name@', 'prog.c',
38+
link_with: l,
39+
rust_dependency_map: name_map,
40+
install: true)
41+
test(f'polyglottest-@name@', e)
42+
endforeach
43+
endforeach

test cases/rust/4 polyglot/test.json

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,35 @@
11
{
22
"installed": [
3-
{"type": "exe", "file": "usr/bin/prog"},
4-
{"type": "pdb", "file": "usr/bin/prog"},
5-
{"type": "file", "platform": "gcc", "file": "usr/lib/libstuff.so"},
6-
{"type": "file", "platform": "msvc", "file": "usr/bin/stuff.dll"},
7-
{"type": "file", "platform": "msvc", "file": "usr/lib/stuff.dll.lib"},
8-
{"type": "pdb", "file": "usr/bin/stuff"}
3+
{"type": "exe", "file": "usr/bin/prog-stuff-clib-static_library"},
4+
{"type": "exe", "file": "usr/bin/prog-stuff-clib-both_libraries"},
5+
{"type": "exe", "file": "usr/bin/prog-stuff-clib-shared_library"},
6+
{"type": "exe", "file": "usr/bin/prog-stuff-cdylib-shared_library"},
7+
{"type": "exe", "file": "usr/bin/prog-stuff-staticlib-static_library"},
8+
9+
{"type": "pdb", "file": "usr/bin/prog-stuff-clib-static_library"},
10+
{"type": "pdb", "file": "usr/bin/prog-stuff-clib-both_libraries"},
11+
{"type": "pdb", "file": "usr/bin/prog-stuff-clib-shared_library"},
12+
{"type": "pdb", "file": "usr/bin/prog-stuff-cdylib-shared_library"},
13+
{"type": "pdb", "file": "usr/bin/prog-stuff-staticlib-static_library"},
14+
15+
{"type": "file", "platform": "gcc", "file": "usr/lib/libstuff-clib-both_libraries.so"},
16+
{"type": "file", "platform": "msvc", "file": "usr/lib/libstuff-clib-both_libraries.dll"},
17+
{"type": "file", "platform": "msvc", "file": "usr/lib/libstuff-clib-both_libraries.dll.lib"},
18+
19+
{"type": "file", "platform": "gcc", "file": "usr/lib/libstuff-clib-shared_library.so"},
20+
{"type": "file", "platform": "msvc", "file": "usr/lib/libstuff-clib-shared_library.dll"},
21+
{"type": "file", "platform": "msvc", "file": "usr/lib/libstuff-clib-shared_library.dll.lib"},
22+
23+
{"type": "file", "platform": "gcc", "file": "usr/lib/libstuff-cdylib-shared_library.so"},
24+
{"type": "file", "platform": "msvc", "file": "usr/lib/libstuff-cdylib-shared_library.dll"},
25+
{"type": "file", "platform": "msvc", "file": "usr/lib/libstuff-cdylib-shared_library.dll.lib"},
26+
27+
{"type": "file", "platform": "gcc", "file": "usr/lib/libstuff-cdylib-both_libraries.so"},
28+
{"type": "file", "platform": "msvc", "file": "usr/lib/libstuff-cdylib-both_libraries.dll"},
29+
{"type": "file", "platform": "msvc", "file": "usr/lib/libstuff-cdylib-both_libraries.dll.lib"},
30+
31+
{"type": "file", "file": "usr/lib/libstuff-clib-both_libraries.a"},
32+
{"type": "file", "file": "usr/lib/libstuff-clib-static_library.a"},
33+
{"type": "file", "file": "usr/lib/libstuff-staticlib-static_library.a"}
934
]
1035
}

0 commit comments

Comments
 (0)