diff --git a/.github/workflows/build_test.yml b/.github/workflows/build_test.yml index 1a09c94..177348d 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 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 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 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/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", diff --git a/eng/dump.bat b/eng/dump.bat index 7d0ab5c..bbaf537 100644 --- a/eng/dump.bat +++ b/eng/dump.bat @@ -11,12 +11,12 @@ 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 + xcopy /Q /Y "%%~H" ".\dumps\DriverStore\%%~nxG" >nul , 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, @@ -224,3 +226,22 @@ 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()); + regex_cache::cached_match(Some(""), d.inf_provider.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()); + }); +}