-
Notifications
You must be signed in to change notification settings - Fork 240
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding support for external fixture/example tests
Added code to allow external bindings crates to find the UDL files and cdylibs for examples/fixtures. Made a new crate for this, since I didn't want to pull in `serde` as a dependency for `uniffi`. Eventually, this can replace `uniffi/testing.rs` and we can remove some other dependencies from `uniffi` like `cargo_metadata`. Standardized the crate names for fixtures/examples. I think we're going to need to publish these to crates.io eventually. Make all fixtures/examples specify `crate-type = ["lib", "cdylib"]`. The `lib` part is needed for moz-central to be able to import these crates and build them into `libxul`. Added `Cargo.toml` config section that lists external clates for `ext-types` We copy the dylibs for external crates as well as our own. I think this should fix #1183.
- Loading branch information
Showing
25 changed files
with
322 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
fixtures/regressions/cdylib-crate-type-dependency/cdylib-dependency/Cargo.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
[package] | ||
name = "cdylib-dependency" | ||
name = "uniffi-fixture-regression-cdylib-dependency" | ||
version = "0.17.0" | ||
authors = ["king6cong <king6cong@gmail.com>"] | ||
edition = "2018" | ||
publish = false | ||
|
||
[lib] | ||
crate-type = ["cdylib"] | ||
crate-type = ["lib", "cdylib"] |
6 changes: 3 additions & 3 deletions
6
fixtures/regressions/cdylib-crate-type-dependency/ffi-crate/Cargo.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,19 @@ | ||
[package] | ||
name = "ffi-crate" | ||
name = "uniffi-fixture-regression-cdylib-dependency-ffi-crate" | ||
edition = "2018" | ||
version = "0.17.0" | ||
authors = ["Firefox Sync Team <sync-team@mozilla.com>"] | ||
license = "MPL-2.0" | ||
publish = false | ||
|
||
[lib] | ||
crate-type = ["cdylib"] | ||
crate-type = ["lib", "cdylib"] | ||
name = "uniffi_empty" | ||
|
||
[dependencies] | ||
uniffi_macros = {path = "../../../../uniffi_macros"} | ||
uniffi = {path = "../../../../uniffi", features=["builtin-bindgen"]} | ||
cdylib-dependency = {path = "../cdylib-dependency"} | ||
uniffi-fixture-regression-cdylib-dependency = {path = "../cdylib-dependency"} | ||
|
||
[build-dependencies] | ||
uniffi_build = {path = "../../../../uniffi_build", features=["builtin-bindgen"]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
fixtures/regressions/kotlin-experimental-unsigned-types/Cargo.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[package] | ||
name = "uniffi_testing" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] | ||
anyhow = "1" | ||
cargo_metadata = "0.13" | ||
lazy_static = "1.4" | ||
serde = "1" | ||
serde_json = "1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
This crate contains helper code for testing bindings. Our general system is to | ||
generate bindings for the libraries from the examples and fixtures | ||
directories, then execute a script that tests the bindings. | ||
|
||
Each bindings crate can do this in a different way, but the typical system is: | ||
|
||
- Construct a `UniFFITestHelper` struct to assist the process | ||
- Call `UniFFITestHelper.create_out_dir()` to create a temp directory to | ||
store testing files | ||
- Call `UniFFITestHelper.copy_cdylibs_to_out_dir()` to copy the dylib | ||
artifacts for the example/fixture library to the `out_dir`. This is needed | ||
because the bindings code dynamically links to or loads from this library. | ||
- Call `UniFFITestHelper.get_compile_sources()` to iterate over (`udl_path`, | ||
`uniffi_config_path`) pairs and generate the bindings from them. This step | ||
is specific to the bindings language, it may mean creating a .jar file, | ||
compiling a binary, or just copying script files over. | ||
- Execute the test script and check if it succeeds. This step is also | ||
specific to the bindings language. |
Oops, something went wrong.