diff options
author | Rob Mensching <rob@firegiant.com> | 2019-03-01 16:45:55 -0800 |
---|---|---|
committer | Rob Mensching <rob@robmensching.com> | 2019-03-01 16:51:02 -0800 |
commit | 615bc202834ac45a9a107e5fccd900081a4abf74 (patch) | |
tree | ceebc5b3652f0274bee745701a3538439b0275d1 /src/test | |
parent | 009f11ca9cf8674b40b74888aae90bcd4817828b (diff) | |
download | wix-615bc202834ac45a9a107e5fccd900081a4abf74.tar.gz wix-615bc202834ac45a9a107e5fccd900081a4abf74.tar.bz2 wix-615bc202834ac45a9a107e5fccd900081a4abf74.zip |
Include the preprocessed include files with the processed document
This change also cleans up the internal state handling of the preprocesor
to pass the processing state around rather than depend on "global state"
in member variables. This removes the need to "reset" the member
variables before preprocessing which is much cleaner.
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/WixToolsetTest.CoreIntegration/PreprocessorFixture.cs | 33 |
1 files changed, 29 insertions, 4 deletions
diff --git a/src/test/WixToolsetTest.CoreIntegration/PreprocessorFixture.cs b/src/test/WixToolsetTest.CoreIntegration/PreprocessorFixture.cs index f9a9fe83..633a1b46 100644 --- a/src/test/WixToolsetTest.CoreIntegration/PreprocessorFixture.cs +++ b/src/test/WixToolsetTest.CoreIntegration/PreprocessorFixture.cs | |||
@@ -1,19 +1,44 @@ | |||
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. | 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 | 2 | ||
3 | namespace WixToolsetTest.CoreIntegration | 3 | namespace WixToolsetTest.CoreIntegration |
4 | { | 4 | { |
5 | using System.IO; | 5 | using System.IO; |
6 | using System.Linq; | 6 | using System.Linq; |
7 | using WixBuildTools.TestSupport; | 7 | using WixBuildTools.TestSupport; |
8 | using WixToolset.Core; | ||
8 | using WixToolset.Core.TestPackage; | 9 | using WixToolset.Core.TestPackage; |
9 | using WixToolset.Data; | 10 | using WixToolset.Extensibility.Data; |
10 | using WixToolset.Data.Tuples; | ||
11 | using WixToolset.Data.WindowsInstaller; | ||
12 | using Xunit; | 11 | using Xunit; |
13 | 12 | ||
14 | public class PreprocessorFixture | 13 | public class PreprocessorFixture |
15 | { | 14 | { |
16 | [Fact] | 15 | [Fact] |
16 | public void PreprocessDirectly() | ||
17 | { | ||
18 | var folder = TestData.Get(@"TestData\IncludePath"); | ||
19 | var sourcePath = Path.Combine(folder, "Package.wxs"); | ||
20 | var includeFolder = Path.Combine(folder, "data"); | ||
21 | var includeFile = Path.Combine(includeFolder, "Package.wxi"); | ||
22 | |||
23 | var serviceProvider = new WixToolsetServiceProvider(); | ||
24 | |||
25 | var context = (IPreprocessContext)serviceProvider.GetService(typeof(IPreprocessContext)); | ||
26 | context.SourcePath = sourcePath; | ||
27 | context.IncludeSearchPaths = new[] { includeFolder }; | ||
28 | |||
29 | var preprocessor = (IPreprocessor)serviceProvider.GetService(typeof(IPreprocessor)); | ||
30 | var result = preprocessor.Preprocess(context); | ||
31 | |||
32 | var includedFile = result.IncludedFiles.Single(); | ||
33 | Assert.NotNull(result.Document); | ||
34 | Assert.Equal(includeFile, includedFile.Path); | ||
35 | Assert.Equal(sourcePath, includedFile.SourceLineNumbers.FileName); | ||
36 | Assert.Equal(2, includedFile.SourceLineNumbers.LineNumber.Value); | ||
37 | Assert.Equal($"{sourcePath}*2", includedFile.SourceLineNumbers.QualifiedFileName); | ||
38 | Assert.Null(includedFile.SourceLineNumbers.Parent); | ||
39 | } | ||
40 | |||
41 | [Fact] | ||
17 | public void VariableRedefinitionIsAWarning() | 42 | public void VariableRedefinitionIsAWarning() |
18 | { | 43 | { |
19 | var folder = TestData.Get(@"TestData\Variables"); | 44 | var folder = TestData.Get(@"TestData\Variables"); |