1// Copyright © SixtyFPS GmbH <info@slint.dev>
2// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0
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() {
13 let test_function_name = testcase.identifier();
14 let ignored = testcase.is_ignored("interpreter");
15
16 write!(
17 tests_file,
18 r##"
19 #[test]
20 {ignore}
21 fn test_interpreter_{function_name}() {{
22 interpreter::test(&test_driver_lib::TestCase{{
23 absolute_path: std::path::PathBuf::from(r#"{absolute_path}"#),
24 relative_path: std::path::PathBuf::from(r#"{relative_path}"#),
25 requested_style: {requested_style},
26 }}).unwrap();
27 }}
28 "##,
29 ignore = if ignored { "#[ignore]" } else { "" },
30 function_name = test_function_name,
31 absolute_path = testcase.absolute_path.to_string_lossy(),
32 relative_path = testcase.relative_path.to_string_lossy(),
33 requested_style =
34 testcase.requested_style.map_or("None".into(), |style| format!("Some({style:?})")),
35 )?;
36 }
37
38 println!("cargo:rustc-env=TEST_FUNCTIONS={}", tests_file_path.to_string_lossy());
39 println!("cargo:rustc-env=SLINT_ENABLE_EXPERIMENTAL_FEATURES=1");
40
41 Ok(())
42}
43