Пример #1
0
        public override void Cancel()
        {
            if (_nightlyListener != null)
            {
                _nightlyListener.Stop();
                _nightlyListener = null;
            }

            bool runAgain = MainWindow.NightlyRunIndefinitely.Checked;

            if (Math.Abs(MainWindow.RunElapsedTime.TotalMinutes - (int)MainWindow.NightlyDuration.Value * MINUTES_PER_INCREMENT) > 5)
            {
                runAgain = false;
            }

            base.Cancel();

            if (runAgain)
            {
                // Automaticly run again, but delayed to allow everything else to close before
                // trying to delete all the files of the project that was just running.
                // The recursive deletion can leave the directory locked and denying access
                // until the computer is restarted.
                _runAgainTimer = new Timer {
                    Interval = 30 * 1000
                };                                                      // 30 seconds - to be safe
                _runAgainTimer.Tick += (o, args) =>
                {
                    _runAgainTimer.Stop();
                    _runAgainTimer = null;
                    MainWindow.RunByTimer(this);
                };
                _runAgainTimer.Start();
            }
        }
Пример #2
0
        private void StartNightly()
        {
            _labels.Clear();
            _findTest.Clear();

            if (File.Exists(MainWindow.DefaultLogFile))
            {
                Try.Multi <Exception>(() => File.Delete(MainWindow.DefaultLogFile), 4, false);
            }
            var logsDirectory = MainWindow.GetLogsDir();

            if (!Directory.Exists(logsDirectory))
            {
                Directory.CreateDirectory(logsDirectory);
            }

            MainWindow.SetStatus("Running nightly pass...");
            var architecture = MainWindow.NightlyBuildType.SelectedIndex == 0 ? 32 : 64;

            MainWindow.SelectBuild(architecture == 32 ? SkylineTesterWindow.BuildDirs.nightly32 : SkylineTesterWindow.BuildDirs.nightly64);
            _saveSelectedBuild = MainWindow.SelectedBuild;
            MainWindow.ResetElapsedTime();

            MainWindow.TestsRun       = 0;
            MainWindow.LastTestResult = null;
            MainWindow.NewNightlyRun  = new Summary.Run
            {
                Date = DateTime.Now
            };
            MainWindow.Summary.Runs.Add(MainWindow.NewNightlyRun);
            MainWindow.AddRun(MainWindow.NewNightlyRun, MainWindow.NightlyRunDate);
            MainWindow.NightlyRunDate.SelectedIndex = 0;

            StartLog("Nightly", MainWindow.Summary.GetLogFile(MainWindow.NewNightlyRun));

            var revisionWorker = new BackgroundWorker();

            revisionWorker.DoWork += (s, a) =>
            {
                var revision = GetRevision(true);
                lock (MainWindow.NewNightlyRun)
                {
                    MainWindow.NewNightlyRun.Revision = _revision = revision;
                    MainWindow.Invoke(new System.Action(() => MainWindow.UpdateRun(MainWindow.NewNightlyRun, MainWindow.NightlyRunDate)));
                }
            };
            revisionWorker.RunWorkerAsync();

            _updateTimer = new Timer {
                Interval = 300
            };
            _updateTimer.Tick += (s, a) => RunUI(() =>
            {
                try
                {
                    UpdateNightly();
                }
                catch (Exception x)
                {
                    _updateTimer.Stop();

                    MessageBox.Show(string.Format("Unexpected Error: {0}", x));

                    Stop(false);
                }
            });

            _stopTimer = new Timer {
                Interval = (int)MainWindow.NightlyDuration.Value * MINUTES_PER_INCREMENT * 60 * 1000
            };                                                                                                          // Interval in milliseconds
            _stopTimer.Tick += (s, a) => RunUI(() =>
            {
                if (_stopTimer != null)
                {
                    _stopTimer.Stop();
                    _stopTimer = null;
                }
                MainWindow.StopByTimer();
            });

            _architecture = (MainWindow.NightlyBuildType.SelectedIndex == 0)
                ? 32
                : 64;
            var architectureList = new[] { _architecture };
            var branchUrl        = MainWindow.NightlyBuildTrunk.Checked
                ? @"https://github.com/ProteoWizard/pwiz"
                : MainWindow.NightlyBranchUrl.Text;
            var buildRoot = Path.Combine(MainWindow.GetNightlyBuildRoot(), "pwiz");

            // Build Skyline.exe without testing during the build
            if (!TabBuild.CreateBuildCommands(branchUrl, buildRoot, architectureList, true, false, false))
            {
                MainWindow.CommandShell.Add("# Nightly cancelled.");
            }
            else
            {
                // Then add the testing command
                int stressTestLoopCount;
                if (!int.TryParse(MainWindow.NightlyRepeat.Text, out stressTestLoopCount))
                {
                    stressTestLoopCount = 0;
                }
                MainWindow.AddTestRunner("offscreen=on quality=on loop=-1 " +
                                         (stressTestLoopCount > 1 || MainWindow.NightlyRunPerfTests.Checked ? "pass0=off pass1=off " : "pass0=on pass1=on ") + // Skip the special passes if we're here to do stresstests or perftests
                                         (MainWindow.NightlyRunPerfTests.Checked ? " perftests=on" : string.Empty) +
                                         " runsmallmoleculeversions=on" +                                                                                      // Run any provided tests that convert the document to small molecules
                                         " retrydatadownloads=on" +                                                                                            // In case of test failure, re-download test data in case staleness was the issue
                                         (MainWindow.NightlyRandomize.Checked ? " random=on" : " random=off") +
                                         (stressTestLoopCount > 1 ? " repeat=" + MainWindow.NightlyRepeat.Text : string.Empty)
                                         + " dmpdir=" + MainWindow.GetMinidumpDir());
                MainWindow.CommandShell.Add("# Nightly finished.");
            }
            MainWindow.CommandShell.IsUnattended = MainWindow.NightlyExit.Checked;

            MainWindow.RunCommands();

            if (_updateTimer != null)
            {
                _updateTimer.Start();
            }
            if (_stopTimer != null)
            {
                _stopTimer.Start();
            }

            _nightlyListener = new NightlyListener(_stopTimer);
        }