Ejemplo n.º 1
0
        private static int ForwardToVSTestConsole(ParseResult parseResult, string[] args, string[] settings, string testSessionCorrelationId)
        {
            List <string> convertedArgs = new VSTestArgumentConverter().Convert(args, out List <string> ignoredArgs);

            if (ignoredArgs.Any())
            {
                Reporter.Output.WriteLine(string.Format(LocalizableStrings.IgnoredArgumentsMessage, string.Join(" ", ignoredArgs)).Yellow());
            }

            // merge the args settings, we don't need to escape
            // one more time, there is no extra hop via msbuild
            convertedArgs.AddRange(settings);

            if (FeatureFlag.Default.IsEnabled(FeatureFlag.ARTIFACTS_POSTPROCESSING))
            {
                // Add artifacts processing mode and test session id for the artifact post-processing
                convertedArgs.Add("--artifactsProcessingMode-collect");
                convertedArgs.Add($"--testSessionCorrelationId:{testSessionCorrelationId}");
            }

            int exitCode = new VSTestForwardingApp(convertedArgs).Execute();

            // We run post processing also if execution is failed for possible partial successful result to post process.
            exitCode |= RunArtifactPostProcessingIfNeeded(testSessionCorrelationId, parseResult, FeatureFlag.Default);

            return(exitCode);
        }
Ejemplo n.º 2
0
        public static int Run(string[] args)
        {
            DebugHelper.HandleDebugSwitch(ref args);

            // Fix for https://github.com/Microsoft/vstest/issues/1453
            // Try to run dll/exe directly using the VSTestForwardingApp
            if (ContainsBuiltTestSources(args))
            {
                var convertedArgs = new VSTestArgumentConverter().Convert(args, out var ignoredArgs);
                if (ignoredArgs.Any())
                {
                    Reporter.Output.WriteLine(string.Format(LocalizableStrings.IgnoredArgumentsMessage, string.Join(" ", ignoredArgs)).Yellow());
                }
                return(new VSTestForwardingApp(convertedArgs).Execute());
            }

            // Workaround for https://github.com/Microsoft/vstest/issues/1503
            const string NodeWindowEnvironmentName = "MSBUILDENSURESTDOUTFORTASKPROCESSES";
            string       previousNodeWindowSetting = Environment.GetEnvironmentVariable(NodeWindowEnvironmentName);

            try
            {
                Environment.SetEnvironmentVariable(NodeWindowEnvironmentName, "1");
                return(FromArgs(args).Execute());
            }
            finally
            {
                Environment.SetEnvironmentVariable(NodeWindowEnvironmentName, previousNodeWindowSetting);
            }
        }
Ejemplo n.º 3
0
        public void ConvertArgshouldConvertsVerbosityArgsIntoVSTestParsableArgs(string input, string expectedString)
        {
            string[] args         = input.Split(' ');
            string[] expectedArgs = expectedString.Split(' ');

            // Act
            List <string> convertedArgs = new VSTestArgumentConverter().Convert(args, out List <string> ignoredArgs);

            convertedArgs.Should().BeEquivalentTo(expectedArgs);
            ignoredArgs.Should().BeEmpty();
        }
Ejemplo n.º 4
0
        public void ConvertArgshouldConvertsVerbosityArgsIntoVSTestParsableArgs(string input, string expectedString)
        {
            string[] args         = input.Split(' ');
            string[] expectedArgs = expectedString.Split(' ');

            // Act
            var convertedArgs = new VSTestArgumentConverter().Convert(args, out var ignoredArgs);

            Assert.Equal(expectedArgs, convertedArgs);
            Assert.True(ignoredArgs.Count == 0);
        }
Ejemplo n.º 5
0
        public void ConvertArgsShouldConvertValidArgsIntoVSTestParsableArgs(string input, string expectedString)
        {
            string[] args         = input.Split(' ');
            string[] expectedArgs = expectedString.Split(' ');

            // Act
            var convertedArgs = new VSTestArgumentConverter().Convert(args, out var ignoredArgs);

            convertedArgs.Should().BeEquivalentTo(convertedArgs);
            ignoredArgs.Should().BeEmpty();
        }
Ejemplo n.º 6
0
        public void ConvertArgsShouldIgnoreKnownArgsWhileConvertingArgsIntoVSTestParsableArgs(string input, string expectedArgString, string expIgnoredArgString)
        {
            string[] args           = input.Split(' ');
            string[] expectedArgs   = expectedArgString.Split(' ');
            string[] expIgnoredArgs = expIgnoredArgString.Split(' ');

            // Act
            List <string> convertedArgs = new VSTestArgumentConverter().Convert(args, out List <string> ignoredArgs);

            convertedArgs.Should().BeEquivalentTo(expectedArgs);
            ignoredArgs.Select(x => x.ToUpperInvariant()).Should().BeEquivalentTo(expIgnoredArgs.Select(x => x.ToUpperInvariant()));
        }
Ejemplo n.º 7
0
        public void ConvertArgsShouldIgnoreKnownArgsWhileConvertingArgsIntoVSTestParsableArgs(string input, string expectedArgString, string expIgnoredArgString)
        {
            string[] args           = input.Split(' ');
            string[] expectedArgs   = expectedArgString.Split(' ');
            string[] expIgnoredArgs = expIgnoredArgString.Split(' ');

            // Act
            var convertedArgs = new VSTestArgumentConverter().Convert(args, out var ignoredArgs);

            Assert.Equal(expectedArgs, convertedArgs);
            Assert.Equal(expIgnoredArgs, ignoredArgs);
        }
Ejemplo n.º 8
0
        public static int Run(ParseResult parseResult)
        {
            parseResult.HandleDebugSwitch();

            var args = parseResult.GetArguments();

            // settings parameters are after -- (including --), these should not be considered by the parser
            var settings = args.SkipWhile(a => a != "--").ToArray();

            // all parameters before --
            args = args.TakeWhile(a => a != "--").ToArray();

            // Fix for https://github.com/Microsoft/vstest/issues/1453
            // Try to run dll/exe directly using the VSTestForwardingApp
            if (ContainsBuiltTestSources(args))
            {
                var convertedArgs = new VSTestArgumentConverter().Convert(args, out var ignoredArgs);
                if (ignoredArgs.Any())
                {
                    Reporter.Output.WriteLine(string.Format(LocalizableStrings.IgnoredArgumentsMessage, string.Join(" ", ignoredArgs)).Yellow());
                }

                // merge the args settings, we don't need to escape
                // one more time, there is no extra hop via msbuild
                convertedArgs.AddRange(settings);

                return(new VSTestForwardingApp(convertedArgs).Execute());
            }

            // Workaround for https://github.com/Microsoft/vstest/issues/1503
            const string NodeWindowEnvironmentName = "MSBUILDENSURESTDOUTFORTASKPROCESSES";
            string       previousNodeWindowSetting = Environment.GetEnvironmentVariable(NodeWindowEnvironmentName);

            try
            {
                Environment.SetEnvironmentVariable(NodeWindowEnvironmentName, "1");
                return(FromParseResult(parseResult, settings).Execute());
            }
            finally
            {
                Environment.SetEnvironmentVariable(NodeWindowEnvironmentName, previousNodeWindowSetting);
            }
        }