diff options
author | Rob Mensching <rob@firegiant.com> | 2024-07-17 11:09:34 -0700 |
---|---|---|
committer | Rob Mensching <rob@firegiant.com> | 2024-07-17 12:15:00 -0700 |
commit | 8fb5d579e8cf5eb0f93d07a73bf318a8969c6b10 (patch) | |
tree | b9640c71b55bf81d63b9978b8583ac5d839bf6ee /src/test | |
parent | bb975d370a6a7398c4d28d23601b20ada7a7cdfe (diff) | |
download | wix-8fb5d579e8cf5eb0f93d07a73bf318a8969c6b10.tar.gz wix-8fb5d579e8cf5eb0f93d07a73bf318a8969c6b10.tar.bz2 wix-8fb5d579e8cf5eb0f93d07a73bf318a8969c6b10.zip |
Initialize WOW64 in TouchFile custom action
Fixes 8638
Diffstat (limited to 'src/test')
3 files changed, 62 insertions, 0 deletions
diff --git a/src/test/msi/TestData/TouchFileTests/TouchFile/Package.wxs b/src/test/msi/TestData/TouchFileTests/TouchFile/Package.wxs new file mode 100644 index 00000000..23bd195b --- /dev/null +++ b/src/test/msi/TestData/TouchFileTests/TouchFile/Package.wxs | |||
@@ -0,0 +1,8 @@ | |||
1 | <Wix xmlns="http://wixtoolset.org/schemas/v4/wxs" xmlns:util="http://wixtoolset.org/schemas/v4/wxs/util"> | ||
2 | <Package Name="~TouchFile" Version="1.0.0" Manufacturer="Example Corporation" UpgradeCode="047730a5-30fe-4a62-a520-da9381b8226a"> | ||
3 | <Component> | ||
4 | <File Source="$(sys.SOURCEFILEPATH)" /> | ||
5 | <util:TouchFile Path="[LocalAppDataFolder]touch-file-test.txt" /> | ||
6 | </Component> | ||
7 | </Package> | ||
8 | </Wix> | ||
diff --git a/src/test/msi/TestData/TouchFileTests/TouchFile/TouchFile.wixproj b/src/test/msi/TestData/TouchFileTests/TouchFile/TouchFile.wixproj new file mode 100644 index 00000000..58321e7e --- /dev/null +++ b/src/test/msi/TestData/TouchFileTests/TouchFile/TouchFile.wixproj | |||
@@ -0,0 +1,6 @@ | |||
1 | <!-- Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. --> | ||
2 | <Project Sdk="WixToolset.Sdk"> | ||
3 | <ItemGroup> | ||
4 | <PackageReference Include="WixToolset.Util.wixext" /> | ||
5 | </ItemGroup> | ||
6 | </Project> \ No newline at end of file | ||
diff --git a/src/test/msi/WixToolsetTest.MsiE2E/TouchFileTests.cs b/src/test/msi/WixToolsetTest.MsiE2E/TouchFileTests.cs new file mode 100644 index 00000000..f7666825 --- /dev/null +++ b/src/test/msi/WixToolsetTest.MsiE2E/TouchFileTests.cs | |||
@@ -0,0 +1,48 @@ | |||
1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. | ||
2 | |||
3 | namespace WixToolsetTest.MsiE2E; | ||
4 | |||
5 | using System; | ||
6 | using System.IO; | ||
7 | using WixTestTools; | ||
8 | using Xunit; | ||
9 | using Xunit.Abstractions; | ||
10 | |||
11 | public class TouchFileTests : MsiE2ETests | ||
12 | { | ||
13 | public TouchFileTests(ITestOutputHelper testOutputHelper) : base(testOutputHelper) | ||
14 | { | ||
15 | } | ||
16 | |||
17 | [RuntimeFact] | ||
18 | public void CanValidateTouchFile() | ||
19 | { | ||
20 | var touchFileTestPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "touch-file-test.txt"); | ||
21 | |||
22 | try | ||
23 | { | ||
24 | var touchFileTime = new DateTime(2004, 4, 5, 0, 0, 0, DateTimeKind.Utc); | ||
25 | |||
26 | File.WriteAllText(touchFileTestPath, "This file exists to test CanValidateTouchFile()"); | ||
27 | File.SetCreationTimeUtc(touchFileTestPath, touchFileTime); | ||
28 | File.SetLastAccessTimeUtc(touchFileTestPath, touchFileTime); | ||
29 | File.SetLastWriteTimeUtc(touchFileTestPath, touchFileTime); | ||
30 | |||
31 | var product = this.CreatePackageInstaller("TouchFile"); | ||
32 | |||
33 | var justBeforeInstall = DateTime.UtcNow; | ||
34 | product.InstallProduct(MSIExec.MSIExecReturnCode.SUCCESS); | ||
35 | |||
36 | var touchFile = new FileInfo(touchFileTestPath); | ||
37 | Assert.Equal(touchFileTime, touchFile.CreationTimeUtc); | ||
38 | Assert.Equal(touchFileTime, touchFile.LastAccessTimeUtc); | ||
39 | Assert.True(touchFile.LastWriteTimeUtc >= justBeforeInstall, $"Touch file {touchFileTestPath} last write time: {touchFile.LastWriteTimeUtc} of file should have been updated to at least: {justBeforeInstall}"); | ||
40 | |||
41 | product.UninstallProduct(MSIExec.MSIExecReturnCode.SUCCESS); | ||
42 | } | ||
43 | finally | ||
44 | { | ||
45 | File.Delete(touchFileTestPath); | ||
46 | } | ||
47 | } | ||
48 | } | ||