예제 #1
0
        public static bool IsBuildSuccessful(int timeoutInSecs)
        {
            bool isBuildSuccessful = false;

            Ide.WaitUntil(() => {
                var actualStatusMessage = Workbench.GetStatusMessage();
                if (actualStatusMessage == "Build successful.")
                {
                    isBuildSuccessful = true;
                    return(true);
                }
                if (actualStatusMessage == "Build failed.")
                {
                    isBuildSuccessful = false;
                    return(true);
                }
                var match = buildRegex.Match(actualStatusMessage);
                if (match != null && match.Success)
                {
                    isBuildSuccessful = string.Equals(match.Groups ["errors"].ToString(), "0");
                    return(true);
                }
                return(false);
            },
                          pollStep: 5 * 1000,
                          timeout: timeoutInSecs * 1000,
                          timeoutMessage: () => "GetStatusMessage=" + Workbench.GetStatusMessage());

            return(isBuildSuccessful);
        }
예제 #2
0
 static void PollStatusMessage(string[] statusMessage, int timeoutInSecs, int pollStepInSecs, bool waitForMessage = true)
 {
     Ide.WaitUntil(() => {
         var actualStatusMessage = Workbench.GetStatusMessage();
         return(waitForMessage == (statusMessage.Contains(actualStatusMessage, StringComparer.OrdinalIgnoreCase)));
     }, pollStep: pollStepInSecs * 1000, timeout: timeoutInSecs * 1000);
 }
예제 #3
0
        public static void WaitForIdeIdle(uint totalTimeoutInSecs = 100, uint idlePeriodInSecs = 10, string[] ignoreMessages = null)
        {
            uint             retriesLeft = (uint)Math.Ceiling((double)totalTimeoutInSecs / (double)idlePeriodInSecs);
            ManualResetEvent resetEvent  = new ManualResetEvent(false);

            if (ignoreMessages != null)
            {
                ignoreStatusMessgaes.AddRange(ignoreMessages);
            }

            var timer = new System.Timers.Timer {
                Interval  = idlePeriodInSecs * 1000,
                AutoReset = true
            };
            bool didTimeout = false;

            var initialStatusMessage = Workbench.GetStatusMessage(waitForNonEmpty: false);

            timer.Elapsed += (sender, e) => {
                if (retriesLeft == 0)
                {
                    didTimeout = true;
                    resetEvent.Set();
                }

                var finalStatusMessage = Workbench.GetStatusMessage(waitForNonEmpty: false);
                var isIdle             = string.Equals(initialStatusMessage, finalStatusMessage) && !ignoreStatusMessgaes.Contains(finalStatusMessage);

                if (!isIdle)
                {
                    retriesLeft--;
                    initialStatusMessage = finalStatusMessage;
                }
                if (isIdle)
                {
                    resetEvent.Set();
                }
            };

            timer.Start();
            resetEvent.WaitOne();
            timer.Stop();
            timer.AutoReset = false;
            timer.Dispose();

            if (didTimeout)
            {
                throw new TimeoutException("Timeout waiting for IDE to be ready and idle");
            }
        }
예제 #4
0
파일: Ide.cs 프로젝트: morhir/monodevelop
 static void PollStatusMessage(string[] statusMessage, int timeoutInSecs, int pollStepInSecs, bool waitForMessage = true)
 {
     Ide.WaitUntil(() => {
         string actualStatusMessage = string.Empty;
         try {
             actualStatusMessage = Workbench.GetStatusMessage();
             return(waitForMessage == (statusMessage.Contains(actualStatusMessage, StringComparer.OrdinalIgnoreCase)));
         } catch (TimeoutException e) {
             throw new TimeoutException(
                 string.Format("Timed out. Found status message '{0}'\nand expected one of these:\n\t {1}",
                               actualStatusMessage, string.Join("\n\t", statusMessage)), e);
         }
     }, pollStep: pollStepInSecs * 1000, timeout: timeoutInSecs * 1000);
 }
예제 #5
0
        public void DontShowPackageUpdatesAvailable()
        {
            var templateOptions = new TemplateSelectionOptions {
                CategoryRoot     = OtherCategoryRoot,
                Category         = ".NET",
                TemplateKindRoot = GeneralKindRoot,
                TemplateKind     = "Console Project"
            };
            var projectDetails = new ProjectDetails(templateOptions);

            CreateProject(templateOptions, projectDetails);
            NuGetController.AddPackage(new NuGetPackageOptions {
                PackageName  = "CommandLineParser",
                Version      = "1.9.3.34",
                IsPreRelease = false
            }, this);

            string solutionFolder = GetSolutionDirectory();
            string solutionPath   = Path.Combine(solutionFolder, projectDetails.SolutionName + ".sln");
            var    projectPath    = Path.Combine(solutionFolder, projectDetails.ProjectName, projectDetails.ProjectName + ".csproj");

            Assert.IsTrue(File.Exists(projectPath));

            Workbench.CloseWorkspace(this);

            Workbench.OpenWorkspace(solutionPath, this);
            try {
                const string expected = "When a solution is opened and package updates are available, it don't show in status bar";
                ReproStep(expected);
                Ide.WaitForPackageUpdate();
                var failureMessage = string.Format("Expected: {0}\nActual: {1}",
                                                   expected, "When a solution is opened and package updates are available, it shows in status bar");
                ReproStep(failureMessage);
                Assert.Fail(failureMessage);
            } catch (TimeoutException) {
                Session.DebugObject.Debug("WaitForPackageUpdate throws TimeoutException as expected");
            }
            Ide.WaitForSolutionLoaded();
            TakeScreenShot("Solution-Ready");
        }
예제 #6
0
        public static void WaitForIdeIdle(uint totalTimeoutInSecs = 100, uint idlePeriodInSecs = 1, string[] ignoreMessages = null)
        {
            var ignoreStatusMessages = globalIgnoreStatusMessages.ToList();

            if (ignoreMessages != null)
            {
                ignoreStatusMessages.AddRange(ignoreMessages);
            }

            var initialStatusMessage = Workbench.GetStatusMessage(waitForNonEmpty: false);

            PollTimer((int)totalTimeoutInSecs * 1000, (int)idlePeriodInSecs * 1000, () => {
                var finalStatusMessage = Workbench.GetStatusMessage(waitForNonEmpty: false);
                var isIdle             = string.Equals(initialStatusMessage, finalStatusMessage) && !ignoreStatusMessages.Contains(finalStatusMessage);

                if (!isIdle)
                {
                    initialStatusMessage = finalStatusMessage;
                }
                return(isIdle);
            });
        }
예제 #7
0
        public void TestLocalCopyPreservedUpdate()
        {
            var templateOptions = new TemplateSelectionOptions {
                CategoryRoot     = OtherCategoryRoot,
                Category         = ".NET",
                TemplateKindRoot = GeneralKindRoot,
                TemplateKind     = "Console Project"
            };
            var projectDetails = new ProjectDetails(templateOptions);

            CreateProject(templateOptions, projectDetails);
            NuGetController.AddPackage(new NuGetPackageOptions {
                PackageName  = "CommandLineParser",
                Version      = "1.9.71",
                IsPreRelease = false
            }, this);

            string solutionFolder = GetSolutionDirectory();
            string solutionPath   = Path.Combine(solutionFolder, projectDetails.SolutionName + ".sln");
            var    projectPath    = Path.Combine(solutionFolder, projectDetails.ProjectName, projectDetails.ProjectName + ".csproj");

            Assert.IsTrue(File.Exists(projectPath));

            ReproStep("Check 'Local Copy' on CommandLine package under References");

            Workbench.CloseWorkspace(this);

            AddOrCheckLocalCopy(projectPath, true);

            Workbench.OpenWorkspace(solutionPath, this);

            NuGetController.UpdateAllNuGetPackages(this);

            ReproStep("Check if CommandLine package under References has 'Local Copy' checked");
            AddOrCheckLocalCopy(projectPath, false);
        }
예제 #8
0
 public static bool RebuildSolution(bool isPass = true, int timeoutInSecs = 360)
 {
     Session.RunAndWaitForTimer(() => Session.ExecuteCommand(ProjectCommands.RebuildSolution), "Ide.Shell.ProjectBuilt", timeoutInSecs * 1000);
     return(isPass == Workbench.IsBuildSuccessful(timeoutInSecs));
 }
예제 #9
0
 public static bool BuildSolution(bool isPass = true, int timeoutInSecs = 360)
 {
     Session.ExecuteCommand(ProjectCommands.BuildSolution);
     return(isPass == Workbench.IsBuildSuccessful(timeoutInSecs));
 }