From a67b29cdaf0901e7a9cab43984a932defbc7189a Mon Sep 17 00:00:00 2001 From: kuuuube Date: Fri, 13 Feb 2026 16:17:29 -0500 Subject: [PATCH 1/9] Add tests for init and regex match --- src/cleanup_modules/device_cleanup.rs | 18 ++++++++++++++++++ src/cleanup_modules/driver_cleanup.rs | 17 +++++++++++++++++ src/cleanup_modules/driver_package_cleanup.rs | 18 ++++++++++++++++++ 3 files changed, 53 insertions(+) diff --git a/src/cleanup_modules/device_cleanup.rs b/src/cleanup_modules/device_cleanup.rs index cb986c0..64110bb 100644 --- a/src/cleanup_modules/device_cleanup.rs +++ b/src/cleanup_modules/device_cleanup.rs @@ -224,3 +224,21 @@ fn is_of_interest(device: &Device) -> bool { candidate_iter(strings) } + +#[tokio::test] +async fn test_init() { + let mut module = DeviceCleanupModule::new(); + let state = State { + dry_run: true, + interactive: false, + use_cache: true, + allow_updates: false, + current_path: Default::default(), + }; + module.initialize(&state).await.unwrap(); + module.get_objects_to_uninstall().iter().for_each(|d| { + regex_cache::cached_match(Some(""), d.device_desc.as_deref()); + regex_cache::cached_match(Some(""), d.manufacturer.as_deref()); + regex_cache::cached_match(Some(""), d.hardware_id.as_deref()); + }); +} diff --git a/src/cleanup_modules/driver_cleanup.rs b/src/cleanup_modules/driver_cleanup.rs index a184a38..fb0d58c 100644 --- a/src/cleanup_modules/driver_cleanup.rs +++ b/src/cleanup_modules/driver_cleanup.rs @@ -186,3 +186,20 @@ fn is_of_interest(driver: &Driver) -> bool { let strings = [driver.inf_original_name(), driver.provider()]; candidate_iter(strings.into_iter().flatten()) } + +#[tokio::test] +async fn test_init() { + let mut module = DriverCleanupModule::new(); + let state = State { + dry_run: true, + interactive: false, + use_cache: true, + allow_updates: false, + current_path: Default::default(), + }; + module.initialize(&state).await.unwrap(); + module.get_objects_to_uninstall().iter().for_each(|d| { + regex_cache::cached_match(Some(""), d.original_name.as_deref()); + regex_cache::cached_match(Some(""), d.provider.as_deref()); + }); +} diff --git a/src/cleanup_modules/driver_package_cleanup.rs b/src/cleanup_modules/driver_package_cleanup.rs index e2f5844..ebb2d62 100644 --- a/src/cleanup_modules/driver_package_cleanup.rs +++ b/src/cleanup_modules/driver_package_cleanup.rs @@ -412,3 +412,21 @@ fn to_command(command: &str) -> std::process::Command { command } + +#[tokio::test] +async fn test_init() { + let mut module = DriverPackageCleanupModule::new(); + let state = State { + dry_run: true, + interactive: false, + use_cache: true, + allow_updates: false, + current_path: Default::default(), + }; + module.initialize(&state).await.unwrap(); + module.get_objects_to_uninstall().iter().for_each(|d| { + regex_cache::cached_match(Some(""), d.display_name.as_deref()); + regex_cache::cached_match(Some(""), d.display_version.as_deref()); + regex_cache::cached_match(Some(""), d.publisher.as_deref()); + }); +} From c98b0dc0cf844c636674ebcce1ba13ae6a399096 Mon Sep 17 00:00:00 2001 From: kuuuube Date: Fri, 13 Feb 2026 17:11:42 -0500 Subject: [PATCH 2/9] Split test and build into separate jobs --- .github/workflows/build_test.yml | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build_test.yml b/.github/workflows/build_test.yml index 1a09c94..e007c44 100755 --- a/.github/workflows/build_test.yml +++ b/.github/workflows/build_test.yml @@ -23,11 +23,20 @@ jobs: run: | powershell ./build.ps1 - - name: Run tests - run: cargo test --verbose - - uses: actions/upload-artifact@v6 with: name: tabletdrivercleanup path: ./build if-no-files-found: error + + test-windows: + runs-on: windows-latest + steps: + - uses: actions/checkout@v6 + - name: Setup dependencies + run: | + rustup update stable + rustup default stable + + - name: Run tests + run: cargo test --verbose From d3c4bfc8f59d6699d76c7ac163bffea6b560909c Mon Sep 17 00:00:00 2001 From: kuuuube Date: Tue, 3 Mar 2026 16:33:42 -0500 Subject: [PATCH 3/9] Add dist to gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index cfcdc21..932fc70 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ build/ +dist/ # Generated by Cargo # will have compiled files and executables From e1f8de4fa6a0922a7f572200472246e3b8342231 Mon Sep 17 00:00:00 2001 From: kuuuube Date: Tue, 3 Mar 2026 16:34:21 -0500 Subject: [PATCH 4/9] Avoid build errors if build couldnt be deleted or dist already existed --- build.ps1 | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/build.ps1 b/build.ps1 index cae59da..d1232a9 100644 --- a/build.ps1 +++ b/build.ps1 @@ -1,9 +1,14 @@ cargo build --release if (Test-Path ./build) { - Remove-Item -Path ./build -Recurse + Remove-Item -Path ./build/* -Recurse +} else { + New-Item -Path ./build -ItemType directory > $null +} +if (Test-Path ./dist) { + Remove-Item -Path ./dist/* -Recurse +} else { + New-Item -Path ./dist -ItemType directory > $null } -New-Item -Path ./build -ItemType directory > $null -New-Item -Path ./dist -ItemType directory > $null Copy-Item -Path ./target/release/tabletdrivercleanup.exe -Destination ./build Copy-Item -Path ./eng/dump.bat -Destination ./build Copy-Item -Path ./eng/dry_run.bat -Destination ./build From 2c9b0e270d7f17664e7d48adb74fed5f18f9bd86 Mon Sep 17 00:00:00 2001 From: kuuuube Date: Tue, 3 Mar 2026 16:34:58 -0500 Subject: [PATCH 5/9] Use mkdir instead of md in dump.bat, ignore errors (folder already exists) --- eng/dump.bat | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/eng/dump.bat b/eng/dump.bat index 7d0ab5c..0326541 100644 --- a/eng/dump.bat +++ b/eng/dump.bat @@ -11,10 +11,10 @@ tabletdrivercleanup.exe --dump pnputil /enum-drivers > .\dumps\pnputil_drivers.txt pnputil /enum-devices /connected /drivers > .\dumps\pnputil_devices.txt -md .\dumps\DriverStore +mkdir ".\dumps\DriverStore" 2>nul for /D %%G in ("C:\Windows\System32\DriverStore\FileRepository\*") DO ( - md .\dumps\DriverStore\%%~nxG + mkdir ".\dumps\DriverStore\%%~nxG" 2>nul for /F %%H in ("%%~G\*.inf") DO ( xcopy /Q /Y "%%H" .\dumps\DriverStore\%%~nxG > nul Date: Tue, 3 Mar 2026 16:35:09 -0500 Subject: [PATCH 6/9] Fix bad file copying --- eng/dump.bat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/dump.bat b/eng/dump.bat index 0326541..bbaf537 100644 --- a/eng/dump.bat +++ b/eng/dump.bat @@ -16,7 +16,7 @@ mkdir ".\dumps\DriverStore" 2>nul for /D %%G in ("C:\Windows\System32\DriverStore\FileRepository\*") DO ( mkdir ".\dumps\DriverStore\%%~nxG" 2>nul for /F %%H in ("%%~G\*.inf") DO ( - xcopy /Q /Y "%%H" .\dumps\DriverStore\%%~nxG > nul + xcopy /Q /Y "%%~H" ".\dumps\DriverStore\%%~nxG" >nul Date: Tue, 3 Mar 2026 16:47:41 -0500 Subject: [PATCH 7/9] Catch more wacom libwdi and libusb drivers --- config/driver_identifiers.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/config/driver_identifiers.json b/config/driver_identifiers.json index 7e814c4..d572df9 100644 --- a/config/driver_identifiers.json +++ b/config/driver_identifiers.json @@ -33,9 +33,9 @@ "provider": "(libusbK|libusb-win32)" }, { - "friendly_name": "Intuos LibUsbK Driver", - "original_name": "intuos.*\\.inf", - "provider": "(libusbK|libusb-win32)" + "friendly_name": "Wacom LibUsb/Libwdi Driver", + "original_name": "(intuos|(c|p)t(l|h|k)-).*\\.inf", + "provider": "(libusb|libusb-win32)" }, { "friendly_name": "Hanvon Ugee Mouse Filter", From e67761dc81eafe15efd22426174b84846bd7ec7c Mon Sep 17 00:00:00 2001 From: kuuuube Date: Tue, 3 Mar 2026 16:57:01 -0500 Subject: [PATCH 8/9] Dont run tests in verbose mode --- .github/workflows/build_test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_test.yml b/.github/workflows/build_test.yml index e007c44..177348d 100755 --- a/.github/workflows/build_test.yml +++ b/.github/workflows/build_test.yml @@ -39,4 +39,4 @@ jobs: rustup default stable - name: Run tests - run: cargo test --verbose + run: cargo test From a85068e0001359951330135d9aeaa28527673b82 Mon Sep 17 00:00:00 2001 From: kuuuube Date: Tue, 3 Mar 2026 16:52:49 -0500 Subject: [PATCH 9/9] Add support for matching inf_provider and add broad match for any tablet with wibusb or libwdi on device --- config/device_identifiers.json | 5 +++++ src/cleanup_modules/device_cleanup.rs | 3 +++ 2 files changed, 8 insertions(+) diff --git a/config/device_identifiers.json b/config/device_identifiers.json index d178f96..115ddec 100644 --- a/config/device_identifiers.json +++ b/config/device_identifiers.json @@ -22,5 +22,10 @@ "manufacturer": "GSPY", "hardware_id": "VID_(5543|28BD|256C|0A12|172F|0458|08CA|0483|0B57|2FEB|0543|056A|0531|2D80)", "class_uuid": "6264e7e6-b95c-4033-908f-86e7ab9e2555" + }, + { + "friendly_name": "LibUsb/Libwdi", + "hardware_id": "VID_(5543|28BD|256C|0A12|172F|0458|08CA|0483|0B57|2FEB|0543|056A|0531|2D80)", + "inf_provider": "(libusb|libwdi)" } ] \ No newline at end of file diff --git a/src/cleanup_modules/device_cleanup.rs b/src/cleanup_modules/device_cleanup.rs index 64110bb..62d3672 100644 --- a/src/cleanup_modules/device_cleanup.rs +++ b/src/cleanup_modules/device_cleanup.rs @@ -188,12 +188,14 @@ pub struct DeviceToUninstall { manufacturer: Option, hardware_id: Option, class_uuid: Option, + inf_provider: Option, } impl ToUninstall for DeviceToUninstall { fn matches(&self, other: &Device) -> bool { regex_cache::cached_match(other.description(), self.device_desc.as_deref()) && regex_cache::cached_match(other.manufacturer(), self.manufacturer.as_deref()) + && regex_cache::cached_match(other.inf_provider(), self.inf_provider.as_deref()) && match self.class_uuid { Some(uuid) => *other.class_guid() == uuid, None => true, @@ -240,5 +242,6 @@ async fn test_init() { regex_cache::cached_match(Some(""), d.device_desc.as_deref()); regex_cache::cached_match(Some(""), d.manufacturer.as_deref()); regex_cache::cached_match(Some(""), d.hardware_id.as_deref()); + regex_cache::cached_match(Some(""), d.inf_provider.as_deref()); }); }