Esempio n. 1
0
        public static void Main(string[] args)
        {
            NUnitRunner runner = new NUnitRunner(args);

            runner.AddGlobalSetupIfNeeded("GVFS.UnitTests.Setup");

            List <string> excludeCategories = new List <string>();

            if (Debugger.IsAttached)
            {
                excludeCategories.Add(CategoryConstants.ExceptionExpected);
            }

            if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
            {
                excludeCategories.Add(CategoryConstants.CaseInsensitiveFileSystemOnly);
            }
            else
            {
                excludeCategories.Add(CategoryConstants.CaseSensitiveFileSystemOnly);
            }

            Environment.ExitCode = runner.RunTests(includeCategories: null, excludeCategories: excludeCategories);

            if (Debugger.IsAttached)
            {
                Console.WriteLine("Tests completed. Press Enter to exit.");
                Console.ReadLine();
            }
        }
        public void TestRunTestsThrowsArgumentNullExceptionWhenAssemblyIsNull()
        {
            INUnitRunner runner = new NUnitRunner("suite-name");

            Assert.Throws(
                Is.TypeOf <ArgumentNullException>().And.Message
                .EqualTo("The assembly cannot be null. (Parameter 'assembly')"),
                () => runner.RunTests(null, null, null));
        }
Esempio n. 3
0
        public static void Main(string[] args)
        {
            NUnitRunner runner = new NUnitRunner(args);

            if (Debugger.IsAttached)
            {
                runner.ExcludeCategory(CategoryContants.ExceptionExpected);
            }

            Environment.ExitCode = runner.RunTests(1);
        }
Esempio n. 4
0
        public static void Main(string[] args)
        {
            NUnitRunner runner = new NUnitRunner(args);

            if (runner.HasCustomArg("--full-suite"))
            {
                Console.WriteLine("Running the full suite of tests");
                FileSystemRunners.FileSystemRunner.UseAllRunners = true;
            }

            Environment.ExitCode = runner.RunTests(Properties.Settings.Default.TestRepeatCount);
        }
        public void TestRunTestsWithAssemblyRunsTestsAndReturnsTheRanTests([Values] bool withChildTests,
                                                                           [Values] bool withListener, [Values] bool withFilter)
        {
            ITestFilter filter = withFilter
                ? NUnitFilter.Where.Class(typeof(TestFixtureStubOne).FullName).And.Method("Test2").Build().Filter
                : null;
            ResultState expectedState = ResultState.Inconclusive;

            if (withChildTests)
            {
                expectedState = withFilter ? ResultState.Success : ResultState.ChildFailure;
            }

            TestListenerForTest listener = withListener ? new TestListenerForTest() : null;

            INUnitRunner runner   = new NUnitRunner("suite-name");
            Assembly     assembly = typeof(TestFixtureStubOne).Assembly;

            int expectedCaseCount   = 0;
            int expectedResultCount = 0;

            if (withChildTests)
            {
                expectedCaseCount = TestFixtureStubHelper.GeTestFixtureStub().ResultsDepth +
                                    (withFilter ? 2 : TestFixtureStubHelper.GeTestFixtureStub().ResultCount);
                expectedResultCount = withFilter ? 1 : TestFixtureStubHelper.GeTestFixtureStub().TestCount;
                Task <ITest> testTask = runner.AddTestAssemblyAsync(assembly);
                testTask.Wait();
            }

            ITestResult results = runner.RunTests(assembly, listener, filter);

            if (withChildTests)
            {
                Assert.IsNotNull(results);
                Assert.IsFalse(runner.IsTestRunning);
                Assert.IsTrue(runner.IsTestComplete);
                Assert.AreEqual(expectedState, results.ResultState);
                int totalResultCount = results.FailCount + results.InconclusiveCount + results.PassCount +
                                       results.SkipCount +
                                       results.WarningCount;
                Assert.AreEqual(expectedResultCount, totalResultCount);

                if (withListener)
                {
                    Assert.AreEqual(expectedCaseCount, listener.Tests.Count);
                }
            }
            else
            {
                Assert.IsNull(results);
            }
        }
Esempio n. 6
0
        public static void Main(string[] args)
        {
            NUnitRunner runner = new NUnitRunner(args);

            if (runner.HasCustomArg("--no-shared-gvfs-cache"))
            {
                Console.WriteLine("Running without a shared git object cache");
                GVFSTestConfig.NoSharedCache = true;
            }

            GVFSTestConfig.LocalCacheRoot = runner.GetCustomArgWithParam("--shared-gvfs-cache-root");

            if (runner.HasCustomArg("--full-suite"))
            {
                Console.WriteLine("Running the full suite of tests");
                GVFSTestConfig.UseAllRunners = true;
            }

            GVFSTestConfig.RepoToClone =
                runner.GetCustomArgWithParam("--repo-to-clone")
                ?? Properties.Settings.Default.RepoToClone;

            string servicePath = Path.Combine(TestContext.CurrentContext.TestDirectory, Properties.Settings.Default.PathToGVFSService);

            GVFSServiceProcess.InstallService(servicePath);
            try
            {
                Environment.ExitCode = runner.RunTests(Properties.Settings.Default.TestRepeatCount);
            }
            finally
            {
                string serviceLogFolder = Path.Combine(
                    Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData),
                    "GVFS",
                    GVFSServiceProcess.TestServiceName,
                    "Logs");

                Console.WriteLine("GVFS.Service logs at '{0}' attached below.\n\n", serviceLogFolder);
                foreach (string filename in TestResultsHelper.GetAllFilesInDirectory(serviceLogFolder))
                {
                    TestResultsHelper.OutputFileContents(filename);
                }

                GVFSServiceProcess.UninstallService();
            }

            if (Debugger.IsAttached)
            {
                Console.WriteLine("Tests completed. Press Enter to exit.");
                Console.ReadLine();
            }
        }
        public void TestGetTestResultsAsyncWithAssemblyReturnsResults([Values] bool withChildTests,
                                                                      [Values] bool runTests, [Values] bool withFilter)
        {
            ITestFilter filter = withFilter
                ? NUnitFilter.Where.Class(typeof(TestFixtureStubOne).FullName).And.Method("Test2").Build().Filter
                : null;
            ResultState expectedState = ResultState.Inconclusive;

            if (withChildTests && runTests)
            {
                expectedState = withFilter ? ResultState.Success : ResultState.ChildFailure;
            }

            INUnitRunner runner   = new NUnitRunner("suite-name");
            Assembly     assembly = typeof(TestFixtureStubOne).Assembly;

            int expectedCount = 0;

            if (withChildTests)
            {
                expectedCount = withFilter ? 1 : TestFixtureStubHelper.GeTestFixtureStub().TestCount;
                Task <ITest> testTask = runner.AddTestAssemblyAsync(assembly);
                testTask.Wait();
            }

            if (runTests)
            {
                runner.RunTests(null, filter);
            }
            else
            {
                expectedCount = 0;
            }

            Task <ITestResult> resultTask = runner.GetTestResultsAsync(assembly);

            Assert.IsNotNull(resultTask);
            resultTask.Wait();
            ITestResult results = resultTask.Result;

            Assert.IsNotNull(results);
            Assert.AreEqual(expectedState, results.ResultState);
            int totalCount = results.FailCount + results.InconclusiveCount + results.PassCount + results.SkipCount +
                             results.WarningCount;

            Assert.AreEqual(expectedCount, totalCount);
        }
Esempio n. 8
0
        public static void Main(string[] args)
        {
            NUnitRunner runner = new NUnitRunner(args);

            if (Debugger.IsAttached)
            {
                runner.ExcludeCategory(CategoryConstants.ExceptionExpected);
            }

            Environment.ExitCode = runner.RunTests();

            if (Debugger.IsAttached)
            {
                Console.WriteLine("Tests completed. Press Enter to exit.");
                Console.ReadLine();
            }
        }
Esempio n. 9
0
        public static void Main(string[] args)
        {
            NUnitRunner runner = new NUnitRunner(args);

            if (runner.HasCustomArg("--full-suite"))
            {
                Console.WriteLine("Running the full suite of tests");
                FileSystemRunners.FileSystemRunner.UseAllRunners = true;
            }

            if (!runner.HasCustomArg("--run-builds"))
            {
                runner.ExcludeCategory(CategoryConstants.Build);
            }

            string servicePath = Path.Combine(TestContext.CurrentContext.TestDirectory, Properties.Settings.Default.PathToGVFSService);

            GVFSServiceProcess.InstallService(servicePath);
            try
            {
                Environment.ExitCode = runner.RunTests(Properties.Settings.Default.TestRepeatCount);
            }
            finally
            {
                string serviceLogFolder = Path.Combine(
                    Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData),
                    "GVFS",
                    GVFSServiceProcess.TestServiceName,
                    "Logs");

                Console.WriteLine("GVFS.Service logs at '{0}' attached below.\n\n", serviceLogFolder);
                foreach (string filename in TestResultsHelper.GetAllFilesInDirectory(serviceLogFolder))
                {
                    TestResultsHelper.OutputFileContents(filename);
                }

                GVFSServiceProcess.UninstallService();
            }

            if (Debugger.IsAttached)
            {
                Console.WriteLine("Tests completed. Press Enter to exit.");
                Console.ReadLine();
            }
        }
Esempio n. 10
0
        public static void Main(string[] args)
        {
            Properties.Settings.Default.Initialize();
            NUnitRunner runner = new NUnitRunner(args);

            if (runner.HasCustomArg("--no-shared-gvfs-cache"))
            {
                Console.WriteLine("Running without a shared git object cache");
                GVFSTestConfig.NoSharedCache = true;
            }

            if (runner.HasCustomArg("--test-gvfs-on-path"))
            {
                Console.WriteLine("Running tests against GVFS on path");
                GVFSTestConfig.TestGVFSOnPath = true;
            }

            if (runner.HasCustomArg("--replace-inbox-projfs"))
            {
                Console.WriteLine("Tests will replace inbox ProjFS");
                GVFSTestConfig.ReplaceInboxProjFS = true;
            }

            GVFSTestConfig.LocalCacheRoot = runner.GetCustomArgWithParam("--shared-gvfs-cache-root");

            HashSet <string> includeCategories = new HashSet <string>();
            HashSet <string> excludeCategories = new HashSet <string>();

            if (runner.HasCustomArg("--full-suite"))
            {
                Console.WriteLine("Running the full suite of tests");

                GVFSTestConfig.GitRepoTestsValidateWorkTree = DataSources.AllBools;

                if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
                {
                    GVFSTestConfig.FileSystemRunners = FileSystemRunners.FileSystemRunner.AllWindowsRunners;
                }
                else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
                {
                    GVFSTestConfig.FileSystemRunners = FileSystemRunners.FileSystemRunner.AllMacRunners;
                }
            }
            else
            {
                GVFSTestConfig.GitRepoTestsValidateWorkTree =
                    new object[]
                {
                    new object[] { true }
                };

                if (runner.HasCustomArg("--extra-only"))
                {
                    Console.WriteLine("Running only the tests marked as ExtraCoverage");
                    includeCategories.Add(Categories.ExtraCoverage);
                }
                else
                {
                    excludeCategories.Add(Categories.ExtraCoverage);
                }

                GVFSTestConfig.FileSystemRunners = FileSystemRunners.FileSystemRunner.DefaultRunners;
            }

            if (runner.HasCustomArg("--windows-only"))
            {
                includeCategories.Add(Categories.WindowsOnly);

                // RunTests unions all includeCategories.  Remove ExtraCoverage to
                // ensure that we only run tests flagged as WindowsOnly
                includeCategories.Remove(Categories.ExtraCoverage);
            }

            if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
            {
                excludeCategories.Add(Categories.MacTODO.FailsOnBuildAgent);
                excludeCategories.Add(Categories.MacTODO.NeedsNewFolderCreateNotification);
                excludeCategories.Add(Categories.MacTODO.M4);
                excludeCategories.Add(Categories.MacTODO.FlakyTest);
                excludeCategories.Add(Categories.WindowsOnly);
            }
            else
            {
                excludeCategories.Add(Categories.MacOnly);
            }

            GVFSTestConfig.RepoToClone =
                runner.GetCustomArgWithParam("--repo-to-clone")
                ?? Properties.Settings.Default.RepoToClone;

            RunBeforeAnyTests();
            Environment.ExitCode = runner.RunTests(includeCategories, excludeCategories);
            RunAfterAllTests();

            if (Debugger.IsAttached)
            {
                Console.WriteLine("Tests completed. Press Enter to exit.");
                Console.ReadLine();
            }
        }
Esempio n. 11
0
        public static void Main(string[] args)
        {
            Properties.Settings.Default.Initialize();
            NUnitRunner runner = new NUnitRunner(args);

            if (runner.HasCustomArg("--no-shared-gvfs-cache"))
            {
                Console.WriteLine("Running without a shared git object cache");
                GVFSTestConfig.NoSharedCache = true;
            }

            if (runner.HasCustomArg("--test-gvfs-on-path"))
            {
                Console.WriteLine("Running tests against GVFS on path");
                GVFSTestConfig.TestGVFSOnPath = true;
            }

            if (runner.HasCustomArg("--replace-inbox-projfs"))
            {
                Console.WriteLine("Tests will replace inbox ProjFS");
                GVFSTestConfig.ReplaceInboxProjFS = true;
            }

            GVFSTestConfig.LocalCacheRoot = runner.GetCustomArgWithParam("--shared-gvfs-cache-root");

            List <string> includeCategories = new List <string>();
            List <string> excludeCategories = new List <string>();

            if (runner.HasCustomArg("--full-suite"))
            {
                Console.WriteLine("Running the full suite of tests");

                if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
                {
                    GVFSTestConfig.FileSystemRunners = FileSystemRunners.FileSystemRunner.AllWindowsRunners;
                }
                else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
                {
                    GVFSTestConfig.FileSystemRunners = FileSystemRunners.FileSystemRunner.AllMacRunners;
                }
            }
            else
            {
                excludeCategories.Add(Categories.FullSuiteOnly);
                GVFSTestConfig.FileSystemRunners = FileSystemRunners.FileSystemRunner.DefaultRunners;
            }

            if (runner.HasCustomArg("--windows-only"))
            {
                includeCategories.Add(Categories.Windows);
            }

            if (runner.HasCustomArg("--mac-only"))
            {
                includeCategories.Add(Categories.Mac.M1);
                includeCategories.Add(Categories.Mac.M2);
                excludeCategories.Add(Categories.Mac.M2TODO);
                excludeCategories.Add(Categories.Mac.M3);
                excludeCategories.Add(Categories.Mac.M4);
                excludeCategories.Add(Categories.Windows);
            }

            GVFSTestConfig.RepoToClone =
                runner.GetCustomArgWithParam("--repo-to-clone")
                ?? Properties.Settings.Default.RepoToClone;

            RunBeforeAnyTests();
            Environment.ExitCode = runner.RunTests(includeCategories, excludeCategories);
            RunAfterAllTests();

            if (Debugger.IsAttached)
            {
                Console.WriteLine("Tests completed. Press Enter to exit.");
                Console.ReadLine();
            }
        }
Esempio n. 12
0
        public void TestReloadResultsCommandReloadsTestResults([Values] bool withTest, [Values] bool withResults,
                                                               [Values] bool withAdditionalTests)
        {
            int         invocationCount = 0;
            NUnitRunner runner          = new NUnitRunner("runner-name");

            runner.AddTestAssembly(typeof(TestFixtureStubOne).Assembly);
            int expectedRunnerCount = withAdditionalTests ? 2 : 1;

            if (withAdditionalTests)
            {
                runner.AddTestAssembly(GetType().Assembly);
            }

            Assert.AreEqual(expectedRunnerCount, runner.TestSuite.TestAssemblyRunners.Count);

            ITest testInstance = runner.TestSuite;
            ITest test         = withTest ? testInstance : null;

            TestsViewModel model = new TestsViewModel(runner, test);

            ITestFilter        filter          = NUnitFilter.Where.Class(typeof(TestFixtureStubOne).Namespace).Build().Filter;
            ITestResult        expectedResult  = withResults ? runner.RunTests(null, filter) : null;
            List <ITestResult> expectedResults = new List <ITestResult>();

            model.Result = withResults ? new NUnitTestResult(expectedResult) : null;
            if (withResults)
            {
                expectedResults.AddRange(expectedResult.Children);
            }
            else
            {
                expectedResults.Add(null);
                if (withAdditionalTests)
                {
                    expectedResults.Add(null);
                }
            }

            model.LoadTestsCommand.Execute(null);

            WaitForCommand(model);

            model.PropertyChanged += (sender, args) =>
            {
                switch (args.PropertyName)
                {
                case "IsBusy":
                    invocationCount++;
                    break;
                }
            };

            model.ReloadResultsCommand.Execute(null);

            WaitForCommand(model);

            Assert.IsFalse(model.IsBusy);
            Assert.AreEqual(2, invocationCount);
            Assert.IsNotNull(model.Test);
            Assert.AreEqual(testInstance, model.Test);

            IList <ITest> actualTests = model.Tests.Select(x => x.Test).ToList();

            // Matching test is not the root, so search for the test instance with the namespace of the test fixture
            IList <ITest> foundTests = new List <ITest>();
            int           skipCount  = 0;
            ITest         foundTest  = GetTestByName(testInstance, typeof(TestFixtureStubOne).Namespace, ref skipCount);

            foundTests.Add(foundTest);

            // Matching result is not the root, so search for the result instance with the namespace of the test fixture
            skipCount = 0;
            IList <ITestResult> foundResults = expectedResults
                                               .Select(result => GetTestResultByName(result, typeof(TestFixtureStubOne).Namespace, ref skipCount))
                                               .ToList();

            if (withAdditionalTests)
            {
                // Matching test is not the root, so search for the test instance with the namespace of the test fixture
                // Skip the first found match as the namespace is a sub-space of another
                // The first found is x.y of sub-space x.y.z, but the actual is just x.y with no sub-space
                skipCount = 1;
                foundTest = GetTestByName(testInstance, GetType().Assembly.GetName().Name, ref skipCount);
                foundTests.Add(foundTest);
            }

            CollectionAssert.AreEquivalent(foundTests, actualTests);

            IList <ITestResult> actualResults = model.Tests.Select(x => x.Result.Result).ToList();

            CollectionAssert.AreEquivalent(foundResults, actualResults);
            Assert.AreEqual(expectedResult, model.Result?.Result);
        }
Esempio n. 13
0
        public static void Main(string[] args)
        {
            Properties.Settings.Default.Initialize();
            NUnitRunner runner = new NUnitRunner(args);

            if (runner.HasCustomArg("--no-shared-gvfs-cache"))
            {
                Console.WriteLine("Running without a shared git object cache");
                GVFSTestConfig.NoSharedCache = true;
            }

            if (runner.HasCustomArg("--test-gvfs-on-path"))
            {
                Console.WriteLine("Running tests against GVFS on path");
                GVFSTestConfig.TestGVFSOnPath = true;
            }

            if (runner.HasCustomArg("--replace-inbox-projfs"))
            {
                Console.WriteLine("Tests will replace inbox ProjFS");
                GVFSTestConfig.ReplaceInboxProjFS = true;
            }

            GVFSTestConfig.LocalCacheRoot = runner.GetCustomArgWithParam("--shared-gvfs-cache-root");

            HashSet <string> includeCategories = new HashSet <string>();
            HashSet <string> excludeCategories = new HashSet <string>();

            if (runner.HasCustomArg("--full-suite"))
            {
                Console.WriteLine("Running the full suite of tests");

                List <object[]> modes = new List <object[]>();
                foreach (Settings.ValidateWorkingTreeMode mode in Enum.GetValues(typeof(Settings.ValidateWorkingTreeMode)))
                {
                    modes.Add(new object[] { mode });
                }

                GVFSTestConfig.GitRepoTestsValidateWorkTree = modes.ToArray();

                if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
                {
                    GVFSTestConfig.FileSystemRunners = FileSystemRunners.FileSystemRunner.AllWindowsRunners;
                }
                else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
                {
                    GVFSTestConfig.FileSystemRunners = FileSystemRunners.FileSystemRunner.AllMacRunners;
                }
            }
            else
            {
                Settings.ValidateWorkingTreeMode validateMode = Settings.ValidateWorkingTreeMode.Full;

                if (runner.HasCustomArg("--sparse-mode"))
                {
                    validateMode = Settings.ValidateWorkingTreeMode.SparseMode;

                    // Only test the git commands in sparse mode for splitting out tests in builds
                    includeCategories.Add(Categories.GitCommands);
                }

                GVFSTestConfig.GitRepoTestsValidateWorkTree =
                    new object[]
                {
                    new object[] { validateMode },
                };

                if (runner.HasCustomArg("--extra-only"))
                {
                    Console.WriteLine("Running only the tests marked as ExtraCoverage");
                    includeCategories.Add(Categories.ExtraCoverage);
                }
                else
                {
                    excludeCategories.Add(Categories.ExtraCoverage);
                }

                GVFSTestConfig.FileSystemRunners = FileSystemRunners.FileSystemRunner.DefaultRunners;
            }

            if (runner.HasCustomArg("--windows-only"))
            {
                includeCategories.Add(Categories.WindowsOnly);

                // RunTests unions all includeCategories.  Remove ExtraCoverage to
                // ensure that we only run tests flagged as WindowsOnly
                includeCategories.Remove(Categories.ExtraCoverage);
            }

            if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
            {
                excludeCategories.Add(Categories.MacTODO.NeedsNewFolderCreateNotification);
                excludeCategories.Add(Categories.MacTODO.NeedsGVFSConfig);
                excludeCategories.Add(Categories.MacTODO.NeedsServiceVerb);
                excludeCategories.Add(Categories.MacTODO.NeedsStatusCache);
                excludeCategories.Add(Categories.MacTODO.TestNeedsToLockFile);
                excludeCategories.Add(Categories.WindowsOnly);
            }
            else
            {
                excludeCategories.Add(Categories.MacOnly);
            }

            GVFSTestConfig.DotGVFSRoot = RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ? ".vfsforgit" : ".gvfs";

            GVFSTestConfig.RepoToClone =
                runner.GetCustomArgWithParam("--repo-to-clone")
                ?? Properties.Settings.Default.RepoToClone;

            RunBeforeAnyTests();
            Environment.ExitCode = runner.RunTests(includeCategories, excludeCategories);

            if (Debugger.IsAttached)
            {
                Console.WriteLine("Tests completed. Press Enter to exit.");
                Console.ReadLine();
            }
        }
Esempio n. 14
0
        public static void Main(string[] args)
        {
            Properties.Settings.Default.Initialize();
            NUnitRunner runner = new NUnitRunner(args);

            runner.AddGlobalSetupIfNeeded("Scalar.FunctionalTests.GlobalSetup");

            if (runner.HasCustomArg("--no-shared-scalar-cache"))
            {
                Console.WriteLine("Running without a shared git object cache");
                ScalarTestConfig.NoSharedCache = true;
            }

            if (runner.HasCustomArg("--test-scalar-on-path"))
            {
                Console.WriteLine("Running tests against Scalar on path");
                ScalarTestConfig.TestScalarOnPath = true;
            }

            string trace2Output = runner.GetCustomArgWithParam("--trace2-output");

            if (trace2Output != null)
            {
                Console.WriteLine($"Sending trace2 output to {trace2Output}");
                Environment.SetEnvironmentVariable("GIT_TRACE2_EVENT", trace2Output);
            }

            ScalarTestConfig.LocalCacheRoot = runner.GetCustomArgWithParam("--shared-scalar-cache-root");

            HashSet <string> includeCategories = new HashSet <string>();
            HashSet <string> excludeCategories = new HashSet <string>();

            // Run all GitRepoTests with sparse mode
            ScalarTestConfig.GitRepoTestsValidateWorkTree =
                new object[]
            {
                new object[] { Settings.ValidateWorkingTreeMode.SparseMode },
            };

            if (runner.HasCustomArg("--full-suite"))
            {
                Console.WriteLine("Running the full suite of tests");

                if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
                {
                    ScalarTestConfig.FileSystemRunners = FileSystemRunners.FileSystemRunner.AllWindowsRunners;
                }
                else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
                {
                    ScalarTestConfig.FileSystemRunners = FileSystemRunners.FileSystemRunner.AllMacRunners;
                }
            }
            else
            {
                if (runner.HasCustomArg("--extra-only"))
                {
                    Console.WriteLine("Running only the tests marked as ExtraCoverage");
                    includeCategories.Add(Categories.ExtraCoverage);
                }
                else
                {
                    excludeCategories.Add(Categories.ExtraCoverage);
                }

                ScalarTestConfig.FileSystemRunners = FileSystemRunners.FileSystemRunner.DefaultRunners;
            }

            if (runner.HasCustomArg("--windows-only"))
            {
                includeCategories.Add(Categories.WindowsOnly);

                // RunTests unions all includeCategories.  Remove ExtraCoverage to
                // ensure that we only run tests flagged as WindowsOnly
                includeCategories.Remove(Categories.ExtraCoverage);
            }

            if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
            {
                excludeCategories.Add(Categories.MacTODO.NeedsScalarConfig);
                excludeCategories.Add(Categories.MacTODO.NeedsServiceVerb);
                excludeCategories.Add(Categories.MacTODO.TestNeedsToLockFile);
                excludeCategories.Add(Categories.WindowsOnly);
            }
            else
            {
                excludeCategories.Add(Categories.MacOnly);
            }

            // For now, run all of the tests not flagged as needing to be updated to work
            // with the non-virtualized solution
            excludeCategories.Add(Categories.NeedsUpdatesForNonVirtualizedMode);

            if (!RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
            {
                excludeCategories.Add(Categories.MacOnly);
            }

            ScalarTestConfig.RepoToClone =
                runner.GetCustomArgWithParam("--repo-to-clone")
                ?? Properties.Settings.Default.RepoToClone;

            RunBeforeAnyTests();
            Environment.ExitCode = runner.RunTests(includeCategories, excludeCategories);

            try
            {
                // Shutdown the watchman server now that the tests are complete.
                // Allows deleting the unwatched directories.
                ProcessHelper.Run("watchman", "shudown-server");
            }
            catch (Exception)
            {
                // This is non-critical, and watchman may not be installed.
            }

            if (Debugger.IsAttached)
            {
                Console.WriteLine("Tests completed. Press Enter to exit.");
                Console.ReadLine();
            }
        }
Esempio n. 15
0
        public static void Main(string[] args)
        {
            Properties.Settings.Default.Initialize();
            Console.WriteLine("Settings.Default.CurrentDirectory: {0}", Settings.Default.CurrentDirectory);
            Console.WriteLine("Settings.Default.PathToGit: {0}", Settings.Default.PathToGit);
            Console.WriteLine("Settings.Default.PathToGVFS: {0}", Settings.Default.PathToGVFS);
            Console.WriteLine("Settings.Default.PathToGVFSService: {0}", Settings.Default.PathToGVFSService);

            NUnitRunner runner = new NUnitRunner(args);

            runner.AddGlobalSetupIfNeeded("GVFS.FunctionalTests.GlobalSetup");

            if (runner.HasCustomArg("--no-shared-gvfs-cache"))
            {
                Console.WriteLine("Running without a shared git object cache");
                GVFSTestConfig.NoSharedCache = true;
            }

            if (runner.HasCustomArg("--replace-inbox-projfs"))
            {
                Console.WriteLine("Tests will replace inbox ProjFS");
                GVFSTestConfig.ReplaceInboxProjFS = true;
            }

            GVFSTestConfig.LocalCacheRoot = runner.GetCustomArgWithParam("--shared-gvfs-cache-root");

            HashSet <string> includeCategories = new HashSet <string>();
            HashSet <string> excludeCategories = new HashSet <string>();

            if (runner.HasCustomArg("--full-suite"))
            {
                Console.WriteLine("Running the full suite of tests");

                List <object[]> modes = new List <object[]>();
                foreach (Settings.ValidateWorkingTreeMode mode in Enum.GetValues(typeof(Settings.ValidateWorkingTreeMode)))
                {
                    modes.Add(new object[] { mode });
                }

                GVFSTestConfig.GitRepoTestsValidateWorkTree = modes.ToArray();
                GVFSTestConfig.FileSystemRunners            = FileSystemRunners.FileSystemRunner.AllWindowsRunners;
            }
            else
            {
                Settings.ValidateWorkingTreeMode validateMode = Settings.ValidateWorkingTreeMode.Full;

                if (runner.HasCustomArg("--sparse-mode"))
                {
                    validateMode = Settings.ValidateWorkingTreeMode.SparseMode;

                    // Only test the git commands in sparse mode for splitting out tests in builds
                    includeCategories.Add(Categories.GitCommands);
                }

                GVFSTestConfig.GitRepoTestsValidateWorkTree =
                    new object[]
                {
                    new object[] { validateMode },
                };

                if (runner.HasCustomArg("--extra-only"))
                {
                    Console.WriteLine("Running only the tests marked as ExtraCoverage");
                    includeCategories.Add(Categories.ExtraCoverage);
                }
                else
                {
                    excludeCategories.Add(Categories.ExtraCoverage);
                }

                // If we're running in CI exclude tests that are currently
                // flakey or broken when run in a CI environment.
                if (runner.HasCustomArg("--ci"))
                {
                    excludeCategories.Add(Categories.NeedsReactionInCI);
                }

                GVFSTestConfig.FileSystemRunners = FileSystemRunners.FileSystemRunner.DefaultRunners;
            }

            GVFSTestConfig.DotGVFSRoot = ".gvfs";

            GVFSTestConfig.RepoToClone =
                runner.GetCustomArgWithParam("--repo-to-clone")
                ?? Properties.Settings.Default.RepoToClone;

            RunBeforeAnyTests();
            Environment.ExitCode = runner.RunTests(includeCategories, excludeCategories);

            if (Debugger.IsAttached)
            {
                Console.WriteLine("Tests completed. Press Enter to exit.");
                Console.ReadLine();
            }
        }