diff --git a/.github/workflows/clippy.yml b/.github/workflows/clippy.yml index 3634903beb..5a0cccd159 100644 --- a/.github/workflows/clippy.yml +++ b/.github/workflows/clippy.yml @@ -86,7 +86,7 @@ jobs: cargo clippy -p test_core && cargo clippy -p test_debug && cargo clippy -p test_debug_inspectable && - cargo clippy -p test_debugger_visualizer_x && + cargo clippy -p test_debugger_visualizer && cargo clippy -p test_deprecated && cargo clippy -p test_dispatch && cargo clippy -p test_does_not_return && diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1374c1b7b8..ce1da057fc 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -93,14 +93,15 @@ jobs: cargo test -p test_core && cargo test -p test_debug && cargo test -p test_debug_inspectable && + cargo test -p test_debugger_visualizer && cargo test -p test_deprecated && cargo test -p test_dispatch && cargo test -p test_does_not_return && cargo test -p test_enums && cargo test -p test_error && cargo test -p test_event && - cargo test -p test_extensions && cargo clean && + cargo test -p test_extensions && cargo test -p test_handles && cargo test -p test_helpers && cargo test -p test_implement && diff --git a/crates/tests/debugger_visualizer/Cargo.toml b/crates/tests/debugger_visualizer/Cargo.toml index 3a8b7e2211..3b75cd9358 100644 --- a/crates/tests/debugger_visualizer/Cargo.toml +++ b/crates/tests/debugger_visualizer/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "test_debugger_visualizer_x" +name = "test_debugger_visualizer" version = "0.0.0" edition = "2021" publish = false diff --git a/crates/tests/targets/Cargo.toml b/crates/tests/targets/Cargo.toml index 31b18bf3ca..3595b78fe8 100644 --- a/crates/tests/targets/Cargo.toml +++ b/crates/tests/targets/Cargo.toml @@ -14,3 +14,6 @@ features = [ "Win32_Foundation", "Win32_Security_Authentication_Identity" ] [dependencies.windows-sys] path = "../../libs/sys" features = [ "Win32_Foundation", "Win32_Security_Authentication_Identity" ] + +[dependencies.tool_lib] +path = "../../tools/lib" \ No newline at end of file diff --git a/crates/tests/targets/tests/files.rs b/crates/tests/targets/tests/files.rs index d27d051195..78702c9a77 100644 --- a/crates/tests/targets/tests/files.rs +++ b/crates/tests/targets/tests/files.rs @@ -3,6 +3,10 @@ #[test] fn test() { + let targets = tool_lib::crates("../../targets"); + assert_eq!(7, targets.len()); + assert!(targets.iter().all(|(_, version)| version == "0.52.0")); + std::include_bytes!("../../../targets/aarch64_gnullvm/lib/libwindows.0.52.0.a"); std::include_bytes!("../../../targets/aarch64_msvc/lib/windows.0.52.0.lib"); std::include_bytes!("../../../targets/i686_gnu/lib/libwindows.0.52.0.a"); diff --git a/crates/tools/lib/Cargo.toml b/crates/tools/lib/Cargo.toml index 57b926efdf..1549cce132 100644 --- a/crates/tools/lib/Cargo.toml +++ b/crates/tools/lib/Cargo.toml @@ -5,4 +5,5 @@ edition = "2021" publish = false [dependencies] +regex = "1.7" metadata = { package = "windows-metadata", path = "../../libs/metadata" } diff --git a/crates/tools/lib/src/lib.rs b/crates/tools/lib/src/lib.rs index 8a4de76d75..6ee852748f 100644 --- a/crates/tools/lib/src/lib.rs +++ b/crates/tools/lib/src/lib.rs @@ -1,4 +1,6 @@ use std::collections::BTreeMap; +use regex::Regex; +use std::path::Path; pub enum CallingConvention { Stdcall(usize), @@ -82,3 +84,38 @@ fn combine_libraries( } } } + +pub fn crates>(path: P) -> Vec<(String, String)> { + let regex = Regex::new(r#"name = "([^"]+)"\sversion = "([^"]+)""#).expect("regex"); + let mut names = find(path, ®ex); + names.sort(); + names +} + +fn find>(path: P, regex: &Regex) -> Vec<(String, String)> { + let mut names = vec![]; + + if let Ok(files) = std::fs::read_dir(path) { + for file in files.filter_map(|file| file.ok()) { + if let Ok(file_type) = file.file_type() { + if file_type.is_dir() { + names.append(&mut find(file.path(), regex)); + } else if file.file_name() == "Cargo.toml" { + let text = std::fs::read_to_string(file.path()).expect("Cargo.toml"); + let captures = regex + .captures(&text) + .expect("captures"); + let name = captures + .get(1) + .expect("name"); + let version = captures + .get(2) + .expect("version"); + names.push((name.as_str().to_string(), version.as_str().to_string())); + } + } + } + } + + names +} diff --git a/crates/tools/yml/Cargo.toml b/crates/tools/yml/Cargo.toml index cc8047b5ae..9acfd94035 100644 --- a/crates/tools/yml/Cargo.toml +++ b/crates/tools/yml/Cargo.toml @@ -5,4 +5,4 @@ edition = "2021" publish = false [dependencies] -regex = "1.7" +lib = { package = "tool_lib", path = "../lib" } diff --git a/crates/tools/yml/src/main.rs b/crates/tools/yml/src/main.rs index f421fe0d58..f5ff72bbfb 100644 --- a/crates/tools/yml/src/main.rs +++ b/crates/tools/yml/src/main.rs @@ -1,6 +1,4 @@ -use regex::Regex; use std::fmt::Write; -use std::path::Path; fn main() { test_yml(); @@ -53,16 +51,16 @@ jobs: run: >" .to_string(); - let crates = crates(true); + let crates = lib::crates("crates"); let (first, last) = crates.split_at(crates.len() / 2); - for name in first { + for (name, _) in first { write!(&mut yml, "\n cargo test -p {name} &&").unwrap(); } write!(&mut yml, "\n cargo clean &&").unwrap(); - for name in last { + for (name, _) in last { write!(&mut yml, "\n cargo test -p {name} &&").unwrap(); } @@ -109,43 +107,10 @@ jobs: run: |"# .to_string(); - for name in crates(false) { + for (name, _) in lib::crates("crates") { write!(&mut yml, "\n cargo clippy -p {name} &&").unwrap(); } yml.truncate(yml.len() - 3); std::fs::write(".github/workflows/clippy.yml", yml.as_bytes()).unwrap(); } - -fn crates(filter: bool) -> Vec { - let regex = Regex::new(r#"name = "([^"]+)""#).expect("regex"); - let mut names = find("crates", ®ex, filter); - names.sort(); - names -} - -fn find>(path: P, regex: &Regex, filter: bool) -> Vec { - let mut names = vec![]; - - if let Ok(files) = std::fs::read_dir(path) { - for file in files.filter_map(|file| file.ok()) { - if let Ok(file_type) = file.file_type() { - if file_type.is_dir() { - names.append(&mut find(file.path(), regex, filter)); - } else if file.file_name() == "Cargo.toml" { - let text = std::fs::read_to_string(file.path()).expect("Cargo.toml"); - let name = regex - .captures(&text) - .expect("captures") - .get(1) - .expect("name"); - if !filter || !name.as_str().ends_with("_x") { - names.push(name.as_str().to_string()); - } - } - } - } - } - - names -}