diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2023-06-21 12:02:06 -0700 |
---|---|---|
committer | Dylan Baker <dylan@pnwbakers.com> | 2023-06-27 11:53:18 -0700 |
commit | 43f24060f3e0065b44b1909d88bcc8e2882e9e5e (patch) | |
tree | 0350478696a6bd7270279d184518ce1daf27943c /test cases/rust | |
parent | 78b8d447eea08445c9708bc0e3ba3c886717f6cd (diff) | |
download | meson-43f24060f3e0065b44b1909d88bcc8e2882e9e5e.zip meson-43f24060f3e0065b44b1909d88bcc8e2882e9e5e.tar.gz meson-43f24060f3e0065b44b1909d88bcc8e2882e9e5e.tar.bz2 |
modules/rust: Add a `link_with` kwarg to the test method
This was requested by Mesa, where a bunch of `declare_dependency`
objects are being created as a workaround for the lack of this keyword
Diffstat (limited to 'test cases/rust')
-rw-r--r-- | test cases/rust/9 unit tests/helper.rs | 3 | ||||
-rw-r--r-- | test cases/rust/9 unit tests/meson.build | 4 | ||||
-rw-r--r-- | test cases/rust/9 unit tests/test3.rs | 16 |
3 files changed, 23 insertions, 0 deletions
diff --git a/test cases/rust/9 unit tests/helper.rs b/test cases/rust/9 unit tests/helper.rs new file mode 100644 index 0000000..afe3233 --- /dev/null +++ b/test cases/rust/9 unit tests/helper.rs @@ -0,0 +1,3 @@ +pub fn subtract(a: i32, b: i32) -> i32 { + a - b +} diff --git a/test cases/rust/9 unit tests/meson.build b/test cases/rust/9 unit tests/meson.build index b649abb..9096014 100644 --- a/test cases/rust/9 unit tests/meson.build +++ b/test cases/rust/9 unit tests/meson.build @@ -41,3 +41,7 @@ rust.test('rust_test_from_static', lib, args: ['--skip', 'test_add_intentional_f lib = shared_library('rust_shared', ['test.rs']) rust.test('rust_test_from_shared', lib, args: ['--skip', 'test_add_intentional_fail']) + +helper = static_library('helper', 'helper.rs') +lib = static_library('rust_link_with', 'test3.rs') +rust.test('rust_test_link_with', lib, link_with : helper) diff --git a/test cases/rust/9 unit tests/test3.rs b/test cases/rust/9 unit tests/test3.rs new file mode 100644 index 0000000..ccb5f98 --- /dev/null +++ b/test cases/rust/9 unit tests/test3.rs @@ -0,0 +1,16 @@ +pub fn add(a: i32, b: i32) -> i32 { + a + b +} + +#[cfg(test)] +mod tests { + extern crate helper; + + use super::*; + + #[test] + fn test_add_sub() { + let x = helper::subtract(6, 5); + assert_eq!(add(x, 5), 6); + } +} |