Beispiel #1
0
        public void DetectUnconvertableQtExecCmdTimeout()
        {
            const string beforeFileName = "v3.wxs";
            const string afterFileName  = "v4_expected.wxs";
            var          folder         = TestData.Get(@"TestData\QtExec.bad");

            using (var fs = new DisposableFileSystem())
            {
                var baseFolder = fs.GetFolder(true);
                var targetFile = Path.Combine(baseFolder, beforeFileName);
                File.Copy(Path.Combine(folder, beforeFileName), Path.Combine(baseFolder, beforeFileName));

                var runner = new WixCopRunner
                {
                    FixErrors      = true,
                    SearchPatterns =
                    {
                        targetFile,
                    },
                };

                var result = runner.Execute();

                Assert.Equal(2, result.ExitCode);

                Assert.Single(result.Messages.Where(message => message.ToString().EndsWith("(QtExecCmdTimeoutAmbiguous)")));

                var expected = File.ReadAllText(Path.Combine(folder, afterFileName)).Replace("\r\n", "\n");
                var actual   = File.ReadAllText(targetFile).Replace("\r\n", "\n");
                Assert.Equal(expected, actual);

                // still fails because QtExecCmdTimeoutAmbiguous is unfixable
                var runner2 = new WixCopRunner
                {
                    FixErrors      = true,
                    SearchPatterns =
                    {
                        targetFile,
                    },
                };

                var result2 = runner2.Execute();

                Assert.Equal(2, result2.ExitCode);
            }
        }
Beispiel #2
0
        public void RetainsPreprocessorInstructions()
        {
            const string beforeFileName = "Preprocessor.wxs";
            const string afterFileName  = "ConvertedPreprocessor.wxs";
            var          folder         = TestData.Get(@"TestData\Preprocessor");

            using (var fs = new DisposableFileSystem())
            {
                var baseFolder = fs.GetFolder(true);
                var targetFile = Path.Combine(baseFolder, beforeFileName);
                File.Copy(Path.Combine(folder, beforeFileName), Path.Combine(baseFolder, beforeFileName));

                var runner = new WixCopRunner
                {
                    FixErrors      = true,
                    SettingFile1   = Path.Combine(folder, "wixcop.settings.xml"),
                    SearchPatterns =
                    {
                        targetFile,
                    },
                };

                var result = runner.Execute();

                Assert.Equal(2, result.ExitCode);

                var expected = File.ReadAllText(Path.Combine(folder, afterFileName)).Replace("\r\n", "\n");
                var actual   = File.ReadAllText(targetFile).Replace("\r\n", "\n");
                Assert.Equal(expected, actual);

                var runner2 = new WixCopRunner
                {
                    FixErrors      = true,
                    SettingFile1   = Path.Combine(folder, "wixcop.settings.xml"),
                    SearchPatterns =
                    {
                        targetFile,
                    },
                };

                var result2 = runner2.Execute();

                Assert.Equal(0, result2.ExitCode);
            }
        }
Beispiel #3
0
        public void CanConvertQtExec()
        {
            const string beforeFileName = "v3.wxs";
            const string afterFileName  = "v4_expected.wxs";
            var          folder         = TestData.Get(@"TestData\QtExec");

            using (var fs = new DisposableFileSystem())
            {
                var baseFolder = fs.GetFolder(true);
                var targetFile = Path.Combine(baseFolder, beforeFileName);
                File.Copy(Path.Combine(folder, beforeFileName), Path.Combine(baseFolder, beforeFileName));

                var runner = new WixCopRunner
                {
                    FixErrors      = true,
                    SearchPatterns =
                    {
                        targetFile,
                    },
                };

                var result = runner.Execute();

                Assert.Equal(2, result.ExitCode);

                var expected = File.ReadAllText(Path.Combine(folder, afterFileName)).Replace("\r\n", "\n");
                var actual   = File.ReadAllText(targetFile).Replace("\r\n", "\n");
                Assert.Equal(expected, actual);

                var runner2 = new WixCopRunner
                {
                    FixErrors      = true,
                    SearchPatterns =
                    {
                        targetFile,
                    },
                };

                var result2 = runner2.Execute();

                Assert.Equal(0, result2.ExitCode);
            }
        }
Beispiel #4
0
        public WixCopRunnerResult Execute()
        {
            var argList = new List <string>();

            if (this.FixErrors)
            {
                argList.Add("-f");
            }

            if (!String.IsNullOrEmpty(this.SettingFile1))
            {
                argList.Add($"-set1{this.SettingFile1}");
            }

            foreach (var searchPattern in this.SearchPatterns)
            {
                argList.Add(searchPattern);
            }

            return(WixCopRunner.Execute(argList.ToArray()));
        }