private IEnumerable GetFinalCommandLines()

in GoogleTestAdapter/Core/Runners/CommandLineGenerator.cs [64:108]


        private IEnumerable<Args> GetFinalCommandLines(string baseCommandLine)
        {
            var commandLines = new List<Args>();
            string userParam = GetAdditionalUserParameter();
            if (AllTestCasesOfExecutableAreRun())
            {
                commandLines.Add(new Args(_testCasesToRun, baseCommandLine + userParam));
                return commandLines;
            }

            string baseCommandLineWithFilter = baseCommandLine + GoogleTestConstants.FilterOption;

            List<string> suitesRunningAllTests = GetSuitesRunningAllTests();
            baseCommandLineWithFilter += GetFilterForSuitesRunningAllTests(suitesRunningAllTests);

            List<TestCase> testCasesNotRunBySuite = GetTestCasesNotRunBySuite(suitesRunningAllTests);
            List<TestCase> testCasesRunBySuite = _testCasesToRun.Where(tc => !testCasesNotRunBySuite.Contains(tc)).ToList();
            if (testCasesNotRunBySuite.Count == 0)
            {
                commandLines.Add(new Args(_testCasesToRun, baseCommandLineWithFilter + userParam));
                return commandLines;
            }

            List<TestCase> includedTestCases;
            int remainingLength = MaxCommandLength
                - baseCommandLineWithFilter.Length - _lengthOfExecutableString - userParam.Length - 1;
            string commandLine = baseCommandLineWithFilter +
                JoinTestsUpToMaxLength(testCasesNotRunBySuite, remainingLength, out includedTestCases);
            includedTestCases.AddRange(testCasesRunBySuite);
            commandLines.Add(new Args(includedTestCases, commandLine + userParam));

            // only add suites to first command line
            baseCommandLineWithFilter = baseCommandLine + GoogleTestConstants.FilterOption;

            while (testCasesNotRunBySuite.Count > 0)
            {
                remainingLength = MaxCommandLength
                    - baseCommandLineWithFilter.Length - _lengthOfExecutableString - userParam.Length - 1;
                commandLine = baseCommandLineWithFilter +
                              JoinTestsUpToMaxLength(testCasesNotRunBySuite, remainingLength, out includedTestCases);
                commandLines.Add(new Args(includedTestCases, commandLine + userParam));
            }

            return commandLines;
        }