-
Notifications
You must be signed in to change notification settings - Fork 41
Expand file tree
/
Copy pathPester.Commands.Cmdlets.Archive.Tests.ps1
More file actions
1271 lines (1087 loc) · 59.2 KB
/
Copy pathPester.Commands.Cmdlets.Archive.Tests.ps1
File metadata and controls
1271 lines (1087 loc) · 59.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<############################################################################################
# File: Pester.Commands.Cmdlets.ArchiveTests.ps1
# Commands.Cmdlets.ArchiveTests suite contains Tests that are
# used for validating Microsoft.PowerShell.Archive module.
############################################################################################>
$script:TestSourceRoot = $PSScriptRoot
$DS = [System.IO.Path]::DirectorySeparatorChar
if ($IsWindows -eq $null) {
$IsWindows = $PSVersionTable.PSEdition -eq "Desktop"
}
Describe "Test suite for Microsoft.PowerShell.Archive module" -Tags "BVT" {
BeforeAll {
$originalProgressPref = $ProgressPreference
$ProgressPreference = "SilentlyContinue"
$originalPSModulePath = $env:PSModulePath
# make sure we use the one in this repo
$env:PSModulePath = "$($script:TestSourceRoot)\..;$($env:PSModulePath)"
New-Item $TestDrive$($DS)SourceDir -Type Directory | Out-Null
New-Item $TestDrive$($DS)SourceDir$($DS)ChildDir-1 -Type Directory | Out-Null
New-Item $TestDrive$($DS)SourceDir$($DS)ChildDir-2 -Type Directory | Out-Null
New-Item $TestDrive$($DS)SourceDir$($DS)ChildEmptyDir -Type Directory | Out-Null
$content = "Some Data"
$content | Out-File -FilePath $TestDrive$($DS)SourceDir$($DS)Sample-1.txt
$content | Out-File -FilePath $TestDrive$($DS)SourceDir$($DS)Sample-2.txt
$content | Out-File -FilePath $TestDrive$($DS)SourceDir$($DS)ChildDir-1$($DS)Sample-3.txt
$content | Out-File -FilePath $TestDrive$($DS)SourceDir$($DS)ChildDir-1$($DS)Sample-4.txt
$content | Out-File -FilePath $TestDrive$($DS)SourceDir$($DS)ChildDir-2$($DS)Sample-5.txt
$content | Out-File -FilePath $TestDrive$($DS)SourceDir$($DS)ChildDir-2$($DS)Sample-6.txt
"Some Text" > $TestDrive$($DS)Sample.unzip
"Some Text" > $TestDrive$($DS)Sample.cab
$preCreatedArchivePath = Join-Path $script:TestSourceRoot "SamplePreCreatedArchive.archive"
Copy-Item $preCreatedArchivePath $TestDrive$($DS)SamplePreCreatedArchive.zip -Force
$preCreatedArchivePath = Join-Path $script:TestSourceRoot "TrailingSpacer.archive"
Copy-Item $preCreatedArchivePath $TestDrive$($DS)TrailingSpacer.zip -Force
$preCreatedArchivePath = Join-Path $script:TestSourceRoot "EncodedWith936.archive"
Copy-Item $preCreatedArchivePath $TestDrive$($DS)EncodedWith936.zip -Force
}
AfterAll {
$global:ProgressPreference = $originalProgressPref
$env:PSModulePath = $originalPSModulePath
}
function Add-CompressionAssemblies {
Add-Type -AssemblyName System.IO.Compression
if ($psedition -eq "Core")
{
Add-Type -AssemblyName System.IO.Compression.ZipFile
}
else
{
Add-Type -AssemblyName System.IO.Compression.FileSystem
}
}
function CompressArchivePathParameterSetValidator {
param
(
[string[]] $path,
[string] $destinationPath,
[string] $compressionLevel = "Optimal"
)
try
{
Compress-Archive -Path $path -DestinationPath $destinationPath -CompressionLevel $compressionLevel
throw "ValidateNotNullOrEmpty attribute is missing on one of parameters belonging to Path parameterset."
}
catch
{
$_.FullyQualifiedErrorId | Should Be "ParameterArgumentValidationError,Compress-Archive"
}
}
function CompressArchiveLiteralPathParameterSetValidator {
param
(
[string[]] $literalPath,
[string] $destinationPath,
[string] $compressionLevel = "Optimal"
)
try
{
Compress-Archive -LiteralPath $literalPath -DestinationPath $destinationPath -CompressionLevel $compressionLevel
throw "ValidateNotNullOrEmpty attribute is missing on one of parameters belonging to LiteralPath parameterset."
}
catch
{
$_.FullyQualifiedErrorId | Should Be "ParameterArgumentValidationError,Compress-Archive"
}
}
function CompressArchiveInValidPathValidator {
param
(
[string[]] $path,
[string] $destinationPath,
[string] $invalidPath,
[string] $expectedFullyQualifiedErrorId
)
try
{
Compress-Archive -Path $path -DestinationPath $destinationPath
throw "Failed to validate that an invalid Path $invalidPath was supplied as input to Compress-Archive cmdlet."
}
catch
{
$_.FullyQualifiedErrorId | Should Be $expectedFullyQualifiedErrorId
}
}
function CompressArchiveInValidArchiveFileExtensionValidator {
param
(
[string[]] $path,
[string] $destinationPath,
[string] $invalidArchiveFileExtension
)
try
{
Compress-Archive -Path $path -DestinationPath $destinationPath
throw "Failed to validate that an invalid archive file format $invalidArchiveFileExtension was supplied as input to Compress-Archive cmdlet."
}
catch
{
$_.FullyQualifiedErrorId | Should Be "NotSupportedArchiveFileExtension,Compress-Archive"
}
}
function Validate-ArchiveEntryCount {
param
(
[string] $path,
[int] $expectedEntryCount
)
Add-CompressionAssemblies
try
{
$archiveFileStreamArgs = @($path, [System.IO.FileMode]::Open)
$archiveFileStream = New-Object -TypeName System.IO.FileStream -ArgumentList $archiveFileStreamArgs
$zipArchiveArgs = @($archiveFileStream, [System.IO.Compression.ZipArchiveMode]::Read, $false)
$zipArchive = New-Object -TypeName System.IO.Compression.ZipArchive -ArgumentList $zipArchiveArgs
$actualEntryCount = $zipArchive.Entries.Count
$actualEntryCount | Should Be $expectedEntryCount
}
finally
{
if ($null -ne $zipArchive) { $zipArchive.Dispose()}
if ($null -ne $archiveFileStream) { $archiveFileStream.Dispose() }
}
}
function ArchiveFileEntryContentValidator {
param
(
[string] $path,
[string] $entryFileName,
[string] $expectedEntryFileContent
)
Add-CompressionAssemblies
try
{
$destFile = "$TestDrive$($DS)ExpandedFile"+([System.Guid]::NewGuid().ToString())+".txt"
$archiveFileStreamArgs = @($path, [System.IO.FileMode]::Open)
$archiveFileStream = New-Object -TypeName System.IO.FileStream -ArgumentList $archiveFileStreamArgs
$zipArchiveArgs = @($archiveFileStream, [System.IO.Compression.ZipArchiveMode]::Read, $false)
$zipArchive = New-Object -TypeName System.IO.Compression.ZipArchive -ArgumentList $zipArchiveArgs
$entryToBeUpdated = $zipArchive.Entries | ? {$_.FullName -eq $entryFileName.replace([System.IO.Path]::DirectorySeparatorChar, [System.IO.Path]::AltDirectorySeparatorChar)}
if($entryToBeUpdated -ne $null)
{
$srcStream = $entryToBeUpdated.Open()
$destStream = New-Object "System.IO.FileStream" -ArgumentList( $destFile, [System.IO.FileMode]::Create )
$srcStream.CopyTo( $destStream )
$destStream.Dispose()
$srcStream.Dispose()
Get-Content $destFile | Should Be $expectedEntryFileContent
}
else
{
throw "Failed to find the file $entryFileName in the archive file $path"
}
}
finally
{
if ($zipArchive)
{
$zipArchive.Dispose()
}
if ($archiveFileStream)
{
$archiveFileStream.Dispose()
}
}
}
function ArchiveFileEntrySeparatorValidator {
param
(
[string] $path
)
Add-CompressionAssemblies
try
{
$destFile = "$TestDrive$($DS)ExpandedFile"+([System.Guid]::NewGuid().ToString())+".txt"
$archiveFileStreamArgs = @($path, [System.IO.FileMode]::Open)
$archiveFileStream = New-Object -TypeName System.IO.FileStream -ArgumentList $archiveFileStreamArgs
$zipArchiveArgs = @($archiveFileStream, [System.IO.Compression.ZipArchiveMode]::Read, $false)
$zipArchive = New-Object -TypeName System.IO.Compression.ZipArchive -ArgumentList $zipArchiveArgs
$badEntries = $zipArchive.Entries | Where-Object {$_.FullName.Contains('\')}
$badEntries.Count | Should Be 0
}
finally
{
if ($zipArchive)
{
$zipArchive.Dispose()
}
if ($archiveFileStream)
{
$archiveFileStream.Dispose()
}
}
}
function ExpandArchiveInvalidParameterValidator {
param
(
[boolean] $isLiteralPathParameterSet,
[string[]] $path,
[string] $destinationPath,
[string] $expectedFullyQualifiedErrorId
)
try
{
if($isLiteralPathParameterSet)
{
Expand-Archive -LiteralPath $literalPath -DestinationPath $destinationPath
}
else
{
Expand-Archive -Path $path -DestinationPath $destinationPath
}
throw "Expand-Archive did NOT throw expected error"
}
catch
{
$_.FullyQualifiedErrorId | Should Be $expectedFullyQualifiedErrorId
}
}
Context "Compress-Archive - Parameter validation test cases" {
It "Validate errors from Compress-Archive with NULL & EMPTY values for Path, LiteralPath, DestinationPath, CompressionLevel parameters" {
$sourcePath = "$TestDrive$($DS)SourceDir"
$destinationPath = "$TestDrive$($DS)SampleSingleFile.zip"
CompressArchivePathParameterSetValidator $null $destinationPath
CompressArchivePathParameterSetValidator $sourcePath $null
CompressArchivePathParameterSetValidator $null $null
CompressArchivePathParameterSetValidator "" $destinationPath
CompressArchivePathParameterSetValidator $sourcePath ""
CompressArchivePathParameterSetValidator "" ""
CompressArchivePathParameterSetValidator $null $null "NoCompression"
CompressArchiveLiteralPathParameterSetValidator $null $destinationPath
CompressArchiveLiteralPathParameterSetValidator $sourcePath $null
CompressArchiveLiteralPathParameterSetValidator $null $null
CompressArchiveLiteralPathParameterSetValidator "" $destinationPath
CompressArchiveLiteralPathParameterSetValidator $sourcePath ""
CompressArchiveLiteralPathParameterSetValidator "" ""
CompressArchiveLiteralPathParameterSetValidator $null $null "NoCompression"
CompressArchiveLiteralPathParameterSetValidator $sourcePath $destinationPath $null
CompressArchiveLiteralPathParameterSetValidator $sourcePath $destinationPath ""
}
It "Validate errors from Compress-Archive when invalid path (non-existing path / non-filesystem path) is supplied for Path or LiteralPath parameters" {
CompressArchiveInValidPathValidator "$TestDrive$($DS)InvalidPath" $TestDrive "$TestDrive$($DS)InvalidPath" "ArchiveCmdletPathNotFound,Compress-Archive"
CompressArchiveInValidPathValidator "$TestDrive" "$TestDrive$($DS)NonExistingDirectory$($DS)sample.zip" "$TestDrive$($DS)NonExistingDirectory$($DS)sample.zip" "ArchiveCmdletPathNotFound,Compress-Archive"
$path = @("$TestDrive", "$TestDrive$($DS)InvalidPath")
CompressArchiveInValidPathValidator $path $TestDrive "$TestDrive$($DS)InvalidPath" "ArchiveCmdletPathNotFound,Compress-Archive"
# The tests below are no longer valid. You can have zip files with non-zip extensions. Different archive
# formats should be added in a separate pull request, with a parameter to identify the archive format, and
# default formats associated with specific extensions. Until then, as long as these cmdlets only support
# Zip files, any file extension is supported.
#$invalidUnZipFileFormat = "$TestDrive$($DS)Sample.unzip"
#CompressArchiveInValidArchiveFileExtensionValidator $TestDrive "$invalidUnZipFileFormat" ".unzip"
#$invalidcabZipFileFormat = "$TestDrive$($DS)Sample.cab"
#CompressArchiveInValidArchiveFileExtensionValidator $TestDrive "$invalidcabZipFileFormat" ".cab"
}
It "Validate error from Compress-Archive when archive file already exists and -Update parameter is not specified" {
$sourcePath = "$TestDrive$($DS)SourceDir"
$destinationPath = "$TestDrive$($DS)ValidateErrorWhenUpdateNotSpecified.zip"
try
{
"Some Data" > $destinationPath
Compress-Archive -Path $sourcePath -DestinationPath $destinationPath
throw "Failed to validate that an archive file format $destinationPath already exists and -Update switch parameter is not specified while running Compress-Archive command."
}
catch
{
$_.FullyQualifiedErrorId | Should Be "ArchiveFileExists,Compress-Archive"
}
}
It "Validate error from Compress-Archive when duplicate paths are supplied as input to Path parameter" {
$sourcePath = @(
"$TestDrive$($DS)SourceDir$($DS)Sample-1.txt",
"$TestDrive$($DS)SourceDir$($DS)Sample-1.txt")
$destinationPath = "$TestDrive$($DS)DuplicatePaths.zip"
try
{
Compress-Archive -Path $sourcePath -DestinationPath $destinationPath
throw "Failed to detect that duplicate Path $sourcePath is supplied as input to Path parameter."
}
catch
{
$_.FullyQualifiedErrorId | Should Be "DuplicatePathFound,Compress-Archive"
}
}
It "Validate error from Compress-Archive when duplicate paths are supplied as input to LiteralPath parameter" {
$sourcePath = @(
"$TestDrive$($DS)SourceDir$($DS)Sample-1.txt",
"$TestDrive$($DS)SourceDir$($DS)Sample-1.txt")
$destinationPath = "$TestDrive$($DS)DuplicatePaths.zip"
try
{
Compress-Archive -LiteralPath $sourcePath -DestinationPath $destinationPath
throw "Failed to detect that duplicate Path $sourcePath is supplied as input to LiteralPath parameter."
}
catch
{
$_.FullyQualifiedErrorId | Should Be "DuplicatePathFound,Compress-Archive"
}
}
}
Context "Compress-Archive - functional test cases" {
It "Validate that a single file can be compressed using Compress-Archive cmdlet" {
$sourcePath = "$TestDrive$($DS)SourceDir$($DS)ChildDir-1$($DS)Sample-3.txt"
$destinationPath = "$TestDrive$($DS)SampleSingleFile.zip"
Compress-Archive -Path $sourcePath -DestinationPath $destinationPath
$destinationPath | Should Exist
}
# This test requires a fix in PS5 to support reading paths with square bracket
It "Validate that Compress-Archive cmdlet can accept LiteralPath parameter with Special Characters" -skip:(($PSVersionTable.psversion.Major -lt 5) -and ($PSVersionTable.psversion.Minor -lt 0)) {
$sourcePath = "$TestDrive$($DS)SourceDir$($DS)ChildDir-1$($DS)Sample[]File.txt"
"Some Random Content" | Out-File -LiteralPath $sourcePath
$destinationPath = "$TestDrive$($DS)SampleSingleFileWithSpecialCharacters.zip"
try
{
Compress-Archive -LiteralPath $sourcePath -DestinationPath $destinationPath
$destinationPath | Should Exist
}
finally
{
Remove-Item -LiteralPath $sourcePath -Force
}
}
It "Validate that Compress-Archive cmdlet errors out when DestinationPath resolves to multiple locations" {
New-Item $TestDrive$($DS)SampleDir$($DS)Child-1 -Type Directory -Force | Out-Null
New-Item $TestDrive$($DS)SampleDir$($DS)Child-2 -Type Directory -Force | Out-Null
New-Item $TestDrive$($DS)SampleDir$($DS)Test.txt -Type File -Force | Out-Null
$destinationPath = "$TestDrive$($DS)SampleDir$($DS)Child-*$($DS)SampleChidArchive.zip"
$sourcePath = "$TestDrive$($DS)SampleDir$($DS)Test.txt"
try
{
Compress-Archive -Path $sourcePath -DestinationPath $destinationPath
throw "Failed to detect that destination $destinationPath can resolve to multiple paths"
}
catch
{
$_.FullyQualifiedErrorId | Should Be "InvalidArchiveFilePath,Compress-Archive"
}
finally
{
Remove-Item -LiteralPath $TestDrive$($DS)SampleDir -Force -Recurse
}
}
It "Validate that Compress-Archive cmdlet works when DestinationPath has wild card pattern and resolves to a single valid path" {
New-Item $TestDrive$($DS)SampleDir$($DS)Child-1 -Type Directory -Force | Out-Null
New-Item $TestDrive$($DS)SampleDir$($DS)Test.txt -Type File -Force | Out-Null
$destinationPath = "$TestDrive$($DS)SampleDir$($DS)Child-*$($DS)SampleChidArchive.zip"
$sourcePath = "$TestDrive$($DS)SampleDir$($DS)Test.txt"
try
{
Compress-Archive -Path $sourcePath -DestinationPath $destinationPath
$destinationPath | Should Exist
}
finally
{
Remove-Item -LiteralPath $TestDrive$($DS)SampleDir -Force -Recurse
}
}
It "Validate that Compress-Archive cmdlet works when it ecounters LastWriteTimeValues earlier than 1980" {
New-Item $TestDrive$($DS)SampleDir$($DS)Child-1 -Type Directory -Force | Out-Null
$file = New-Item $TestDrive$($DS)SampleDir$($DS)Test.txt -Type File -Force
$destinationPath = "$TestDrive$($DS)SampleDir$($DS)Child-*$($DS)SampleChidArchive.zip"
$sourcePath = "$TestDrive$($DS)SampleDir$($DS)Test.txt"
$file.LastWriteTime = [DateTime]::Parse('1967-03-04T06:00:00')
try
{
Compress-Archive -Path $sourcePath -DestinationPath $destinationPath -WarningAction SilentlyContinue
$destinationPath | Should Exist
}
finally
{
Remove-Item -LiteralPath $TestDrive$($DS)SampleDir -Force -Recurse
}
}
It "Validate that Compress-Archive cmdlet warns when updating the LastWriteTime for files earlier than 1980" {
New-Item $TestDrive$($DS)SampleDir$($DS)Child-1 -Type Directory -Force | Out-Null
$file = New-Item $TestDrive$($DS)SampleDir$($DS)Test.txt -Type File -Force
$destinationPath = "$TestDrive$($DS)SampleDir$($DS)Child-*$($DS)SampleChidArchive.zip"
$sourcePath = "$TestDrive$($DS)SampleDir$($DS)Test.txt"
$file.LastWriteTime = [DateTime]::Parse('1967-03-04T06:00:00')
try
{
$ps=[PowerShell]::Create()
$ps.Streams.Warning.Clear()
$script = "Import-Module Microsoft.PowerShell.Archive; Compress-Archive -Path $sourcePath -DestinationPath `"$destinationPath`" -CompressionLevel Fastest -Verbose"
$ps.AddScript($script)
$ps.Invoke()
$ps.Streams.Warning.Count -gt 0 | Should Be $True
}
finally
{
Remove-Item -LiteralPath $TestDrive$($DS)SampleDir -Force -Recurse
}
}
# This test requires a fix in PS5 to support reading paths with square bracket
It "Validate that Compress-Archive cmdlet can accept LiteralPath parameter for a directory with Special Characters in the directory name" -skip:(($PSVersionTable.psversion.Major -lt 5) -and ($PSVersionTable.psversion.Minor -lt 0)) {
$sourcePath = "$TestDrive$($DS)Source[]Dir$($DS)ChildDir[]-1"
New-Item $sourcePath -Type Directory | Out-Null
"Some Random Content" | Out-File -LiteralPath "$sourcePath$($DS)Sample[]File.txt"
$destinationPath = "$TestDrive$($DS)SampleDirWithSpecialCharacters.zip"
try
{
Compress-Archive -LiteralPath $sourcePath -DestinationPath $destinationPath
$destinationPath | Should Exist
}
finally
{
Remove-Item -LiteralPath $sourcePath -Force -Recurse
}
}
It "Validate that Compress-Archive cmdlet can accept DestinationPath parameter with Special Characters" {
$sourcePath = "$TestDrive$($DS)SourceDir$($DS)ChildDir-1$($DS)Sample-3.txt"
$destinationPath = "$TestDrive$($DS)Sample[]SingleFile.zip"
try
{
Compress-Archive -Path $sourcePath -DestinationPath $destinationPath
Test-Path -LiteralPath $destinationPath | Should Be $true
}
finally
{
Remove-Item -LiteralPath $destinationPath -Force
}
}
It "Validate that Source Path can be at SystemDrive location" -skip:(!$IsWindows) {
$sourcePath = "$env:SystemDrive$($DS)SourceDir"
$destinationPath = "$TestDrive$($DS)SampleFromSystemDrive.zip"
New-Item $sourcePath -Type Directory | Out-Null # not enough permissions to write to drive root on Linux
"Some Data" | Out-File -FilePath $sourcePath$($DS)SampleSourceFileForArchive.txt
try
{
Compress-Archive -Path $sourcePath -DestinationPath $destinationPath
Test-Path $destinationPath | Should Be $true
}
finally
{
del "$sourcePath" -Force -Recurse -ErrorAction SilentlyContinue
}
}
It "Validate that multiple files can be compressed using Compress-Archive cmdlet" {
$sourcePath = @(
"$TestDrive$($DS)SourceDir$($DS)ChildDir-1$($DS)Sample-3.txt",
"$TestDrive$($DS)SourceDir$($DS)ChildDir-1$($DS)Sample-4.txt",
"$TestDrive$($DS)SourceDir$($DS)ChildDir-2$($DS)Sample-5.txt",
"$TestDrive$($DS)SourceDir$($DS)ChildDir-2$($DS)Sample-6.txt")
$destinationPath = "$TestDrive$($DS)SampleMultipleFiles.zip"
Compress-Archive -Path $sourcePath -DestinationPath $destinationPath
Test-Path $destinationPath | Should Be $true
}
It "Validate that multiple files and directories can be compressed using Compress-Archive cmdlet" {
$sourcePath = @(
"$TestDrive$($DS)SourceDir$($DS)Sample-1.txt",
"$TestDrive$($DS)SourceDir$($DS)Sample-2.txt",
"$TestDrive$($DS)SourceDir$($DS)ChildDir-1",
"$TestDrive$($DS)SourceDir$($DS)ChildDir-2")
$destinationPath = "$TestDrive$($DS)SampleMultipleFilesAndDirs.zip"
Compress-Archive -Path $sourcePath -DestinationPath $destinationPath
Test-Path $destinationPath | Should Be $true
}
It "Validate that a single directory can be compressed using Compress-Archive cmdlet" {
$sourcePath = @("$TestDrive$($DS)SourceDir$($DS)ChildDir-1")
$destinationPath = "$TestDrive$($DS)SampleSingleDir.zip"
Compress-Archive -Path $sourcePath -DestinationPath $destinationPath
Test-Path $destinationPath | Should Be $true
}
It "Validate that a single directory with multiple files and subdirectories can be compressed using Compress-Archive cmdlet" {
$sourcePath = @("$TestDrive$($DS)SourceDir")
$destinationPath = "$TestDrive$($DS)SampleSubTree.zip"
Compress-Archive -Path $sourcePath -DestinationPath $destinationPath
Test-Path $destinationPath | Should Be $true
}
It "Validate that a single directory & multiple files can be compressed using Compress-Archive cmdlet" {
$sourcePath = @(
"$TestDrive$($DS)SourceDir$($DS)ChildDir-1",
"$TestDrive$($DS)SourceDir$($DS)Sample-1.txt",
"$TestDrive$($DS)SourceDir$($DS)Sample-2.txt")
$destinationPath = "$TestDrive$($DS)SampleMultipleFilesAndSingleDir.zip"
Compress-Archive -Path $sourcePath -DestinationPath $destinationPath
Test-Path $destinationPath | Should Be $true
}
It "Validate that if .zip extension is not supplied as input to DestinationPath parameter, then .zip extension is appended" {
$sourcePath = @("$TestDrive$($DS)SourceDir")
$destinationPath = "$TestDrive$($DS)SampleNoExtension.zip"
$destinationWithoutExtensionPath = "$TestDrive$($DS)SampleNoExtension"
Compress-Archive -Path $sourcePath -DestinationPath $destinationWithoutExtensionPath
Test-Path $destinationPath | Should Be $true
}
It "Validate that relative path can be specified as Path parameter of Compress-Archive cmdlet" {
$sourcePath = ".$($DS)SourceDir"
$destinationPath = "RelativePathForPathParameter.zip"
try
{
Push-Location $TestDrive
Compress-Archive -Path $sourcePath -DestinationPath $destinationPath
Test-Path $destinationPath | Should Be $true
}
finally
{
Pop-Location
}
}
It "Validate that relative path can be specified as LiteralPath parameter of Compress-Archive cmdlet" {
$sourcePath = ".$($DS)SourceDir"
$destinationPath = "RelativePathForLiteralPathParameter.zip"
try
{
Push-Location $TestDrive
Compress-Archive -LiteralPath $sourcePath -DestinationPath $destinationPath
Test-Path $destinationPath | Should Be $true
}
finally
{
Pop-Location
}
}
It "Validate that relative path can be specified as DestinationPath parameter of Compress-Archive cmdlet" {
$sourcePath = "$TestDrive$($DS)SourceDir"
$destinationPath = ".$($DS)RelativePathForDestinationPathParameter.zip"
try
{
Push-Location $TestDrive
Compress-Archive -Path $sourcePath -DestinationPath $destinationPath
Test-Path $destinationPath | Should Be $true
}
finally
{
Pop-Location
}
}
It "Validate that -Update parameter makes Compress-Archive to not throw an error if archive file already exists" {
$sourcePath = @("$TestDrive$($DS)SourceDir")
$destinationPath = "$TestDrive$($DS)SampleUpdateTest.zip"
Compress-Archive -Path $sourcePath -DestinationPath $destinationPath
Test-Path $destinationPath | Should Be $true
Compress-Archive -Path $sourcePath -DestinationPath $destinationPath -Update
Test-Path $destinationPath | Should Be $true
}
It "Validate -Update parameter by adding a new file to an existing archive file" {
$sourcePath = @("$TestDrive$($DS)SourceDir$($DS)ChildDir-1")
$destinationPath = "$TestDrive$($DS)SampleUpdateAdd1File.zip"
Compress-Archive -Path $sourcePath -DestinationPath $destinationPath
Test-Path $destinationPath | Should Be $true
New-Item $TestDrive$($DS)SourceDir$($DS)ChildDir-1$($DS)Sample-AddedNewFile.txt -Type File | Out-Null
Compress-Archive -Path $sourcePath -DestinationPath $destinationPath -Update
Test-Path $destinationPath | Should Be $true
Validate-ArchiveEntryCount -path $destinationPath -expectedEntryCount 3
}
It "Validate that all CompressionLevel values can be used with Compress-Archive cmdlet" {
$sourcePath = "$TestDrive$($DS)SourceDir$($DS)Sample-1.txt"
$destinationPath = "$TestDrive$($DS)FastestCompressionLevel.zip"
Compress-Archive -Path $sourcePath -DestinationPath $destinationPath -CompressionLevel Fastest
Test-Path $destinationPath | Should Be $true
$destinationPath = "$TestDrive$($DS)OptimalCompressionLevel.zip"
Compress-Archive -Path $sourcePath -DestinationPath $destinationPath -CompressionLevel Optimal
Test-Path $destinationPath | Should Be $true
$destinationPath = "$TestDrive$($DS)NoCompressionCompressionLevel.zip"
Compress-Archive -Path $sourcePath -DestinationPath $destinationPath -CompressionLevel NoCompression
Test-Path $destinationPath | Should Be $true
}
It "Validate that -Update parameter is modifying a file that already exists in the archive file" {
$filePath = "$TestDrive$($DS)SourceDir$($DS)ChildDir-1$($DS)Sample-3.txt"
$initialContent = "Initial Content"
$modifiedContent = "Modified Content"
$initialContent | Set-Content $filePath
$sourcePath = "$TestDrive$($DS)SourceDir"
$destinationPath = "$TestDrive$($DS)UpdatingModifiedFile.zip"
Compress-Archive -Path $sourcePath -DestinationPath $destinationPath
Test-Path $destinationPath | Should Be $True
$modifiedContent | Set-Content $filePath
Compress-Archive -Path $sourcePath -DestinationPath $destinationPath -Update
Test-Path $destinationPath | Should Be $True
ArchiveFileEntryContentValidator "$destinationPath" "SourceDir$($DS)ChildDir-1$($DS)Sample-3.txt" $modifiedContent
}
It "Validate that only / separators are used as archive directory separators" {
$filePath = "$TestDrive$($DS)SourceDir$($DS)ChildDir-1$($DS)Sample-3.txt"
$initialContent = "Initial Content"
$modifiedContent = "Modified Content"
$initialContent | Set-Content $filePath
$sourcePath = "$TestDrive$($DS)SourceDir"
$destinationPath = "$TestDrive$($DS)VerifyingSeparators.zip"
Compress-Archive -Path $sourcePath -DestinationPath $destinationPath
Test-Path $destinationPath | Should Be $True
ArchiveFileEntrySeparatorValidator "$destinationPath"
}
It "Validate Compress-Archive cmdlet in pipleline scenario" {
$destinationPath = "$TestDrive$($DS)CompressArchiveFromPipeline.zip"
# Piping a single file path to Compress-Archive
dir -Path $TestDrive$($DS)SourceDir$($DS)Sample-1.txt | Compress-Archive -DestinationPath $destinationPath
Test-Path $destinationPath | Should Be $True
# Piping a string directory path to Compress-Archive
"$TestDrive$($DS)SourceDir$($DS)ChildDir-2" | Compress-Archive -DestinationPath $destinationPath -Update
Test-Path $destinationPath | Should Be $True
# Piping the output of Get-ChildItem to Compress-Archive
dir "$TestDrive$($DS)SourceDir" -Recurse | Compress-Archive -DestinationPath $destinationPath -Update
Test-Path $destinationPath | Should Be $True
}
It "Validate that Compress-Archive works on ReadOnly files" {
$sourcePath = "$TestDrive$($DS)ReadOnlyFile.txt"
$destinationPath = "$TestDrive$($DS)TestForReadOnlyFile.zip"
"Some Content" | Out-File -FilePath $sourcePath
$createdItem = Get-Item $sourcePath
$createdItem.Attributes = 'ReadOnly'
Compress-Archive -Path $sourcePath -DestinationPath $destinationPath
Test-Path $destinationPath | Should Be $true
}
It "Validate that Compress-Archive generates Verbose messages" {
$sourcePath = "$TestDrive$($DS)SourceDir"
$destinationPath = "$TestDrive$($DS)Compress-Archive generates VerboseMessages.zip"
try
{
$ps=[PowerShell]::Create()
$ps.Streams.Error.Clear()
$ps.Streams.Verbose.Clear()
$script = "Import-Module Microsoft.PowerShell.Archive; Compress-Archive -Path $sourcePath -DestinationPath `"$destinationPath`" -CompressionLevel Fastest -Verbose"
$ps.AddScript($script)
$ps.Invoke()
$ps.Streams.Verbose.Count -gt 0 | Should Be $True
$ps.Streams.Error.Count | Should Be 0
}
finally
{
$ps.Dispose()
}
}
It "Validate that Compress-Archive returns nothing when -PassThru is not used" {
$sourcePath = @("$TestDrive$($DS)SourceDir")
$destinationPath = "$TestDrive$($DS)NoPassThruTest.zip"
$archive = Compress-Archive -Path $sourcePath -DestinationPath $destinationPath
$archive | Should Be $null
}
It "Validate that Compress-Archive returns nothing when -PassThru is used with a value of $false" {
$sourcePath = @("$TestDrive$($DS)SourceDir")
$destinationPath = "$TestDrive$($DS)FalsePassThruTest.zip"
$archive = Compress-Archive -Path $sourcePath -DestinationPath $destinationPath -PassThru:$false
$archive | Should Be $null
}
It "Validate that Compress-Archive returns the archive when invoked with -PassThru" {
$sourcePath = @("$TestDrive$($DS)SourceDir")
$destinationPath = "$TestDrive$($DS)PassThruTest.zip"
$archive = Compress-Archive -Path $sourcePath -DestinationPath $destinationPath -PassThru
$archive.FullName | Should Be $destinationPath
}
It "Validate that Compress-Archive can create a zip archive that has a different extension" {
$sourcePath = "$TestDrive$($DS)SourceDir$($DS)ChildDir-1$($DS)Sample-3.txt"
$destinationPath = "$TestDrive$($DS)DifferentZipExtension.dat"
Compress-Archive -Path $sourcePath -DestinationPath $destinationPath
$destinationPath | Should Exist
}
It "Validate that Compress-Archive can create a zip archive when the source is in use" {
$sourcePath = "$TestDrive$($DS)InUseFile.txt"
$destinationPath = "$TestDrive$($DS)TestForinUseFile.zip"
"Some Content" | Out-File -FilePath $sourcePath
Get-Content $sourcePath
$TestFile = [System.IO.File]::Open($sourcePath, 'Open', 'Read', 'Read')
try {
Compress-Archive -Path $sourcePath -DestinationPath $destinationPath
Test-Path $destinationPath | Should Be $true
}
finally {
$TestFile.Close()
}
}
}
Context "Expand-Archive - Parameter validation test cases" {
It "Validate non existing archive -Path trows expected error message" {
$sourcePath = "$TestDrive$($DS)SourceDir"
$destinationPath = "$TestDrive$($DS)ExpandedArchive"
try
{
Expand-Archive -Path $sourcePath -DestinationPath $destinationPath
throw "Expand-Archive succeeded for non existing archive path"
}
catch
{
$_.FullyQualifiedErrorId | Should Be "PathNotFound,Expand-Archive"
}
}
It "Validate errors from Expand-Archive with NULL & EMPTY values for Path, LiteralPath, DestinationPath parameters" {
ExpandArchiveInvalidParameterValidator $false $null "$TestDrive$($DS)SourceDir" "ParameterArgumentValidationError,Expand-Archive"
ExpandArchiveInvalidParameterValidator $false $null $null "ParameterArgumentValidationError,Expand-Archive"
ExpandArchiveInvalidParameterValidator $false "$TestDrive$($DS)SourceDir" $null "ParameterArgumentTransformationError,Expand-Archive"
ExpandArchiveInvalidParameterValidator $false "" "$TestDrive$($DS)SourceDir" "ParameterArgumentTransformationError,Expand-Archive"
ExpandArchiveInvalidParameterValidator $false "$TestDrive$($DS)SourceDir" "" "ParameterArgumentTransformationError,Expand-Archive"
ExpandArchiveInvalidParameterValidator $false "" "" "ParameterArgumentTransformationError,Expand-Archive"
ExpandArchiveInvalidParameterValidator $true $null "$TestDrive$($DS)SourceDir" "ParameterArgumentValidationError,Expand-Archive"
ExpandArchiveInvalidParameterValidator $true $null $null "ParameterArgumentValidationError,Expand-Archive"
ExpandArchiveInvalidParameterValidator $true "$TestDrive$($DS)SourceDir" $null "ParameterArgumentValidationError,Expand-Archive"
ExpandArchiveInvalidParameterValidator $true "" "$TestDrive$($DS)SourceDir" "ParameterArgumentValidationError,Expand-Archive"
ExpandArchiveInvalidParameterValidator $true "$TestDrive$($DS)SourceDir" "" "ParameterArgumentValidationError,Expand-Archive"
ExpandArchiveInvalidParameterValidator $true "" "" "ParameterArgumentValidationError,Expand-Archive"
ExpandArchiveInvalidParameterValidator $true $null "$TestDrive$($DS)SourceDir" "ParameterArgumentValidationError,Expand-Archive"
ExpandArchiveInvalidParameterValidator $true $null $null "ParameterArgumentValidationError,Expand-Archive"
ExpandArchiveInvalidParameterValidator $true "$TestDrive$($DS)SourceDir" $null "ParameterArgumentValidationError,Expand-Archive"
ExpandArchiveInvalidParameterValidator $true "" "$TestDrive$($DS)SourceDir" "ParameterArgumentValidationError,Expand-Archive"
ExpandArchiveInvalidParameterValidator $true "$TestDrive$($DS)SourceDir" "" "ParameterArgumentValidationError,Expand-Archive"
ExpandArchiveInvalidParameterValidator $true "" "" "ParameterArgumentValidationError,Expand-Archive"
}
It "Validate errors from Expand-Archive when invalid path (non-existing path / non-filesystem path) is supplied for Path or LiteralPath parameters" {
try { Expand-Archive -Path "$TestDrive$($DS)NonExistingArchive" -DestinationPath "$TestDrive$($DS)SourceDir"; throw "Expand-Archive did NOT throw expected error" }
catch { $_.FullyQualifiedErrorId | Should Be "ArchiveCmdletPathNotFound,Expand-Archive" }
try { Expand-Archive -LiteralPath "$TestDrive$($DS)NonExistingArchive" -DestinationPath "$TestDrive$($DS)SourceDir"; throw "Expand-Archive did NOT throw expected error" }
catch { $_.FullyQualifiedErrorId | Should Be "ArchiveCmdletPathNotFound,Expand-Archive" }
}
It "Validate error from Expand-Archive when invalid path (non-existing path / non-filesystem path) is supplied for DestinationPath parameter" {
$sourcePath = "$TestDrive$($DS)SamplePreCreatedArchive.zip"
$destinationPath = "HKLM:\SOFTWARE"
if ($IsWindows) {
$expectedError = "InvalidDirectoryPath,Expand-Archive"
}
else {
$expectedError = "DriveNotFound,Microsoft.PowerShell.Commands.NewItemCommand"
}
try { Expand-Archive -Path $sourcePath -DestinationPath $destinationPath; throw "Expand-Archive did NOT throw expected error" }
catch { $_.FullyQualifiedErrorId | Should Be $expectedError }
}
It "Validate that you can compress an archive to a custom PSDrive using the Compress-Archive cmdlet" {
$sourcePath = "$TestDrive$($DS)SourceDir$($DS)ChildDir-1$($DS)Sample-3.txt"
$destinationDriveName = 'CompressArchivePesterTest'
$destinationDrive = New-PSDrive -Name $destinationDriveName -PSProvider FileSystem -Root $TestDrive -Scope Global
$destinationPath = "${destinationDriveName}:$($DS)CompressToPSDrive.zip"
try {
Compress-Archive -Path $sourcePath -DestinationPath $destinationPath
$destinationPath | Should Exist
} finally {
Remove-PSDrive -LiteralName $destinationDriveName
}
}
}
Context "Expand-Archive - functional test cases" {
It "Validate basic Expand-Archive scenario" {
$sourcePath = "$TestDrive$($DS)SamplePreCreatedArchive.zip"
$content = "Some Data"
$destinationPath = "$TestDrive$($DS)DestDirForBasicExpand"
$files = @("Sample-1.txt", "Sample-2.txt")
# The files in "$TestDrive$($DS)SamplePreCreatedArchive.zip" are precreated.
$fileCreationTimeStamp = Get-Date -Year 2014 -Month 6 -Day 13 -Hour 15 -Minute 50 -Second 20 -Millisecond 0
Expand-Archive -Path $sourcePath -DestinationPath $destinationPath
foreach($currentFile in $files)
{
$expandedFile = Join-Path $destinationPath -ChildPath $currentFile
Test-Path $expandedFile | Should Be $True
# We are validating to make sure that time stamps are preserved in the
# compressed archive are reflected back when the file is expanded.
(dir $expandedFile).LastWriteTime.CompareTo($fileCreationTimeStamp) | Should Be 0
Get-Content $expandedFile | Should Be $content
}
}
It "Validate that Expand-Archive cmdlet errors out when DestinationPath resolves to multiple locations" {
New-Item $TestDrive$($DS)SampleDir$($DS)Child-1 -Type Directory -Force | Out-Null
New-Item $TestDrive$($DS)SampleDir$($DS)Child-2 -Type Directory -Force | Out-Null
$destinationPath = "$TestDrive$($DS)SampleDir$($DS)Child-*"
$sourcePath = "$TestDrive$($DS)SamplePreCreatedArchive.zip"
try
{
Expand-Archive -Path $sourcePath -DestinationPath $destinationPath
throw "Failed to detect that destination $destinationPath can resolve to multiple paths"
}
catch
{
$_.FullyQualifiedErrorId | Should Be "InvalidDestinationPath,Expand-Archive"
}
finally
{
Remove-Item -LiteralPath $TestDrive$($DS)SampleDir -Force -Recurse
}
}
It "Validate that Expand-Archive cmdlet works when DestinationPath resolves has wild card pattern and resolves to a single valid path" {
New-Item $TestDrive$($DS)SampleDir$($DS)Child-1 -Type Directory -Force | Out-Null
$destinationPath = "$TestDrive$($DS)SampleDir$($DS)Child-*"
$sourcePath = "$TestDrive$($DS)SamplePreCreatedArchive.zip"
try
{
Expand-Archive -Path $sourcePath -DestinationPath $destinationPath
$expandedFiles = Get-ChildItem $destinationPath -Recurse
$expandedFiles.Length | Should BeGreaterThan 1
}
finally
{
Remove-Item -LiteralPath $TestDrive$($DS)SampleDir -Force -Recurse
}
}
It "Validate Expand-Archive scenario where DestinationPath has Special Characters" {
$sourcePath = "$TestDrive$($DS)SamplePreCreatedArchive.zip"
$content = "Some Data"
$destinationPath = "$TestDrive$($DS)DestDir[]Expand"
$files = @("Sample-1.txt", "Sample-2.txt")
# The files in "$TestDrive$($DS)SamplePreCreatedArchive.zip" are precreated.
$fileCreationTimeStamp = Get-Date -Year 2014 -Month 6 -Day 13 -Hour 15 -Minute 50 -Second 20 -Millisecond 0
Expand-Archive -Path $sourcePath -DestinationPath $destinationPath
foreach($currentFile in $files)
{
$expandedFile = Join-Path $destinationPath -ChildPath $currentFile
Test-Path -LiteralPath $expandedFile | Should Be $True
# We are validating to make sure that time stamps are preserved in the
# compressed archive are reflected back when the file is expanded.
(dir -LiteralPath $expandedFile).LastWriteTime.CompareTo($fileCreationTimeStamp) | Should Be 0
Get-Content -LiteralPath $expandedFile | Should Be $content
}
}
It "Invoke Expand-Archive with relative path in Path parameter and -Force parameter" {
$sourcePath = ".$($DS)SamplePreCreatedArchive.zip"
$destinationPath = "$TestDrive$($DS)SomeOtherNonExistingDir$($DS)Path"
try
{
Push-Location $TestDrive
Expand-Archive -Path $sourcePath -DestinationPath $destinationPath -Force
$expandedFiles = Get-ChildItem $destinationPath -Recurse
$expandedFiles.Length | Should Be 2
}
finally
{
Pop-Location
}
}
It "Invoke Expand-Archive with relative path in LiteralPath parameter and -Force parameter" {
$sourcePath = ".$($DS)SamplePreCreatedArchive.zip"
$destinationPath = "$TestDrive$($DS)SomeOtherNonExistingDir$($DS)LiteralPath"
try
{
Push-Location $TestDrive
Expand-Archive -LiteralPath $sourcePath -DestinationPath $destinationPath -Force
$expandedFiles = Get-ChildItem $destinationPath -Recurse
$expandedFiles.Length | Should Be 2
}
finally
{
Pop-Location
}
}
It "Invoke Expand-Archive with non-existing relative directory in DestinationPath parameter and -Force parameter" {
$sourcePath = "$TestDrive$($DS)SamplePreCreatedArchive.zip"
$destinationPath = ".$($DS)SomeOtherNonExistingDir$($DS)DestinationPath"
try
{
Push-Location $TestDrive
Expand-Archive -Path $sourcePath -DestinationPath $destinationPath -Force
$expandedFiles = Get-ChildItem $destinationPath -Recurse
$expandedFiles.Length | Should Be 2
}
finally
{
Pop-Location
}
}
# The test below is no longer valid. You can have zip files with non-zip extensions. Different archive
# formats should be added in a separate pull request, with a parameter to identify the archive format, and
# default formats associated with specific extensions. Until then, as long as these cmdlets only support
# Zip files, any file extension is supported.
#It "Invoke Expand-Archive with unsupported archive format" {
# $sourcePath = "$TestDrive$($DS)Sample.cab"
# $destinationPath = "$TestDrive$($DS)UnsupportedArchiveFormatDir"
# try
# {