Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions .github/workflows/build_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
build/
dist/

# Generated by Cargo
# will have compiled files and executables
Expand Down
11 changes: 8 additions & 3 deletions build.ps1
Original file line number Diff line number Diff line change
@@ -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
Expand Down
5 changes: 5 additions & 0 deletions config/device_identifiers.json
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
}
]
6 changes: 3 additions & 3 deletions config/driver_identifiers.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
6 changes: 3 additions & 3 deletions eng/dump.bat
Original file line number Diff line number Diff line change
Expand Up @@ -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
<nul set /p "=Dumped '%%~nxH' !CR!"
)
)
Expand Down
21 changes: 21 additions & 0 deletions src/cleanup_modules/device_cleanup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,12 +188,14 @@ pub struct DeviceToUninstall {
manufacturer: Option<String>,
hardware_id: Option<String>,
class_uuid: Option<Uuid>,
inf_provider: Option<String>,
}

impl ToUninstall<Device> 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,
Expand Down Expand Up @@ -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());
});
}
17 changes: 17 additions & 0 deletions src/cleanup_modules/driver_cleanup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
});
}
18 changes: 18 additions & 0 deletions src/cleanup_modules/driver_package_cleanup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
});
}