mirror of
https://github.com/slint-ui/slint.git
synced 2025-10-01 06:11:16 +00:00
Use the testing backend for the C++ integration tests
This commit is contained in:
parent
a0e910abf0
commit
988c2b0b9d
6 changed files with 18 additions and 2 deletions
2
.github/workflows/ci.yaml
vendored
2
.github/workflows/ci.yaml
vendored
|
@ -209,7 +209,7 @@ jobs:
|
||||||
uses: actions-rs/cargo@v1
|
uses: actions-rs/cargo@v1
|
||||||
with:
|
with:
|
||||||
command: build
|
command: build
|
||||||
args: --lib -p sixtyfps-cpp
|
args: --lib -p sixtyfps-cpp --features testing
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
uses: actions-rs/cargo@v1
|
uses: actions-rs/cargo@v1
|
||||||
with:
|
with:
|
||||||
|
|
|
@ -17,8 +17,12 @@ crate-type = ["lib", "cdylib"]
|
||||||
# In the future, this shouldn't be a default feature, but should be enabled by cmake
|
# In the future, this shouldn't be a default feature, but should be enabled by cmake
|
||||||
default = ["sixtyfps-interpreter"]
|
default = ["sixtyfps-interpreter"]
|
||||||
|
|
||||||
|
# Enable some function used by the integration tests
|
||||||
|
testing = ["sixtyfps-rendering-backend-testing"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
sixtyfps-corelib = { version = "=0.0.6", path="../../sixtyfps_runtime/corelib", features = ["ffi"] }
|
sixtyfps-corelib = { version = "=0.0.6", path="../../sixtyfps_runtime/corelib", features = ["ffi"] }
|
||||||
sixtyfps-rendering-backend-default = { version = "=0.0.6", path="../../sixtyfps_runtime/rendering_backends/default" }
|
sixtyfps-rendering-backend-default = { version = "=0.0.6", path="../../sixtyfps_runtime/rendering_backends/default" }
|
||||||
|
sixtyfps-rendering-backend-testing = { version = "=0.0.6", path="../../sixtyfps_runtime/rendering_backends/testing", optional = true }
|
||||||
sixtyfps-interpreter = { version = "=0.0.6", path="../../sixtyfps_runtime/interpreter", features = ["ffi"], optional = true }
|
sixtyfps-interpreter = { version = "=0.0.6", path="../../sixtyfps_runtime/interpreter", features = ["ffi"], optional = true }
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,11 @@ LICENSE END */
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
namespace sixtyfps::testing {
|
namespace sixtyfps::testing {
|
||||||
|
|
||||||
|
inline void init() {
|
||||||
|
cbindgen_private::sixtyfps_testing_init_backend();
|
||||||
|
}
|
||||||
|
|
||||||
inline void mock_elapsed_time(int64_t time_in_ms)
|
inline void mock_elapsed_time(int64_t time_in_ms)
|
||||||
{
|
{
|
||||||
cbindgen_private::sixtyfps_mock_elapsed_time(time_in_ms);
|
cbindgen_private::sixtyfps_mock_elapsed_time(time_in_ms);
|
||||||
|
|
|
@ -56,3 +56,9 @@ pub unsafe extern "C" fn sixtyfps_register_font_from_path(
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "testing")]
|
||||||
|
#[no_mangle]
|
||||||
|
pub unsafe extern "C" fn sixtyfps_testing_init_backend() {
|
||||||
|
sixtyfps_rendering_backend_testing::init();
|
||||||
|
}
|
||||||
|
|
|
@ -12,6 +12,7 @@ name = "test-driver-cpp"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
sixtyfps-compilerlib = { path = "../../../sixtyfps_compiler", features = ["cpp", "display-diagnostics"] }
|
sixtyfps-compilerlib = { path = "../../../sixtyfps_compiler", features = ["cpp", "display-diagnostics"] }
|
||||||
|
sixtyfps-cpp = { path = "../../../api/sixtyfps-cpp", features = ["testing"] }
|
||||||
cc = "1.0.54"
|
cc = "1.0.54"
|
||||||
tempfile = "3"
|
tempfile = "3"
|
||||||
scopeguard = "1.1.0"
|
scopeguard = "1.1.0"
|
||||||
|
|
|
@ -48,7 +48,7 @@ pub fn test(testcase: &test_driver_lib::TestCase) -> Result<(), Box<dyn Error>>
|
||||||
generated_cpp.write_all(
|
generated_cpp.write_all(
|
||||||
b"#ifdef NDEBUG\n#undef NDEBUG\n#endif\n#include <assert.h>\n#include <cmath>\n#include <iostream>\n#include <sixtyfps_testing.h>\n",
|
b"#ifdef NDEBUG\n#undef NDEBUG\n#endif\n#include <assert.h>\n#include <cmath>\n#include <iostream>\n#include <sixtyfps_testing.h>\n",
|
||||||
)?;
|
)?;
|
||||||
generated_cpp.write_all(b"int main() {\n")?;
|
generated_cpp.write_all(b"int main() {\n sixtyfps::testing::init();\n")?;
|
||||||
for x in test_driver_lib::extract_test_functions(&source).filter(|x| x.language_id == "cpp") {
|
for x in test_driver_lib::extract_test_functions(&source).filter(|x| x.language_id == "cpp") {
|
||||||
write!(generated_cpp, " {{\n {}\n }}\n", x.source.replace("\n", "\n "))?;
|
write!(generated_cpp, " {{\n {}\n }}\n", x.source.replace("\n", "\n "))?;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue