
Ящик для предложений: sales@blogslov.ru
Send Wix-commits mailing list submissions to
wix-commits@lists.sourceforge.net
To subscribe or unsubscribe via the World Wide Web, visit
https://lists.sourceforge.net/lists/listinfo/wix-commits
or, via email, send a message with subject or body 'help' to
wix-commits-request@lists.sourceforge.net
You can reach the person managing the list at
wix-commits-owner@lists.sourceforge.net
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Wix-commits digest..."
Today's Topics:
1. wix/src/WixUnit CompareUnit.cs, NONE, 1.1 ProcessUnit.cs,
NONE, 1.1 PyroUnit.cs, NONE, 1.1 CandleUnit.cs, 1.1, 1.2
LightUnit.cs, 1.3, 1.4 ToolUtility.cs, 1.3, 1.4 TorchUnit.cs,
1.1, 1.2 WixProjUnit.cs, 1.2, 1.3 WixUnit.cs, 1.4, 1.5
WixUnit.csproj, 1.4, 1.5 unitTests.xsd, 1.5, 1.6 (Rob Mensching)
----------------------------------------------------------------------
Message: 1
Date: Wed, 27 Jun 2007 05:35:52 +0000
From: Rob Mensching
Subject: [WiX-commits] wix/src/WixUnit CompareUnit.cs, NONE, 1.1
ProcessUnit.cs, NONE, 1.1 PyroUnit.cs, NONE, 1.1 CandleUnit.cs, 1.1,
1.2 LightUnit.cs, 1.3, 1.4 ToolUtility.cs, 1.3, 1.4 TorchUnit.cs, 1.1,
1.2 WixProjUnit.cs, 1.2, 1.3 WixUnit.cs, 1.4, 1.5 WixUnit.csproj, 1.4,
1.5 unitTests.xsd, 1.5, 1.6
To: wix-commits@lists.sourceforge.net
Message-ID:
Update of /cvsroot/wix/wix/src/WixUnit
In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv1332/src/WixUnit
Modified Files:
CandleUnit.cs LightUnit.cs ToolUtility.cs TorchUnit.cs
WixProjUnit.cs WixUnit.cs WixUnit.csproj unitTests.xsd
Added Files:
CompareUnit.cs ProcessUnit.cs PyroUnit.cs
Log Message:
Benxing: Number of patch related bug fix
*Update FeatureComponent table when ComponentRef in the selected PatchFamily
*File Sequence problem
PMarcu: Allowing extension attributes on DirectoryRef and PropertyRef
Adding extension attributes to the VSExtension Refs
PMarcu: Adding UIRef and DirectoryRef to possible PatchFamily Children
Allowing extension attributes on CustomAction elements.
JRock: Added support for setting pre- and post-build event command lines via a
property page in Votive. This gets me one step closer to restoring the
inter-project variables that we had in V2 but had to pull in V3 to get
it out the door (e.g. $(var.MyProject.TargetPath)).
JRock: Added support for SolutionX variables in the wix.targets file. So, you
can now use $(var.SolutionDir) in your .wxs files and have the variables
automatically added to the preprocessor definitions when building with
wix.targets and MSBuild.
Benxing: Regardless of differences in the MST, we will compare underlying files before
copying data into the patch. Extensions can override CompareFiles to provide
custom file diffing behavior.
AaronSte: Updating Heat to use HKCU instead of HKLM when harvesting registry
information on Windows Vista to avoid UAC issues
PMarcu: Making XsdStitch only output a single prefix for each extension namespace.
Benxing: Fixing null reference exception in the binder when the file table is empty.
RobMen: Default File/@Name to File/@Id.
MikeHo: Fix bug with Setup.exe when trying to install and TEMP and AppData
folders are not on same drive, setup fails
MikeHo: Add fallback to Caching the MSI.
RobMen: SFBUG:1680666 - Correctly modularize RemoveIniFile.DirProperites.
PMarcu: Removing FragmentRef's
AaronSte: SFBUG:1675664 - Marking ComboBox value attribute as localizable.
PMarcu: Adding BinaryRef as a child of PatchFamily.
Benxing: Give warning when removing component from feature during the patch build.
PMarcu: Changing namespace keys in the VSExtension help tables to not be modularized.
PMarcu: Adding some targeted checks to patch transforms to catch possible error
conditions as early as possible.
AaronSte: Adding Visual Studio Codename Orcas detection properties.
AaronSte: SFBUG:1687207 - Update Heat so DllRegisterServer captures will work
on Windows Vista from an elevated cmd prompt.
PMarcu: Fix for DocCompiler to handle ref attributes in attribute definitions under
elements.
BobArnso: Resize and combine some controls to better fit localized strings
(affects all UI sets, dialogs UserExit, OutOfRbDiskDlg, OutOfDiskDlg)
Benxing: Skipping unreal tables when binding transforms to improve patch build
perfomance.
Adding active substorage into binder extension to give the ability to
access corresponding transform information.
JRock: SFBUG:1673425 - Cannot access the VS menu using the alt key
SFBUG:1576283 - Unable to enter 'c' or 'm' in proj properties screen fields
SFBUG:1570392 - Project Designer - Index was outside the bounds of the array
SFBUG:1566296 - Setting 'Cultures' field in project properties has no effect
SFBUG:1576287 - Modifying project properties does not force rebuild
Benxing: Ignore rows without section id in ReduceTransform.
MikeHo: Allow for multiple files to be extracted from chainer.
AaronSte: Adding Visual Studio Team Test project system detection properties.
FGrohn: Support for PubCA in WiX v3.
HeathS: Added extension support to the Validator.
Exposed extension support for the Validator through light.exe.
Exposed extension support for the Validator through smoke.exe.
Exposed multiple .cub file support through smoke.exe.
HeathS: Exposed multiple .cub file support through light.exe.
Added a test for the Validator and multiple .cub support in light.exe.
MikeHo: Add error messages for Windows Installer service can't start or Install
blocked by system policy
BobArnso: Add WixQueryOsInfo CA to detect system suite info and "special
folders" as properties over and above the MSI set
BobArnso: Default to removing library rows from decompiled output in
WixUtilExtension
PMarcu: Refactoring patch buld system to use Pyro instead of Light for filtering
and binding. Other target patch specific bug fixes are in the mix as well.
PMarcu: Adding more command line options to Pyro, specifically the ones that
provide settings for the binder.
PMarcu: Adding error and warning preprocessor instructions.
PMarcu: Fixing an exception thrown when Dark is run and no extensions are defined
in the config file or the config file is absent.
Also, bug where Customtable columns that are not foreign keys have the
keytable attribute defined on the column as keytable="". This results in
an invalid table reference to "".
PMarcu: Switching order on Pyro commandline.
Jordanf: Adding support to WixUnit for Pyro. Fixing the qtest patch.minorupgrade
to use Pyro.
BrianRe: Added code to detect a namespace prefix that is already in use and if
so it will append it with its' position within the "duplicates" for
that specific prefix; eg. sql, sql2, sql3, and so on.
RobMen: Add support for PerformanceCounters (including managed code).
FGrohn: Added COM+ and MSMQ extensions to the zip file.
FGrohn: Move to Windows Vista SDK.
JRock: SFBUG:1566807 - Display full version in about dialog.
SFBUG:1697089 - MSBuild WiX taskscannot resolve WiX tool paths automatically
SFBUG:1689830 - Error when using Wix3 when not installed on C drive
Benxing: Handle Sequence tables when building the patch.
Don't allow empty patch.
HeathS: Added an extension for installing PowerShell snap-ins.
PMarcu: Adding Melt as a tool to decompile MSM's to ComponentGroups.
PMarcu: Adding warning for when a non keypath file is updated and the keypath file
of that component is not.
Benxing: Adding information into _SummaryInformation table for patch build.
PMarcu: Adding a check to assure no duplicate fragment Id's exist.
JKuhne: Fixing a GC issue with the Validator. (Locals are rooted until last reference, not
end of scope.)
BobArnso: Add DiskId attribute to Directory and DirectoryRef to provide default
DiskId for contained components and files.
MikeHo: Fix language matching in Setup.exe
PMarcu: Making sdut and tsa defaults when passing xo to light.exe
AaronSte: Adding more CSIDL values to WixQueryOsDirs custom action
RobMen: Reverse integrate WiX v2 CustomAction fixes.
BobArnso: Add element-extensibility points to Directory and DirectoryRef.
Jordanf: Add a new test for preprocessor .
Mikeho: Add NewFolder UIText element.
AaronSte: Adding custom actions to run devenv.exe /InstallVSTemplates to the
WixVSExtension
BobArnso: Pass directory ID to Directory and DirectoryRef extension elements.
RobMen: Introducing smart-cabbing.
RobMen: SFBUG:1707259 - fix nasty memory violation
HeathS: Added patch-specific property to identify client patches and
if they can be removed.
Mikeho: Fix manifests for setupbld.exe/setup.exe
JordanF: Add the -update option to automatically update a test. Make MSI/MSI
validation explicit in the tests.
JRock: Adding back project references to Votive V3! Actually, I'm adding them
to the wix.targets MSBuild file to be exact. Votive uses it, but you get
the goodness without using Votive also. Basically, this is the feature
where if you reference other projects in your Visual Studio solution,
you can reference the output of those projects from within your wixproj
project. For example, $(var.MyCSharpApp.TargetPath). This will work for
any managed project in Visual Studio (at least it does for VC#, VB, and
VC++ managed). You have to build from within Visual Studio or from the
command line. If you build just the .wixproj, then you won't get the
project variables defined.
SFBUG:1585281 - Add solution and project variables back to Votive v3
MikeHo: Fix support for more than 10 MSIs/MSTs
JRock: SFBUG:1588291 - Support response files for MSBuild candle/light/lit
tasks
BobArnso: Have heat generate a default ComponentGroup when harvesting
directories in a fragment.
JRock: SFBUG:1717966 - Solution Build Issues (build 2911)
When a wixproj is the only thing in the solution, the SolutionX
variables aren't defined when building within Visual Studio. This
is because normally C#/VB define these variables for us. The fix
is to define them ourself.
HeathS: SFBUG:1716160 - ICE03 string overflow error, xmlFile
RobMen: SFBUG:1716160 - fix string overflow error for XmlConfig
BrianRe: Fixing wix.xsd to use W3C recognized regular expressions.
PMarcu: Defaulting Media\@Source to a form of the patchId if not specified
when Media is a child of a patch.
RobMen: SFBUG:1724535 - correctly integrate a few more fixes from WiX v2 to
WiX v3.
JordanF: WixUnit now compares the transforms inside a patch when it is diffing
two patches. Previously, only the tables in the patch were compared.
AaronSte: Added documentation for properties and custom actions in the
WixVSExtension.
PMarcu: Fix for ServiceConfig CA's to call correct rollback entrypoint.
BMurri: Add support for bound wixouts/wixmsts to torch and pyro.
PMarcu: Fix for ServiceConfig CA's to call correct rollback entrypoint.
RobMen: Schema tweaks to enable simple references on FeatureRef and
FeatureGroupRef plus tweaks to enable floating Components.
AaronSte: Added documentation for Votive functionality.
AaronSte: Fixing variable resolution problem in WiX Product item template
in Votive.
PMarcu: Updating flags in XmlConfig to match with CA after the 2.0 to
3.0 integration.
JRock: Integrated the VS SDK 4.0 into Votive.
AaronSte: Merged WiX 2.0 documentation changes into 3.0. Updated instances
of deprecated src attributes in examples in the docs.
MikeHo: Add reinstall support & logging to Chainer + fix bug when using
transforms other than Chinese.
HeathS: SFBUG:1739868 - Pyro does not find .AllowRemoval property
PMarcu: Removing primary key from EnsureTable to support patching.
Fixing documentation for XmlConfig.
RobMen: SFBUG:1739194 - Preserve whitespace when using XmlFile or XmlConfig
JKuhne: Fix a GC related bug in the cab enumeration callback. (Cab.WixEnumerateCab.Enumerate)
--- NEW FILE: CompareUnit.cs ---
//-------------------------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// The use and distribution terms for this software are covered by the
// Common Public License 1.0 (http://opensource.org/licenses/cpl.php)
// which can be found in the file CPL.TXT at the root of this distribution.
// By using this software in any fashion, you are agreeing to be bound by
// the terms of this license.
//
// You must not remove this notice, or any other, from this software.
//
//
//
// Compares to results files as part of a Windows Installer XML WixUnit test.
//
//-------------------------------------------------------------------------------------------------
namespace Microsoft.Tools.WindowsInstallerXml.Unit
{
using System;
using System.Collections;
using System.Globalization;
using System.IO;
using System.Text;
using System.Xml;
using Microsoft.Tools.WindowsInstallerXml.Unit;
///
/// Compares to results files as part of a Windows Installer XML WixUnit test.
///
internal class CompareUnit
{
///
/// Private constructor to prevent instantiation of static class.
///
private CompareUnit()
{
}
///
/// Run a Compare unit test.
///
/// The unit test element.
/// The previous unit test results.
/// Indicates whether to give the user the option to fix a failing test.
public static void RunUnitTest(XmlElement element, UnitResults previousUnitResults, bool update)
{
string file1 = Environment.ExpandEnvironmentVariables(element.GetAttribute("File1"));
string file2 = Environment.ExpandEnvironmentVariables(element.GetAttribute("File2"));
string testName = element.ParentNode.Attributes["Name"].Value;
// Check the results
ArrayList differences = CompareUnit.CompareResults(file1, file2, testName, update);
previousUnitResults.Errors.AddRange(differences);
previousUnitResults.Output.AddRange(differences);
}
///
/// Compare two result files and update the expected result if specified
///
/// The expected result file.
/// The actual result file.
/// The name of the test.
/// If true, update the expected result with the actual result.
/// Any differences found
public static ArrayList CompareResults(string expectedResult, string actualResult, string testName, bool update)
{
ArrayList differences = CompareUnit.CompareResults(expectedResult, actualResult);
// Update the test
if (0 < differences.Count && update)
{
bool isUpdated = CompareUnit.UpdateTest(expectedResult, actualResult, testName, differences);
if (isUpdated)
{
// CompareResults again to verify that there are now no differences
differences = CompareResults(expectedResult, actualResult);
}
}
return differences;
}
///
/// Compare two result files.
///
/// The expected result file.
/// The actual result file.
/// Any differences found.
public static ArrayList CompareResults(string expectedResult, string actualResult)
{
ArrayList differences = new ArrayList();
Output targetOutput;
Output updatedOutput;
OutputType outputType;
string extension = Path.GetExtension(expectedResult);
if (String.Compare(extension, ".msi", true, CultureInfo.InvariantCulture) == 0)
{
outputType = OutputType.Product;
}
else if (String.Compare(extension, ".msm", true, CultureInfo.InvariantCulture) == 0)
{
outputType = OutputType.Module;
}
else if (String.Compare(extension, ".msp", true, CultureInfo.InvariantCulture) == 0)
{
outputType = OutputType.Patch;
}
else if (String.Compare(extension, ".mst", true, CultureInfo.InvariantCulture) == 0)
{
outputType = OutputType.Transform;
}
else if (String.Compare(extension, ".pcp", true, CultureInfo.InvariantCulture) == 0)
{
outputType = OutputType.PatchCreation;
}
else if (String.Compare(extension, ".wixout", true, CultureInfo.InvariantCulture) == 0)
{
outputType = OutputType.Unknown;
}
else
{
throw new InvalidOperationException(String.Format(CultureInfo.InvariantCulture, "Cannot determine the type of msi database file based on file extension '{0}'.", extension));
}
if (outputType != OutputType.Unknown)
{
Unbinder unbinder = new Unbinder();
unbinder.SuppressDemodularization = true;
targetOutput = unbinder.Unbind(expectedResult, outputType, null);
updatedOutput = unbinder.Unbind(actualResult, outputType, null);
}
else
{
targetOutput = Output.Load(expectedResult, false, false);
updatedOutput = Output.Load(actualResult, false, false);
}
differences.AddRange(CompareOutput(targetOutput, updatedOutput));
// If the Output type is a Patch, then compare the patch's transforms
if (outputType == OutputType.Patch)
{
// Compare transforms
foreach (SubStorage targetTransform in targetOutput.SubStorages)
{
SubStorage updatedTransform = null;
// Find the same transform in the other patch
foreach (SubStorage transform in updatedOutput.SubStorages)
{
if (transform.Name == targetTransform.Name)
{
updatedTransform = transform;
break;
}
}
if (null != updatedTransform)
{
// Both patch's have this transform
ArrayList transformDifferences = CompareUnit.CompareOutput(targetTransform.Data, updatedTransform.Data);
// add a description of the transforms being compared
if (0 < transformDifferences.Count)
{
transformDifferences.Insert(0, String.Concat("Differences found while comparing the transform ", targetTransform.Name, " from the two patches"));
differences.AddRange(transformDifferences);
}
}
else
{
differences.Add(String.Format("The {0} tranform has been dropped", targetTransform.Name));
}
}
// Check if the updated patch has had transforms added
foreach (SubStorage updatedTransform in updatedOutput.SubStorages)
{
SubStorage targetTransform = null;
foreach (SubStorage transform in targetOutput.SubStorages)
{
if (transform.Name == updatedTransform.Name)
{
targetTransform = transform;
break;
}
}
if (targetTransform == null)
{
differences.Add(String.Format("The {0} tranform has been added", updatedTransform.Name));
}
}
}
// add a description of the files being compared
if (0 < differences.Count)
{
differences.Insert(0, "Differences found while comparing:");
differences.Insert(1, expectedResult);
differences.Insert(2, actualResult);
}
return differences;
}
///
/// Compare two Outputs
///
///
///
/// Any differences found.
private static ArrayList CompareOutput(Output targetOutput, Output updatedOutput)
{
ArrayList differences = new ArrayList();
Differ differ = new Differ();
differ.SuppressKeepingSpecialRows = true;
Output transform = differ.Diff(targetOutput, updatedOutput);
foreach (Table table in transform.Tables)
{
switch (table.Operation)
{
case TableOperation.Add:
differences.Add(String.Format(CultureInfo.InvariantCulture, "The {0} table has been added.", table.Name));
break;
case TableOperation.Drop:
differences.Add(String.Format(CultureInfo.InvariantCulture, "The {0} table has been dropped.", table.Name));
continue;
}
// index the target rows for better error messages
Hashtable targetRows = new Hashtable();
Table targetTable = targetOutput.Tables[table.Name];
if (null != targetTable)
{
foreach (Row row in targetTable.Rows)
{
string primaryKey = row.GetPrimaryKey('/');
// only index rows with primary keys since these are the ones that can be modified
if (null != primaryKey)
{
targetRows.Add(primaryKey, row);
}
}
}
foreach (Row row in table.Rows)
{
switch (row.Operation)
{
case RowOperation.Add:
differences.Add(String.Format(CultureInfo.InvariantCulture, "The {0} table, row '{1}' has been added.", table.Name, row.ToString()));
break;
case RowOperation.Delete:
differences.Add(String.Format(CultureInfo.InvariantCulture, "The {0} table, row '{1}' has been deleted.", table.Name, row.ToString()));
break;
case RowOperation.Modify:
if (("_SummaryInformation" != table.Name || (9 != (int)row[0] && 12 != (int)row[0] && 13 != (int)row[0] && 18 != (int)row[0])) &&
("Property" != table.Name || "ProductCode" != (string)row[0]))
{
string primaryKey = row.GetPrimaryKey('/');
Row targetRow = (Row)targetRows[primaryKey];
differences.Add(String.Format(CultureInfo.InvariantCulture, "The {0} table, row '{1}' has changed to '{2}'.", table.Name, targetRow.ToString(), row.ToString()));
}
break;
default:
throw new InvalidOperationException("Unknown diff row.");
}
}
}
return differences;
}
///
/// Fix a failed test by replacing the expected file with the actual file
///
/// The expected file
/// The actual file
/// The test name
/// The list of differences between to files
/// True if the user chose to update the test, false otherwise
private static bool UpdateTest(string expectedFile, string actualFile, string testName, ArrayList differences)
{
Console.WriteLine();
Console.WriteLine(String.Concat("Test Name: ", testName));
// Print the differences that were found
foreach (string line in differences)
{
Console.WriteLine(line);
}
Console.WriteLine();
Console.Write("Do you wish to update the test to use the actual file '{0}' as the expected '{1}' (y/n)? ", actualFile, expectedFile);
string answer = Console.ReadLine();
if (answer.Equals("y", StringComparison.InvariantCultureIgnoreCase) || answer.Equals("yes", StringComparison.InvariantCultureIgnoreCase))
{
// sd edit the expected file
ArrayList output = ToolUtility.RunTool("sd.exe", String.Concat("edit ", expectedFile));
// Print the sd edit output
foreach (string line in output)
{
Console.WriteLine(line);
}
File.Copy(actualFile, expectedFile, true);
return true;
}
else
{
Console.WriteLine("The test was not updated");
return false;
}
}
}
}
Index: WixUnit.cs
===================================================================
RCS file: /cvsroot/wix/wix/src/WixUnit/WixUnit.cs,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** WixUnit.cs 16 Feb 2007 09:35:04 -0000 1.4
--- WixUnit.cs 27 Jun 2007 05:35:50 -0000 1.5
***************
*** 30,33 ****
--- 30,34 ----
using System.Xml;
using System.Xml.Schema;
+ using System.Xml.Serialization;
using Microsoft.Tools.WindowsInstallerXml;
***************
*** 39,42 ****
--- 40,44 ----
{
private const string XmlNamespace = "http://schemas.microsoft.com/wix/2006/WixUnit";
+ private readonly string failedTestsFile = Path.Combine(Path.GetTempPath(), "WixUnitFailedTests.xml");
private object lockObject = new object();
***************
*** 44,48 ****
private int completedUnitTests;
! private int failedUnitTests;
private int totalUnitTests;
--- 46,50 ----
private int completedUnitTests;
! private Dictionary failedUnitTests = new Dictionary();
private int totalUnitTests;
***************
*** 50,58 ****
--- 52,63 ----
private List environmentVariables = new List();
private bool noTidy;
+ private bool rerunFailedTests = false;
private bool showHelp;
+ private bool singleThreaded = false;
private TempFileCollection tempFileCollection;
private Queue unitTestElements = new Queue();
private ArrayList unitTests = new ArrayList();
private string unitTestsFile;
+ private bool updateTests;
private bool validate;
private bool verbose;
***************
*** 133,137 ****
--- 138,145 ----
Console.WriteLine(" -env:= Sets an environment variable to the value for the current process");
Console.WriteLine(" -notidy Do not delete temporary files (for checking results)");
+ Console.WriteLine(" -rf Re-run the failed test from the last run");
+ Console.WriteLine(" -st Run the tests on a single thread");
Console.WriteLine(" -test: Run only the specified test (may use wildcards)");
+ Console.WriteLine(" -update Prompt user to auto-update a test if expected and actual output files do not match");
Console.WriteLine(" -v Verbose output");
Console.WriteLine(" -val Run MSI validation for light unit tests");
***************
*** 232,239 ****
{
this.totalUnitTests = this.unitTestElements.Count;
- // create a thread for each processor
- int numberOfProcessors = Convert.ToInt32(Environment.GetEnvironmentVariable("NUMBER_OF_PROCESSORS"), CultureInfo.InvariantCulture);
- Thread[] threads = new Thread[numberOfProcessors];
for (int i = 0; i < threads.Length; i++)
{
--- 240,259 ----
{
this.totalUnitTests = this.unitTestElements.Count;
+ int numThreads;
+
+ if (this.updateTests || this.singleThreaded)
+ {
+ // If the tests are running with the -update switch, they must run on one thread
+ // so that all execution is paused when the user is prompted to update a test.
+ numThreads = 1;
+ }
+ else
+ {
+ // create a thread for each processor
+ numThreads = Convert.ToInt32(Environment.GetEnvironmentVariable("NUMBER_OF_PROCESSORS"), CultureInfo.InvariantCulture);
+ }
+
+ Thread[] threads = new Thread[numThreads];
for (int i = 0; i < threads.Length; i++)
{
***************
*** 251,257 ****
Console.WriteLine();
int elapsedTime = (Environment.TickCount - beginTickCount) / 1000;
! if (this.failedUnitTests > 0)
{
! Console.WriteLine("Failed {0} out of {1} unit test{2} ({3} seconds).", this.failedUnitTests, this.totalUnitTests, (1 != this.completedUnitTests ? "s" : ""), elapsedTime);
}
else
--- 271,298 ----
Console.WriteLine();
int elapsedTime = (Environment.TickCount - beginTickCount) / 1000;
! if (0 < this.failedUnitTests.Count)
{
! Console.WriteLine("Summary of failed tests:");
! Console.WriteLine();
!
! // Put the failed tests into an ArrayList, which will get serialized
! ArrayList serializedFailedTests = new ArrayList();
! foreach (string failedTest in this.failedUnitTests.Keys)
! {
! serializedFailedTests.Add(failedTest);
! Console.WriteLine("{0}. {1}", this.failedUnitTests[failedTest], failedTest);
! }
!
! Console.WriteLine();
! Console.WriteLine("Re-run the failed tests with the -rf option");
! Console.WriteLine();
! Console.WriteLine("Failed {0} out of {1} unit test{2} ({3} seconds).", this.failedUnitTests.Count, this.totalUnitTests, (1 != this.completedUnitTests ? "s" : ""), elapsedTime);
!
! using (XmlWriter writer = XmlWriter.Create(this.failedTestsFile))
! {
! XmlSerializer serializer = new XmlSerializer(serializedFailedTests.GetType());
! serializer.Serialize(writer, serializedFailedTests);
! writer.Close();
! }
}
else
***************
*** 401,404 ****
--- 442,448 ----
CandleUnit.RunUnitTest(unitElement, unitResults);
break;
+ case "Compare":
+ CompareUnit.RunUnitTest(unitElement, unitResults, this.updateTests);
+ break;
case "Dark":
DarkUnit.RunUnitTest(unitElement, unitResults);
***************
*** 408,428 ****
break;
case "Light":
! // disable MSI validation if it hasn't been enabled or this isn't the final Light test
! if (!this.validate || (null != unitElement.NextSibling && "WixProj" != unitElement.NextSibling.Name))
{
! unitElement.SetAttribute("Arguments", String.Concat(unitElement.GetAttribute("Arguments"), " -sval"));
}
! LightUnit.RunUnitTest(unitElement, unitResults);
break;
case "Lit":
LitUnit.RunUnitTest(unitElement, unitResults);
break;
case "Torch":
! TorchUnit.RunUnitTest(unitElement, unitResults);
break;
case "WixProj":
bool skipValidation = (!this.validate);
! WixProjUnit.RunUnitTest(unitElement, unitResults, this.verbose, skipValidation);
break;
}
--- 452,482 ----
break;
case "Light":
! // If WixUnit was not run with -val then suppress MSI validation
! if (!this.validate && ("true" != unitElement.GetAttribute("ForceValidation")))
{
! string arguments = unitElement.GetAttribute("Arguments");
! if (!arguments.Contains("-sval"))
! {
! unitElement.SetAttribute("Arguments", String.Concat(arguments, " -sval"));
! }
}
! LightUnit.RunUnitTest(unitElement, unitResults, this.updateTests);
break;
case "Lit":
LitUnit.RunUnitTest(unitElement, unitResults);
break;
+ case "Process":
+ ProcessUnit.RunUnitTest(unitElement, unitResults);
+ break;
+ case "Pyro":
+ PyroUnit.RunUnitTest(unitElement, unitResults, this.updateTests);
+ break;
case "Torch":
! TorchUnit.RunUnitTest(unitElement, unitResults, this.updateTests);
break;
case "WixProj":
bool skipValidation = (!this.validate);
! WixProjUnit.RunUnitTest(unitElement, unitResults, this.verbose, skipValidation, this.updateTests);
break;
}
***************
*** 463,467 ****
if (unitResults.Errors.Count > 0)
{
! failedUnitTests++;
Console.WriteLine("Failed");
--- 517,522 ----
if (unitResults.Errors.Count > 0)
{
! this.failedUnitTests.Add(name, this.completedUnitTests);
!
Console.WriteLine("Failed");
***************
*** 536,543 ****
--- 591,645 ----
this.noTidy = true;
}
+ else if ("rf" == parameter)
+ {
+ this.rerunFailedTests = true;
+ ArrayList previouslyFailedTests = null;
+
+ if (File.Exists(this.failedTestsFile))
+ {
+ XmlReader reader = null;
+
+ try
+ {
+ reader = XmlReader.Create(this.failedTestsFile);
+ XmlSerializer serializer = new XmlSerializer(typeof(ArrayList));
+ previouslyFailedTests = (ArrayList)serializer.Deserialize(reader);
+ }
+ catch (InvalidOperationException e)
+ {
+ Console.WriteLine(String.Concat("There was an error loading the failed tests from ", this.failedTestsFile));
+ Console.WriteLine(e.Message);
+ }
+ finally
+ {
+ if (null != reader)
+ {
+ reader.Close();
+ }
+
+ if (File.Exists(this.failedTestsFile))
+ {
+ File.Delete(this.failedTestsFile);
+ }
+ }
+ }
+
+ if (null != previouslyFailedTests)
+ {
+ this.unitTests.AddRange(previouslyFailedTests);
+ }
+ }
+ else if ("st" == parameter)
+ {
+ this.singleThreaded = true;
+ }
else if (parameter.StartsWith("test:"))
{
this.unitTests.Add(parameter.Substring(5));
}
+ else if ("update" == parameter)
+ {
+ this.updateTests = true;
+ }
else if ("v" == parameter)
{
***************
*** 553,557 ****
}
}
! else if (this.unitTestsFile == null)
{
this.unitTestsFile = arg;
--- 655,659 ----
}
}
! else if (null == this.unitTestsFile)
{
this.unitTestsFile = arg;
***************
*** 564,575 ****
// no individual unit tests were selected, so match all unit tests
! if (this.unitTests.Count == 0)
{
this.unitTests.Add(".*");
}
- else // ensure validation is on if tests were selected
- {
- this.validate = true;
- }
}
}
--- 666,673 ----
// no individual unit tests were selected, so match all unit tests
! if (0 == this.unitTests.Count && !this.rerunFailedTests)
{
this.unitTests.Add(".*");
}
}
}
--- NEW FILE: PyroUnit.cs ---
//-------------------------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// The use and distribution terms for this software are covered by the
// Common Public License 1.0 (http://opensource.org/licenses/cpl.php)
// which can be found in the file CPL.TXT at the root of this distribution.
// By using this software in any fashion, you are agreeing to be bound by
// the terms of this license.
//
// You must not remove this notice, or any other, from this software.
//
//
//
// The Windows Installer XML Pyro unit tester.
//
//-------------------------------------------------------------------------------------------------
namespace Microsoft.Tools.WindowsInstallerXml.Unit
{
using System;
using System.Collections;
using System.Globalization;
using System.IO;
using System.Text;
using System.Xml;
using Microsoft.Tools.WindowsInstallerXml;
///
/// The Windows Installer XML Pyro unit tester.
///
internal sealed class PyroUnit
{
///
/// Private constructor to prevent instantiation of static class.
///
private PyroUnit()
{
}
///
/// Run a Pyro unit test.
///
/// The unit test element.
/// The previous unit test results.
/// Indicates whether to give the user the option to fix a failing test.
public static void RunUnitTest(XmlElement element, UnitResults previousUnitResults, bool update)
{
string arguments = Environment.ExpandEnvironmentVariables(element.GetAttribute("Arguments"));
string expectedErrors = element.GetAttribute("ExpectedErrors");
string expectedResult = element.GetAttribute("ExpectedResult");
string expectedWarnings = element.GetAttribute("ExpectedWarnings");
string inputFile = element.GetAttribute("InputFile");
string outputFile = element.GetAttribute("OutputFile");
string tempDirectory = element.GetAttribute("TempDirectory");
string testName = element.ParentNode.Attributes["Name"].Value;
string toolsDirectory = element.GetAttribute("ToolsDirectory");
if (null == inputFile || String.Empty == inputFile)
{
throw new WixException(WixErrors.IllegalEmptyAttributeValue(null, element.Name, "InputFile"));
}
if (null == outputFile || String.Empty == outputFile)
{
throw new WixException(WixErrors.IllegalEmptyAttributeValue(null, element.Name, "OutputFile"));
}
// After Pyro is run, verify that this file was not created
if (0 < expectedErrors.Length)
{
outputFile = "ShouldNotBeCreated.msp";
}
string toolFile = Path.Combine(toolsDirectory, "pyro.exe");
StringBuilder commandLine = new StringBuilder(arguments);
commandLine.AppendFormat("{0} -out \"{1}\"", inputFile, outputFile);
previousUnitResults.OutputFiles.Add(outputFile);
// handle child elements
foreach (XmlNode node in element.ChildNodes)
{
if (node.NodeType == XmlNodeType.Element)
{
switch (node.LocalName)
{
case "Transform":
string transformFile = Environment.ExpandEnvironmentVariables(node.Attributes["File"].Value);
string baseline = node.Attributes["Baseline"].Value;
commandLine.AppendFormat(" -t {0} \"{1}\"", baseline, transformFile);
break;
default:
break;
}
}
}
// run the tool
ArrayList output = ToolUtility.RunTool(toolFile, commandLine.ToString());
previousUnitResults.Errors.AddRange(ToolUtility.GetErrors(output, expectedErrors, expectedWarnings));
previousUnitResults.Output.AddRange(output);
// check the output file
if (0 == previousUnitResults.Errors.Count)
{
if (0 < expectedResult.Length)
{
ArrayList differences = CompareUnit.CompareResults(expectedResult, outputFile, testName, update);
previousUnitResults.Errors.AddRange(differences);
previousUnitResults.Output.AddRange(differences);
}
else if (0 < expectedErrors.Length && File.Exists(outputFile)) // ensure the output doesn't exist
{
string error = String.Format(CultureInfo.InvariantCulture, "Expected failure, but the unit test created output file \"{0}\".", outputFile);
previousUnitResults.Errors.Add(error);
previousUnitResults.Output.Add(error);
}
}
}
}
}
Index: CandleUnit.cs
===================================================================
RCS file: /cvsroot/wix/wix/src/WixUnit/CandleUnit.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** CandleUnit.cs 2 Aug 2006 11:24:41 -0000 1.1
--- CandleUnit.cs 27 Jun 2007 05:35:49 -0000 1.2
***************
*** 48,54 ****
--- 48,56 ----
string expectedWarnings = element.GetAttribute("ExpectedWarnings");
string extensions = element.GetAttribute("Extensions");
+ string outputDirectory = element.GetAttribute("OutputDirectory");
bool suppressWixCop = ("true" == element.GetAttribute("SuppressWixCop"));
string tempDirectory = element.GetAttribute("TempDirectory");
string toolsDirectory = element.GetAttribute("ToolsDirectory");
+ bool usePreviousOutput = ("true" == element.GetAttribute("UsePreviousOutput"));
string toolFile = Path.Combine(toolsDirectory, "candle.exe");
***************
*** 63,78 ****
// handle any previous outputs
! ArrayList previousWixobjFiles = new ArrayList();
! foreach (string sourceFile in previousUnitResults.OutputFiles)
{
! string wixobjFile = String.Concat(Path.GetFileNameWithoutExtension(sourceFile), ".wixobj");
! commandLine.AppendFormat(" \"{0}\"", sourceFile);
! wixCopCommandLine.AppendFormat(" \"{0}\"", sourceFile);
! previousWixobjFiles.Add(Path.Combine(tempDirectory, wixobjFile));
}
- previousUnitResults.OutputFiles.Clear();
- previousUnitResults.OutputFiles.AddRange(previousWixobjFiles);
// handle child elements
--- 65,87 ----
// handle any previous outputs
! if (usePreviousOutput)
{
! ArrayList previousWixobjFiles = new ArrayList();
! foreach (string sourceFile in previousUnitResults.OutputFiles)
! {
! string wixobjFile = String.Concat(Path.GetFileNameWithoutExtension(sourceFile), ".wixobj");
! commandLine.AppendFormat(" \"{0}\"", sourceFile);
! wixCopCommandLine.AppendFormat(" \"{0}\"", sourceFile);
! previousWixobjFiles.Add(Path.Combine(tempDirectory, wixobjFile));
! }
! previousUnitResults.OutputFiles.Clear();
! previousUnitResults.OutputFiles.AddRange(previousWixobjFiles);
! }
! else
! {
! previousUnitResults.OutputFiles.Clear();
}
// handle child elements
***************
*** 96,100 ****
}
! commandLine.AppendFormat(" -out \"{0}{1}\\\"", tempDirectory, Path.DirectorySeparatorChar);
// run WixCop if it hasn't been suppressed
--- 105,114 ----
}
! // If the output directory is not set, set it to the temp directory.
! if (null == outputDirectory || String.Empty == outputDirectory)
! {
! outputDirectory = tempDirectory;
! }
! commandLine.AppendFormat(" -out \"{0}{1}\\\"", outputDirectory, Path.DirectorySeparatorChar);
// run WixCop if it hasn't been suppressed
Index: TorchUnit.cs
===================================================================
RCS file: /cvsroot/wix/wix/src/WixUnit/TorchUnit.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** TorchUnit.cs 13 Sep 2006 08:13:22 -0000 1.1
--- TorchUnit.cs 27 Jun 2007 05:35:50 -0000 1.2
***************
*** 44,56 ****
/// The unit test element.
/// The previous unit test results.
! public static void RunUnitTest(XmlElement element, UnitResults previousUnitResults)
{
string arguments = element.GetAttribute("Arguments");
string expectedErrors = element.GetAttribute("ExpectedErrors");
string expectedWarnings = element.GetAttribute("ExpectedWarnings");
string targetDatabase = element.GetAttribute("TargetDatabase");
string tempDirectory = element.GetAttribute("TempDirectory");
string toolsDirectory = element.GetAttribute("ToolsDirectory");
string updatedDatabase = element.GetAttribute("UpdatedDatabase");
string toolFile = Path.Combine(toolsDirectory, "torch.exe");
--- 44,61 ----
/// The unit test element.
/// The previous unit test results.
! /// Indicates whether to give the user the option to fix a failing test.
! public static void RunUnitTest(XmlElement element, UnitResults previousUnitResults, bool update)
{
string arguments = element.GetAttribute("Arguments");
string expectedErrors = element.GetAttribute("ExpectedErrors");
string expectedWarnings = element.GetAttribute("ExpectedWarnings");
+ string outputFile = element.GetAttribute("OutputFile");
string targetDatabase = element.GetAttribute("TargetDatabase");
string tempDirectory = element.GetAttribute("TempDirectory");
+ string testName = element.ParentNode.Attributes["Name"].Value;
string toolsDirectory = element.GetAttribute("ToolsDirectory");
string updatedDatabase = element.GetAttribute("UpdatedDatabase");
+ bool usePreviousOutput = ("true" == element.GetAttribute("UsePreviousOutput"));
+ bool verifyTransform = ("true" == element.GetAttribute("VerifyTransform"));
string toolFile = Path.Combine(toolsDirectory, "torch.exe");
***************
*** 58,62 ****
// handle any previous outputs
! if (0 < previousUnitResults.OutputFiles.Count)
{
commandLine.AppendFormat(" \"{0}\"", previousUnitResults.OutputFiles[0]);
--- 63,67 ----
// handle any previous outputs
! if (0 < previousUnitResults.OutputFiles.Count && usePreviousOutput)
{
commandLine.AppendFormat(" \"{0}\"", previousUnitResults.OutputFiles[0]);
***************
*** 68,72 ****
}
! string outputFile = Path.Combine(tempDirectory, "transform.mst");
commandLine.AppendFormat(" -out \"{0}\"", outputFile);
previousUnitResults.OutputFiles.Add(outputFile);
--- 73,81 ----
}
!
! if (null == outputFile || String.Empty == outputFile)
! {
! outputFile = Path.Combine(tempDirectory, "transform.mst");
! }
commandLine.AppendFormat(" -out \"{0}\"", outputFile);
previousUnitResults.OutputFiles.Add(outputFile);
***************
*** 78,82 ****
// check the results
! if (previousUnitResults.Errors.Count == 0)
{
string actualDatabase = Path.Combine(tempDirectory, String.Concat(Guid.NewGuid(), ".msi"));
--- 87,91 ----
// check the results
! if (previousUnitResults.Errors.Count == 0 && verifyTransform)
{
string actualDatabase = Path.Combine(tempDirectory, String.Concat(Guid.NewGuid(), ".msi"));
***************
*** 91,95 ****
// check the output file
! ArrayList differences = LightUnit.CompareResults(updatedDatabase, actualDatabase);
previousUnitResults.Errors.AddRange(differences);
previousUnitResults.Output.AddRange(differences);
--- 100,104 ----
// check the output file
! ArrayList differences = CompareUnit.CompareResults(updatedDatabase, actualDatabase, testName, update);
previousUnitResults.Errors.AddRange(differences);
previousUnitResults.Output.AddRange(differences);
Index: LightUnit.cs
===================================================================
RCS file: /cvsroot/wix/wix/src/WixUnit/LightUnit.cs,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** LightUnit.cs 13 Sep 2006 08:13:22 -0000 1.3
--- LightUnit.cs 27 Jun 2007 05:35:50 -0000 1.4
***************
*** 45,49 ****
/// The unit test element.
/// The previous unit test results.
! public static void RunUnitTest(XmlElement element, UnitResults previousUnitResults)
{
string arguments = Environment.ExpandEnvironmentVariables(element.GetAttribute("Arguments"));
--- 45,50 ----
/// The unit test element.
/// The previous unit test results.
! /// Indicates whether to give the user the option to fix a failing test.
! public static void RunUnitTest(XmlElement element, UnitResults previousUnitResults, bool update)
{
string arguments = Environment.ExpandEnvironmentVariables(element.GetAttribute("Arguments"));
***************
*** 52,69 ****
string expectedWarnings = element.GetAttribute("ExpectedWarnings");
string extensions = element.GetAttribute("Extensions");
string intermediateOutputType = element.GetAttribute("IntermediateOutputType");
string suppressExtensions = element.GetAttribute("SuppressExtensions");
string tempDirectory = element.GetAttribute("TempDirectory");
string toolsDirectory = element.GetAttribute("ToolsDirectory");
! if (expectedErrors.Length == 0 && expectedResult.Length == 0 && intermediateOutputType.Length == 0)
{
! throw new WixException(WixErrors.ExpectedAttributes(null, element.Name, "ExpectedErrors", "ExpectedResult", "IntermediateOutputType"));
}
! if (expectedErrors.Length > 0 && (expectedResult.Length > 0 || intermediateOutputType.Length > 0) ||
! (expectedResult.Length > 0 && intermediateOutputType.Length > 0))
{
! throw new WixException(WixErrors.IllegalAttributeWithOtherAttributes(null, element.Name, "ExpectedErrors", "ExpectedResult", "IntermediateOutputType"));
}
--- 53,80 ----
string expectedWarnings = element.GetAttribute("ExpectedWarnings");
string extensions = element.GetAttribute("Extensions");
+ string outputFile = element.GetAttribute("OutputFile");
string intermediateOutputType = element.GetAttribute("IntermediateOutputType");
string suppressExtensions = element.GetAttribute("SuppressExtensions");
string tempDirectory = element.GetAttribute("TempDirectory");
+ string testName = element.ParentNode.Attributes["Name"].Value;
string toolsDirectory = element.GetAttribute("ToolsDirectory");
+ bool usePreviousOutput = ("true" == element.GetAttribute("UsePreviousOutput"));
! if (expectedErrors.Length == 0 && expectedResult.Length == 0 && intermediateOutputType.Length == 0 && outputFile.Length == 0)
{
! throw new WixException(WixErrors.ExpectedAttributes(null, element.Name, "ExpectedErrors", "ExpectedResult", "IntermediateOutputType", "OutputFile", null));
}
! if (expectedErrors.Length > 0 && (expectedResult.Length > 0 || intermediateOutputType.Length > 0 || outputFile.Length > 0))
{
! throw new WixException(WixErrors.IllegalAttributeWithOtherAttributes(null, element.Name, "ExpectedErrors", "ExpectedResult", "IntermediateOutputType", "OutputFile", null));
! }
! else if (expectedResult.Length > 0 && (intermediateOutputType.Length > 0 || outputFile.Length > 0))
! {
! throw new WixException(WixErrors.IllegalAttributeWithOtherAttributes(null, element.Name, "ExpectedResult", "IntermediateOutputType", "OutputFile"));
! }
! else if (intermediateOutputType.Length > 0 && outputFile.Length > 0)
! {
! throw new WixException(WixErrors.IllegalAttributeWithOtherAttributes(null, element.Name, "IntermediateOutputType", "OutputFile", null));
}
***************
*** 82,88 ****
// handle any previous outputs
! foreach (string inputFile in previousUnitResults.OutputFiles)
{
! commandLine.AppendFormat(" \"{0}\"", inputFile);
}
previousUnitResults.OutputFiles.Clear();
--- 93,102 ----
// handle any previous outputs
! if (usePreviousOutput)
{
! foreach (string inputFile in previousUnitResults.OutputFiles)
! {
! commandLine.AppendFormat(" \"{0}\"", inputFile);
! }
}
previousUnitResults.OutputFiles.Clear();
***************
*** 109,114 ****
}
! string outputFile;
! if (expectedResult.Length > 0)
{
outputFile = Path.Combine(tempDirectory, Path.GetFileName(expectedResult));
--- 123,131 ----
}
! if (outputFile.Length > 0)
! {
! // outputFile has been explicitly set
! }
! else if (expectedResult.Length > 0)
{
outputFile = Path.Combine(tempDirectory, Path.GetFileName(expectedResult));
***************
*** 137,141 ****
if (expectedResult.Length > 0)
{
! ArrayList differences = CompareResults(expectedResult, outputFile);
previousUnitResults.Errors.AddRange(differences);
--- 154,158 ----
if (expectedResult.Length > 0)
{
! ArrayList differences = CompareUnit.CompareResults(expectedResult, outputFile, testName, update);
previousUnitResults.Errors.AddRange(differences);
***************
*** 151,281 ****
}
}
-
- ///
- /// Compare two result files.
- ///
- /// The expected result file.
- /// The actual result file.
- /// Any differences found.
- public static ArrayList CompareResults(string expectedResult, string actualResult)
- {
- ArrayList differences = new ArrayList();
- Output targetOutput;
- Output updatedOutput;
-
- OutputType outputType;
- string extension = Path.GetExtension(expectedResult);
- if (String.Compare(extension, ".msi", true, CultureInfo.InvariantCulture) == 0)
- {
- outputType = OutputType.Product;
- }
- else if (String.Compare(extension, ".msm", true, CultureInfo.InvariantCulture) == 0)
- {
- outputType = OutputType.Module;
- }
- else if (String.Compare(extension, ".msp", true, CultureInfo.InvariantCulture) == 0)
- {
- outputType = OutputType.Patch;
- }
- else if (String.Compare(extension, ".mst", true, CultureInfo.InvariantCulture) == 0)
- {
- outputType = OutputType.Transform;
- }
- else if (String.Compare(extension, ".pcp", true, CultureInfo.InvariantCulture) == 0)
- {
- outputType = OutputType.PatchCreation;
- }
- else if (String.Compare(extension, ".wixout", true, CultureInfo.InvariantCulture) == 0)
- {
- outputType = OutputType.Unknown;
- }
- else
- {
- throw new InvalidOperationException(String.Format(CultureInfo.InvariantCulture, "Cannot determine the type of msi database file based on file extension '{0}'.", extension));
- }
-
- if (outputType != OutputType.Unknown)
- {
- Unbinder unbinder = new Unbinder();
- unbinder.SuppressDemodularization = true;
-
- targetOutput = unbinder.Unbind(expectedResult, outputType, null);
- updatedOutput = unbinder.Unbind(actualResult, outputType, null);
- }
- else
- {
- targetOutput = Output.Load(expectedResult, false, false);
- updatedOutput = Output.Load(actualResult, false, false);
- }
-
- Differ differ = new Differ();
- differ.SuppressKeepingSpecialRows = true;
- Output transform = differ.Diff(targetOutput, updatedOutput);
-
- foreach (Table table in transform.Tables)
- {
- switch (table.Operation)
- {
- case TableOperation.Add:
- differences.Add(String.Format(CultureInfo.InvariantCulture, "The {0} table has been added.", table.Name));
- break;
- case TableOperation.Drop:
- differences.Add(String.Format(CultureInfo.InvariantCulture, "The {0} table has been dropped.", table.Name));
- continue;
- }
-
- // index the target rows for better error messages
- Hashtable targetRows = new Hashtable();
- Table targetTable = targetOutput.Tables[table.Name];
- if (null != targetTable)
- {
- foreach (Row row in targetTable.Rows)
- {
- string primaryKey = row.GetPrimaryKey('/');
-
- // only index rows with primary keys since these are the ones that can be modified
- if (null != primaryKey)
- {
- targetRows.Add(primaryKey, row);
- }
- }
- }
-
- foreach (Row row in table.Rows)
- {
- switch (row.Operation)
- {
- case RowOperation.Add:
- differences.Add(String.Format(CultureInfo.InvariantCulture, "The {0} table, row '{1}' has been added.", table.Name, row.ToString()));
- break;
- case RowOperation.Delete:
- differences.Add(String.Format(CultureInfo.InvariantCulture, "The {0} table, row '{1}' has been deleted.", table.Name, row.ToString()));
- break;
- case RowOperation.Modify:
- if (("_SummaryInformation" != table.Name || (9 != (int)row[0] && 12 != (int)row[0] && 13 != (int)row[0] && 18 != (int)row[0])) &&
- ("Property" != table.Name || "ProductCode" != (string)row[0]))
- {
- string primaryKey = row.GetPrimaryKey('/');
- Row targetRow = (Row)targetRows[primaryKey];
-
- differences.Add(String.Format(CultureInfo.InvariantCulture, "The {0} table, row '{1}' has changed to '{2}'.", table.Name, targetRow.ToString(), row.ToString()));
- }
- break;
- default:
- throw new InvalidOperationException("Unknown diff row.");
- }
- }
- }
-
- // add a description of the files being compared
- if (0 < differences.Count)
- {
- differences.Insert(0, "Differences found while comparing:");
- differences.Insert(1, expectedResult);
- differences.Insert(2, actualResult);
- }
-
- return differences;
- }
}
}
--- 168,171 ----
Index: WixProjUnit.cs
===================================================================
RCS file: /cvsroot/wix/wix/src/WixUnit/WixProjUnit.cs,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** WixProjUnit.cs 2 Mar 2007 12:22:17 -0000 1.2
--- WixProjUnit.cs 27 Jun 2007 05:35:50 -0000 1.3
***************
*** 2,5 ****
--- 2,13 ----
//
// Copyright (c) Microsoft Corporation. All rights reserved.
+ //
+ // The use and distribution terms for this software are covered by the
+ // Common Public License 1.0 (http://opensource.org/licenses/cpl.php)
+ // which can be found in the file CPL.TXT at the root of this distribution.
+ // By using this software in any fashion, you are agreeing to be bound by
+ // the terms of this license.
+ //
+ // You must not remove this notice, or any other, from this software.
//
//
***************
*** 37,41 ****
/// The level of verbosity for the MSBuild logging.
/// Tells light to skip validation.
! public static void RunUnitTest(XmlElement element, UnitResults previousUnitResults, bool verbose, bool skipValidation)
{
string arguments = element.GetAttribute("Arguments");
--- 45,50 ----
/// The level of verbosity for the MSBuild logging.
/// Tells light to skip validation.
! /// Indicates whether to give the user the option to fix a failing test.
! public static void RunUnitTest(XmlElement element, UnitResults previousUnitResults, bool verbose, bool skipValidation, bool update)
{
string arguments = element.GetAttribute("Arguments");
***************
*** 46,51 ****
--- 55,62 ----
bool noOutputName = XmlConvert.ToBoolean(element.GetAttribute("NoOutputName"));
bool noOutputPath = XmlConvert.ToBoolean(element.GetAttribute("NoOutputPath"));
+ bool defineSolutionProperties = XmlConvert.ToBoolean(element.GetAttribute("DefineSolutionProperties"));
string suppressExtensions = element.GetAttribute("SuppressExtensions");
string tempDirectory = element.GetAttribute("TempDirectory");
+ string testName = element.ParentNode.Attributes["Name"].Value;
string toolsDirectory = element.GetAttribute("ToolsDirectory");
***************
*** 73,78 ****
}
! // handle the tools directory
! commandLine.AppendFormat(" /property:WixToolPath=\"{0}\"", toolsDirectory);
// handle extensions
--- 84,100 ----
}
! // add DefineSolutionProperties
! commandLine.AppendFormat(" /property:DefineSolutionProperties={0}", defineSolutionProperties);
!
! // make sure the tools directory ends in a single backslash
! if (toolsDirectory[toolsDirectory.Length - 1] != Path.DirectorySeparatorChar)
! {
! toolsDirectory = String.Concat(toolsDirectory, Path.DirectorySeparatorChar);
! }
!
! // handle the wix-specific directories and files
! commandLine.AppendFormat(" /property:WixToolPath=\"{0}\\\"", toolsDirectory);
! commandLine.AppendFormat(" /property:WixTargetsPath=\"{0}\"", Path.Combine(toolsDirectory, "wix.targets"));
! commandLine.AppendFormat(" /property:WixTasksPath=\"{0}\"", Path.Combine(toolsDirectory, "WixTasks.dll"));
// handle extensions
***************
*** 134,138 ****
if (expectedResult.Length > 0)
{
! ArrayList differences = LightUnit.CompareResults(expectedResult, outputFile);
previousUnitResults.Errors.AddRange(differences);
--- 156,160 ----
if (expectedResult.Length > 0)
{
! ArrayList differences = CompareUnit.CompareResults(expectedResult, outputFile, testName, update);
previousUnitResults.Errors.AddRange(differences);
Index: ToolUtility.cs
===================================================================
RCS file: /cvsroot/wix/wix/src/WixUnit/ToolUtility.cs,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** ToolUtility.cs 16 Feb 2007 09:35:03 -0000 1.3
--- ToolUtility.cs 27 Jun 2007 05:35:50 -0000 1.4
***************
*** 152,158 ****
--- 152,175 ----
public static ArrayList RunTool(string toolFile, string commandLine)
{
+ // The returnCode variable doesn't get used but it must be created to pass as an argument
+ int returnCode;
+ return ToolUtility.RunTool(toolFile, commandLine, out returnCode);
+ }
+
+ ///
+ /// Run a tool with the given file name and command line.
+ ///
+ /// The tool's file name.
+ /// The command line.
+ /// Store the return code of the process.
+ /// An ArrayList of output strings.
+ public static ArrayList RunTool(string toolFile, string commandLine, out int returnCode)
+ {
ArrayList output = new ArrayList();
Process process = null;
+ // The returnCode must get initialized outside of the try block
+ returnCode = 0;
+
try
{
***************
*** 183,186 ****
--- 200,204 ----
process.WaitForExit();
+ returnCode = process.ExitCode;
}
finally
Index: WixUnit.csproj
===================================================================
RCS file: /cvsroot/wix/wix/src/WixUnit/WixUnit.csproj,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** WixUnit.csproj 16 Feb 2007 09:35:04 -0000 1.4
--- WixUnit.csproj 27 Jun 2007 05:35:50 -0000 1.5
***************
*** 26,34 ****
--- 26,37 ----
+
+
+
--- NEW FILE: ProcessUnit.cs ---
//-------------------------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// The use and distribution terms for this software are covered by the
// Common Public License 1.0 (http://opensource.org/licenses/cpl.php)
// which can be found in the file CPL.TXT at the root of this distribution.
// By using this software in any fashion, you are agreeing to be bound by
// the terms of this license.
//
// You must not remove this notice, or any other, from this software.
//
//
//
// Runs a process as part of a Windows Installer XML WixUnit test.
//
//-------------------------------------------------------------------------------------------------
namespace Microsoft.Tools.WindowsInstallerXml.Unit
{
using System;
using System.Collections;
using System.IO;
using System.Text;
using System.Xml;
using Microsoft.Tools.WindowsInstallerXml.Unit;
///
/// Runs a process as a Windows Installer XML WixUnit test.
///
internal class ProcessUnit
{
///
/// Private constructor to prevent instantiation of static class.
///
private ProcessUnit()
{
}
///
/// Run a Process unit test.
///
/// The unit test element.
/// The previous unit test results.
public static void RunUnitTest(XmlElement element, UnitResults previousUnitResults)
{
string arguments = element.GetAttribute("Arguments");
string executable = Environment.ExpandEnvironmentVariables(element.GetAttribute("Executable"));
string expectedReturnCode = element.GetAttribute("ExpectedReturnCode");
string workingDirectory = element.GetAttribute("WorkingDirectory");
bool compareReturnCodes = false;
// Check if an ExpectedReturnCode was set
if (null != expectedReturnCode && String.Empty != expectedReturnCode)
{
compareReturnCodes = true;
}
// Set the current working directory if one was specified
string currentDirectory = Environment.CurrentDirectory;
if (null != workingDirectory && String.Empty != workingDirectory)
{
Environment.CurrentDirectory = workingDirectory;
}
// Run the process
int actualReturnCode;
ArrayList output = ToolUtility.RunTool(executable, arguments, out actualReturnCode);
Environment.CurrentDirectory = currentDirectory;
previousUnitResults.Output.AddRange(output);
// Check the results
if (compareReturnCodes)
{
if (actualReturnCode == Convert.ToInt32(expectedReturnCode))
{
previousUnitResults.Output.Add(String.Format("Actual return code {0} matched expected return code {1}", actualReturnCode, expectedReturnCode));
}
else
{
previousUnitResults.Errors.Add(String.Format("Actual return code {0} did not match expected return code {1}", actualReturnCode, expectedReturnCode));
previousUnitResults.Output.Add(String.Format("Actual return code {0} did not match expected return code {1}", actualReturnCode, expectedReturnCode));
}
}
}
}
}
Index: unitTests.xsd
===================================================================
RCS file: /cvsroot/wix/wix/src/WixUnit/unitTests.xsd,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** unitTests.xsd 2 Mar 2007 12:22:17 -0000 1.5
--- unitTests.xsd 27 Jun 2007 05:35:50 -0000 1.6
***************
*** 27,31 ****
--- 27,40 ----
+
+
+
+
+
+
+
+
+
***************
*** 71,74 ****
--- 80,84 ----
+
***************
*** 81,85 ****
--- 91,97 ----
+
+
***************
*** 97,100 ****
--- 109,135 ----
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
***************
*** 102,119 ****
--- 137,167 ----
+
+
+
+
+
+
+
+
+
+
+
+
+
***************
*** 135,138 ****
--- 183,187 ----
+
------------------------------
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
------------------------------
_______________________________________________
Wix-commits mailing list
Wix-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wix-commits
End of Wix-commits Digest, Vol 11, Issue 43
*******************************************
P.S. И не забудьте послать роботу вашу рекламу :)
Обработано объявлений: 11776
Стас Давыдов & Outcorp © 2007