private string GetPassPercentage(AbstractReport emailReportDto, bool includeOthersInTotal)
        {
            var summary     = emailReportDto.Summary;
            var totalTests  = 0;
            var passedTests = 0;
            var failedTests = 0;

            if (summary != null)
            {
                if (summary.AggregatedResultsAnalysis.ResultsByOutcome.ContainsKey(TestOutcome.Passed))
                {
                    passedTests = summary.AggregatedResultsAnalysis.ResultsByOutcome[TestOutcome.Passed].Count;
                }
                if (summary.AggregatedResultsAnalysis.ResultsByOutcome.ContainsKey(TestOutcome.Failed))
                {
                    failedTests = summary.AggregatedResultsAnalysis.ResultsByOutcome[TestOutcome.Failed].Count;
                }

                totalTests = summary.AggregatedResultsAnalysis.TotalTests;

                if (!includeOthersInTotal)
                {
                    totalTests = passedTests + failedTests;
                }
            }

            return(TestResultsHelper.GetTestOutcomePercentageString(passedTests, totalTests));
        }
示例#2
0
        public void DeleteEnlistment()
        {
            TestResultsHelper.OutputGVFSLogs(this);

            // Use cmd.exe to delete the enlistment as it properly handles tombstones and reparse points
            CmdRunner.DeleteDirectoryWithRetry(this.EnlistmentRoot);
        }
示例#3
0
        private static ScalarFunctionalTestEnlistment Clone(
            string pathToScalar,
            string enlistmentRoot,
            string commitish,
            string localCacheRoot,
            bool skipFetchCommitsAndTrees = false,
            bool fullClone = true,
            string url     = null)
        {
            enlistmentRoot = enlistmentRoot ?? GetUniqueEnlistmentRoot();

            ScalarFunctionalTestEnlistment enlistment = new ScalarFunctionalTestEnlistment(
                pathToScalar,
                enlistmentRoot,
                url ?? ScalarTestConfig.RepoToClone,
                commitish ?? Properties.Settings.Default.Commitish,
                localCacheRoot ?? ScalarTestConfig.LocalCacheRoot,
                fullClone);

            try
            {
                enlistment.Clone(skipFetchCommitsAndTrees);
            }
            catch (Exception e)
            {
                Console.WriteLine($"Unhandled exception in {nameof(ScalarFunctionalTestEnlistment.Clone)}: " + e.ToString());
                TestResultsHelper.OutputScalarLogs(enlistment);
                throw;
            }

            return(enlistment);
        }
示例#4
0
        protected void TestValidationAndCleanup(bool ignoreCase = false)
        {
            try
            {
                if (TestContext.CurrentContext.Result.Outcome.Status == TestStatus.Failed)
                {
                    this.anyTestsFailed = true;
                    if (this.enlistmentPerTest)
                    {
                        TestResultsHelper.OutputGVFSLogs(this.Enlistment);
                    }
                }

                this.CheckHeadCommitTree();
                this.Enlistment.RepoRoot.ShouldBeADirectory(this.FileSystem)
                .WithDeepStructure(this.ControlGitRepo.RootPath, skipEmptyDirectories: true, ignoreCase: ignoreCase);

                this.RunGitCommand("reset --hard -q HEAD");
                this.RunGitCommand("clean -d -f -x");
                this.ValidateGitCommand("checkout " + this.ControlGitRepo.Commitish);

                this.CheckHeadCommitTree();
                this.Enlistment.RepoRoot.ShouldBeADirectory(this.FileSystem)
                .WithDeepStructure(this.ControlGitRepo.RootPath, skipEmptyDirectories: true, ignoreCase: ignoreCase);
            }
            finally
            {
                if (this.enlistmentPerTest)
                {
                    this.DeleteEnlistment();
                }
            }
        }
示例#5
0
        public static ScalarFunctionalTestEnlistment CloneGitRepo(string pathToScalar)
        {
            string enlistmentRoot = Path.Combine(GetUniqueEnlistmentRoot(), GitRepoSrcDir);

            ScalarFunctionalTestEnlistment enlistment = new ScalarFunctionalTestEnlistment(
                pathToScalar,
                enlistmentRoot,
                ScalarTestConfig.RepoToClone,
                Properties.Settings.Default.Commitish,
                ScalarTestConfig.LocalCacheRoot,
                isScalarRepo: false);

            try
            {
                enlistment.CloneGitRepo();
            }
            catch (Exception e)
            {
                Console.WriteLine($"Unhandled exception in {nameof(ScalarFunctionalTestEnlistment.Clone)}: " + e.ToString());
                TestResultsHelper.OutputScalarLogs(enlistment);
                throw;
            }

            return(enlistment);
        }
示例#6
0
        public TestResultSummaryViewModel(TestResultSummary summary, PipelineConfiguration pipelineConfiguration, bool includeOthersInTotal)
        {
            PassedTests = 0;
            FailedTests = 0;

            if (summary.AggregatedResultsAnalysis.ResultsByOutcome.ContainsKey(TestOutcome.Passed))
            {
                PassedTests = summary.AggregatedResultsAnalysis.ResultsByOutcome[TestOutcome.Passed].Count;
            }
            if (summary.AggregatedResultsAnalysis.ResultsByOutcome.ContainsKey(TestOutcome.Failed))
            {
                FailedTests = summary.AggregatedResultsAnalysis.ResultsByOutcome[TestOutcome.Failed].Count;
            }

            TotalTests = summary.AggregatedResultsAnalysis.TotalTests;
            OtherTests = TotalTests - PassedTests - FailedTests;

            if (!includeOthersInTotal)
            {
                TotalTests -= OtherTests;
            }

            PassingRate = TestResultsHelper.GetTestOutcomePercentageString(PassedTests, TotalTests);
            Duration    = TimeSpanFormatter.FormatDurationWithUnit(summary.AggregatedResultsAnalysis.Duration);
            Url         = pipelineConfiguration.TestTabLink;
        }
        public void DeleteEnlistment()
        {
            TestResultsHelper.OutputGVFSLogs(this);

            // Use cmd.exe to delete the enlistment as it properly handles tombstones
            // and reparse points
            CmdRunner cmdRunner        = new CmdRunner();
            bool      enlistmentExists = Directory.Exists(this.EnlistmentRoot);
            int       retryCount       = 0;

            while (enlistmentExists)
            {
                string output = cmdRunner.DeleteDirectory(this.EnlistmentRoot);
                enlistmentExists = Directory.Exists(this.EnlistmentRoot);
                if (enlistmentExists)
                {
                    ++retryCount;
                    Thread.Sleep(500);
                    try
                    {
                        if (retryCount > 10)
                        {
                            retryCount = 0;
                            throw new DeleteFolderFailedException(output);
                        }
                    }
                    catch (DeleteFolderFailedException)
                    {
                        // Throw\catch a DeleteFolderFailedException here so that developers who are running the tests
                        // and have a debugger attached can be alerted that something is wrong
                    }
                }
            }
        }
示例#8
0
        public virtual void DeleteEnlistment()
        {
            if (this.Enlistment != null)
            {
                if (this.anyTestsFailed)
                {
                    TestResultsHelper.OutputGVFSLogs(this.Enlistment);
                }

                this.Enlistment.UnmountAndDeleteAll();
            }
        }
        public virtual void DeleteEnlistment()
        {
            if (this.Enlistment != null)
            {
                if (TestContext.CurrentContext.Result.Outcome.Status == TestStatus.Failed)
                {
                    TestResultsHelper.OutputGVFSLogs(this.Enlistment);
                }

                this.Enlistment.UnmountAndDeleteAll();
            }
        }
示例#10
0
        public virtual void TearDownForFixture()
        {
            if (!this.enlistmentPerTest)
            {
                if (this.anyTestsFailed)
                {
                    TestResultsHelper.OutputGVFSLogs(this.Enlistment);
                }

                this.DeleteEnlistment();
            }
        }
示例#11
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();
            }
        }
示例#12
0
        public void UnmountAndDeleteEnlistment()
        {
            if (LongRunningSetup.Enlistment != null)
            {
                if (LongRunningSetup.OutputLogsWhenDone)
                {
                    TestResultsHelper.OutputGVFSLogs(LongRunningSetup.Enlistment);
                }

                LongRunningSetup.Enlistment.UnmountAndDeleteAll();
                LongRunningSetup.Enlistment = null;
            }
        }
示例#13
0
        public void DeleteEnlistment()
        {
            TestResultsHelper.OutputGVFSLogs(this);

            if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
            {
                // Use cmd.exe to delete the enlistment as it properly handles tombstones and reparse points
                CmdRunner.DeleteDirectoryWithRetry(this.EnlistmentRoot);
            }
            else
            {
                // TODO(Mac): BashRunner.DeleteDirectory(this.EnlistmentRoot);
            }
        }
示例#14
0
        public TestResultSummaryViewModel(TestSummaryItem summaryItem, PipelineConfiguration pipelineConfiguration, bool includeOthersInTotal)
        {
            PassedTests = summaryItem.GetPassedTestsCount();
            FailedTests = summaryItem.GetFailedTestsCount();
            OtherTests  = summaryItem.GetOtherTestsCount();

            TotalTests = TestResultsHelper.GetTotalTestCountBasedOnUserConfiguration(summaryItem.TestCountByOutCome,
                                                                                     includeOthersInTotal);

            PassingRate = TestResultsHelper.GetTestOutcomePercentageString(PassedTests, TotalTests);

            Duration = TimeSpanFormatter.FormatDurationWithUnit(summaryItem.Duration);

            Url = pipelineConfiguration.TestTabLink;
        }
        public TestInfoByPriorityViewModel(int priority, Dictionary <TestOutcomeForPriority, int> testCountByOutcome,
                                           bool includeOthersInTotal)
        {
            Priority = priority;

            TestCount = TestResultsHelper.GetTotalTestCountBasedOnUserConfiguration(
                testCountByOutcome, includeOthersInTotal);

            if (TestCount > 0)
            {
                var passingTests = GetPassingTestCountByOutcome(testCountByOutcome);

                PassingRate = TestResultsHelper.GetTestOutcomePercentageString(passingTests, TestCount);
            }
        }
        public void DeleteEnlistment()
        {
            TestResultsHelper.OutputGVFSLogs(this);

            // TODO(Mac): Figure out why the call to DeleteDirectoryWithRetry is not returning.
            // Once this is resolved, we can replace this duplicated code with RepositoryHelpers.DeleteTestDirectory
            if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
            {
                // Use cmd.exe to delete the enlistment as it properly handles tombstones and reparse points
                CmdRunner.DeleteDirectoryWithUnlimitedRetries(this.EnlistmentRoot);
            }
            else
            {
                // BashRunner.DeleteDirectoryWithUnlimitedRetries(this.EnlistmentRoot);
            }
        }
示例#17
0
        private async void btnStart_Click(object sender, System.EventArgs e)
        {
            var config = TryReadHttpTestConfig();

            if (config == null)
            {
                MessageBox.Show(@"输入参数不合法");
                return;
            }

            var testResults = await MainVo.StartTest(config);

            var summary     = TestResultsSummary.Create(testResults.Items);
            var resultsDesc = TestResultsHelper.CreateResultsDesc(testResults, summary);

            this.txtResult.Text = resultsDesc;
        }
示例#18
0
文件: Program.cs 项目: wjmjimmie/GVFS
        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();
            }
        }
示例#19
0
        public void DeleteEnlistment()
        {
            string watchmanLocation = ProcessHelper.GetProgramLocation("watchman");

            if (!string.IsNullOrEmpty(watchmanLocation))
            {
                try
                {
                    ProcessHelper.Run(Path.Combine(watchmanLocation, "watchman"), $"watch-del {this.RepoRoot}");
                }
                catch (Exception ex)
                {
                    Console.WriteLine($"Failed to delete watch on {this.RepoRoot}. {ex.ToString()}");
                }
            }

            TestResultsHelper.OutputScalarLogs(this);
            RepositoryHelpers.DeleteTestDirectory(this.EnlistmentRoot);
        }
示例#20
0
        private static void RunAfterAllTests()
        {
            if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
            {
                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();
            }

            PrintTestCaseStats.PrintRunTimeStats();
        }
示例#21
0
        private static GVFSFunctionalTestEnlistment CloneAndMount(string pathToGvfs, string enlistmentRoot, string commitish)
        {
            GVFSFunctionalTestEnlistment enlistment = new GVFSFunctionalTestEnlistment(
                pathToGvfs,
                enlistmentRoot ?? GetUniqueEnlistmentRoot(),
                Properties.Settings.Default.RepoToClone,
                commitish ?? Properties.Settings.Default.Commitish);

            try
            {
                enlistment.CloneAndMount();
            }
            catch (Exception e)
            {
                Console.WriteLine("Unhandled exception in CloneAndMount: " + e.ToString());
                TestResultsHelper.OutputGVFSLogs(enlistment);
                throw;
            }

            return(enlistment);
        }
        public static GVFSFunctionalTestEnlistment CloneAndMount(string pathToGvfs, string commitish = null)
        {
            GVFSFunctionalTestEnlistment enlistment = new GVFSFunctionalTestEnlistment(
                pathToGvfs,
                Properties.Settings.Default.EnlistmentRoot,
                Properties.Settings.Default.RepoToClone,
                commitish == null ? Properties.Settings.Default.Commitish : commitish);

            try
            {
                enlistment.UnmountAndDeleteAll();
                enlistment.CloneAndMount();
            }
            catch (Exception e)
            {
                Console.WriteLine("Unhandled exception in CloneAndMount: " + e.ToString());
                TestResultsHelper.OutputGVFSLogs(enlistment);
                throw;
            }

            return(enlistment);
        }
示例#23
0
        private static GSDFunctionalTestEnlistment CloneAndMount(string pathToGvfs, string enlistmentRoot, string commitish, string localCacheRoot, bool skipPrefetch = false)
        {
            GSDFunctionalTestEnlistment enlistment = new GSDFunctionalTestEnlistment(
                pathToGvfs,
                enlistmentRoot ?? GetUniqueEnlistmentRoot(),
                GSDTestConfig.RepoToClone,
                commitish ?? Properties.Settings.Default.Commitish,
                localCacheRoot ?? GSDTestConfig.LocalCacheRoot);

            try
            {
                enlistment.CloneAndMount(skipPrefetch);
            }
            catch (Exception e)
            {
                Console.WriteLine("Unhandled exception in CloneAndMount: " + e.ToString());
                TestResultsHelper.OutputGSDLogs(enlistment);
                throw;
            }

            return(enlistment);
        }
        private async void BtnStart_Click(object sender, EventArgs e)
        {
            var config = TryReadHttpTestConfig();

            if (config == null)
            {
                MessageBox.Show(@"输入参数不合法");
                return;
            }

            var testClientSpans = Vo.CreateTestClientSpans(config);
            var testResults     = await Vo.StartTest(config, testClientSpans);

            var summary = TestResultsSummary.Create(testResults.Items);

            this.txtData.Text = testClientSpans.ToJson(true);
            this.txtUri.Text  = config.TraceApiEndPoint;

            testResults.Data = string.Empty;
            var resultsDesc = TestResultsHelper.CreateResultsDesc(testResults, summary);

            this.txtResult.Text = resultsDesc;
        }
示例#25
0
 public void DeleteEnlistment()
 {
     TestResultsHelper.OutputGVFSLogs(this);
     RepositoryHelpers.DeleteTestDirectory(this.EnlistmentRoot);
 }