Skip to content

Commit e697813

Browse files
diytechyclaude
andcommitted
Fix parser-blocking bugs in FileBackup.ps1 and add modular test harness
FileBackup.ps1: replace 10 Unicode smart quotes with ASCII (script can now parse), and drop the K timezone specifier from FileLabelDateFormat so change folders no longer get illegal ':' characters in their names. New tests/ layout supports three volume backends (Subst for CI, VHDX for Hyper-V hosts, RealUSB for physical sticks set up via Setup-USB.bat). Run-All sweeps four mode/compression combos through eight suite groups (G1-G8). One- click entry via RunAllTests.bat; GitHub Actions workflow runs the Subst backend on every push and PR. README documents the project and test plan. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent a7a5c11 commit e697813

21 files changed

Lines changed: 1549 additions & 11 deletions

.github/workflows/tests.yml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: tests
2+
3+
on:
4+
push:
5+
branches: [main, working, Claude]
6+
pull_request:
7+
workflow_dispatch:
8+
9+
jobs:
10+
subst-backend:
11+
name: Tests (Subst backend, windows-latest)
12+
runs-on: windows-latest
13+
timeout-minutes: 30
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- name: Cache K4os.Hash.xxHash
18+
uses: actions/cache@v4
19+
with:
20+
path: ~\AppData\Local\PackageManagement\NuGet\Packages\K4os.Hash.xxHash.1.0.8
21+
key: k4os-xxhash-1.0.8-${{ runner.os }}
22+
23+
- name: Install deps (non-interactive)
24+
shell: pwsh
25+
run: |
26+
.\tests\Setup.ps1 -InstallDeps -NonInteractive
27+
28+
- name: Verify 7-Zip
29+
shell: pwsh
30+
run: |
31+
if (-not (Test-Path 'C:\Program Files\7-Zip\7z.exe')) {
32+
throw "7-Zip missing on runner"
33+
}
34+
35+
- name: Run tests (Subst backend)
36+
shell: pwsh
37+
run: |
38+
.\tests\Run-All.ps1 `
39+
-Backend Subst `
40+
-ResultRoot $env:RUNNER_TEMP\fbtest `
41+
-EmitJUnit `
42+
-NonInteractive
43+
44+
- name: Upload raw results
45+
if: always()
46+
uses: actions/upload-artifact@v4
47+
with:
48+
name: test-results-subst
49+
path: ${{ runner.temp }}\fbtest\**
50+
51+
- name: Publish JUnit
52+
if: always()
53+
uses: dorny/test-reporter@v1
54+
with:
55+
name: FileBackup (Subst)
56+
path: ${{ runner.temp }}\fbtest\**\results.xml
57+
reporter: java-junit
58+
fail-on-error: false
59+
60+
vhdx-backend:
61+
name: Tests (VHDX backend, self-hosted)
62+
runs-on: [self-hosted, windows, hyper-v]
63+
if: ${{ vars.HAS_SELF_HOSTED_HYPERV == 'true' }}
64+
timeout-minutes: 60
65+
steps:
66+
- uses: actions/checkout@v4
67+
- shell: pwsh
68+
run: |
69+
.\tests\Setup.ps1 -InstallDeps -NonInteractive
70+
.\tests\Run-All.ps1 -Backend VHDX `
71+
-ResultRoot $env:RUNNER_TEMP\fbtest -EmitJUnit -NonInteractive
72+
- if: always()
73+
uses: actions/upload-artifact@v4
74+
with:
75+
name: test-results-vhdx
76+
path: ${{ runner.temp }}\fbtest\**

FileBackup.ps1

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ $ReconstructBatName = 'RECONSTRUCT.bat'
6464
$ReconstructLogName = 'RECONSTRUCT.log'
6565

6666
$CSVDateFormat = 'O' # ISO 8601 round-trip
67-
$FileLabelDateFormat = "yyyy_MM_dd_HH_mm_ssK" # label in folder and manifest names
67+
$FileLabelDateFormat = 'yyyy_MM_dd_HH_mm_ss' # label in folder and manifest names (no zone — Windows paths can't contain ':')
6868
$ChangeFolderDateMask = 'yyyy_MM_dd_HH_mm_ss' # pattern we look for in change folder names
6969

7070
# Alphabet for short name encoding (base-N over this alphabet)
@@ -1281,28 +1281,28 @@ function Run-BackupSet {
12811281
}
12821282

12831283
# 2. Create logger
1284-
$logPath = Join-Path $paths.ChgPath backup.log
1284+
$logPath = Join-Path $paths.ChgPath 'backup.log'
12851285
$log = New-Logger -LogFile $logPath
12861286
$LogPaths.Add($logPath)
12871287

1288-
& $log "----- Backup set $($Set.Name) starting -----"
1288+
& $log "----- Backup set '$($Set.Name)' starting -----"
12891289

12901290
# 3. Guard staging folder
12911291
try {
12921292
$stagingFolder = Initialize-StagingFolder -ChgPath $paths.ChgPath -Log $log
12931293
} catch {
1294-
& $log "Failed to initialize staging folder: $($_.Exception.Message)" ERROR
1294+
& $log "Failed to initialize staging folder: $($_.Exception.Message)" 'ERROR'
12951295
$OverallSuccess.Value = $false
12961296
return
12971297
}
12981298

12991299
# 4. Update source manifest
1300-
& $log "Updating source manifest at $($paths.SrcPath)."
1301-
$sourceDb = UpdateSourceDatabase -SourcePath $paths.SrcPath -FfprobePath $Deps[ffprobe]
1300+
& $log "Updating source manifest at '$($paths.SrcPath)'."
1301+
$sourceDb = UpdateSourceDatabase -SourcePath $paths.SrcPath -FfprobePath $Deps['ffprobe']
13021302

13031303
# 5. Sanitize backup manifest
1304-
& $log "Sanitizing backup manifest at $($paths.BkpPath)."
1305-
$backupDb = SanitizeBackupDatabase -BackupRoot $paths.BkpPath -PreserveFolderTree ([bool]$Set.PreserveFolderTree) -CompressEnabled ([bool]$Set.CompressEnabled) -SevenZipPath $Deps[7z] -Log $log
1304+
& $log "Sanitizing backup manifest at '$($paths.BkpPath)'."
1305+
$backupDb = SanitizeBackupDatabase -BackupRoot $paths.BkpPath -PreserveFolderTree ([bool]$Set.PreserveFolderTree) -CompressEnabled ([bool]$Set.CompressEnabled) -SevenZipPath $Deps['7z'] -Log $log
13061306

13071307
# 6. Hash recalc decision
13081308
$lastHashRun = $null
@@ -1313,7 +1313,7 @@ function Run-BackupSet {
13131313
& $log "HashRecalcFreq=$($Set.HashRecalcFreq), LastHashRun=$lastHashRun, Recalculate=$recalc"
13141314

13151315
# 7. Write pre-backup manifest to staging
1316-
& $log "Saving pre-backup manifest to staging $stagingFolder."
1316+
& $log "Saving pre-backup manifest to staging '$stagingFolder'."
13171317
Write-Manifest -FolderPath $stagingFolder -Records $backupDb
13181318

13191319
# 8. Diff
@@ -1335,7 +1335,7 @@ function Run-BackupSet {
13351335
-BkpPath $paths.BkpPath `
13361336
-PreserveFolderTree ([bool]$Set.PreserveFolderTree) `
13371337
-CompressEnabled ([bool]$Set.CompressEnabled) `
1338-
-SevenZipPath $Deps[7z] `
1338+
-SevenZipPath $Deps['7z'] `
13391339
-BackupDb $backupDb `
13401340
-BackupMap ([ref]$backupMap) `
13411341
-ChangedCount ([ref]$changedCount) `
@@ -1369,7 +1369,7 @@ function Run-BackupSet {
13691369
SanitizeChangeDatabase -ChangeRoot $paths.ChgPath -BackupRoot $paths.BkpPath -Log $log
13701370

13711371
& $log "Changed files count = $changedCount"
1372-
& $log "----- Backup set $($Set.Name) completed -----"
1372+
& $log "----- Backup set '$($Set.Name)' completed -----"
13731373
}
13741374

13751375
# endregion

0 commit comments

Comments
 (0)