1// Copyright © SixtyFPS GmbH <info@slint.dev>
2// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-1.1 OR LicenseRef-Slint-commercial
3
4use std::io::Write;
5
6fn main() -> Result<(), Box<dyn std::error::Error>> {
7 let tests_file_path =
8 std::path::Path::new(&std::env::var_os("OUT_DIR").unwrap()).join("test_functions.rs");
9
10 let mut tests_file = std::fs::File::create(&tests_file_path)?;
11
12 for testcase in test_driver_lib::collect_test_cases("cases")?.into_iter().filter(|testcase| {
13 // Style testing not supported yet
14 testcase.requested_style.is_none()
15 }) {
16 let test_function_name = testcase.identifier();
17 let ignored = testcase.is_ignored("interpreter");
18
19 write!(
20 tests_file,
21 r##"
22 #[test]
23 {ignore}
24 fn test_interpreter_{function_name}() {{
25 interpreter::test(&test_driver_lib::TestCase{{
26 absolute_path: std::path::PathBuf::from(r#"{absolute_path}"#),
27 relative_path: std::path::PathBuf::from(r#"{relative_path}"#),
28 requested_style: None,
29 }}).unwrap();
30 }}
31 "##,
32 ignore = if ignored { "#[ignore]" } else { "" },
33 function_name = test_function_name,
34 absolute_path = testcase.absolute_path.to_string_lossy(),
35 relative_path = testcase.relative_path.to_string_lossy(),
36 )?;
37 }
38
39 println!("cargo:rustc-env=TEST_FUNCTIONS={}", tests_file_path.to_string_lossy());
40 println!("cargo:rustc-env=SLINT_ENABLE_EXPERIMENTAL_FEATURES=1");
41
42 Ok(())
43}
44