Exemplo n.º 1
0
        /// <summary>
        /// Displays the progress dialog and handle exceptions, if any
        /// </summary>
        /// <param name="owner"></param>
        /// <param name="handler"></param>
        public static void CreateReport(Form owner, ReportHandler handler)
        {
            Exception exception = null;

            try
            {
                SynchronizerList.SuspendSynchronization();

                ProgressDialog dialog = new ProgressDialog("Generating report", handler);
                dialog.ShowDialog(owner);
            }
            catch (Exception e)
            {
                exception = e;
            }
            finally
            {
                SynchronizerList.ResumeSynchronization();
            }

            if (handler.Error != null)
            {
                exception = handler.Error;
            }

            if (exception != null)
            {
                MessageBox.Show(owner, exception.Message, "An error has occured", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            }
        }
Exemplo n.º 2
0
            /// <summary>
            ///     Executes the tests in the background thread
            /// </summary>
            public override void ExecuteWork()
            {
                if (Window != null)
                {
                    SynchronizerList.SuspendSynchronization();
                    MarkingHistory.PerformMark(() =>
                    {
                        SubSequence subSequence = TestCase.Enclosing as SubSequence;
                        if (subSequence != null && TestCase.Steps.Count > 0)
                        {
                            Step step  = null;
                            bool found = false;
                            foreach (TestCase current in subSequence.TestCases)
                            {
                                if (found && current.Steps.Count > 0)
                                {
                                    step = (Step)current.Steps[0];
                                    break;
                                }

                                found = (current == TestCase);
                            }

                            Runner runner = Window.GetRunner(subSequence);
                            runner.RunUntilStep(step);
                        }
                    });
                    SynchronizerList.ResumeSynchronization();
                }
            }
Exemplo n.º 3
0
            /// <summary>
            ///     Executes the tests in the background thread
            /// </summary>
            public override void ExecuteWork()
            {
                DateTime start = DateTime.Now;

                SynchronizerList.SuspendSynchronization();

                // Compile everything
                EfsSystem.Instance.Compiler.Compile_Synchronous(EfsSystem.Instance.ShouldRebuild);
                EfsSystem.Instance.ShouldRebuild = false;

                Failed = 0;
                ArrayList tests = Dictionary.Tests;

                tests.Sort();
                foreach (Frame frame in tests)
                {
                    Dialog.UpdateMessage("Executing " + frame.Name);

                    const bool ensureCompilationDone = false;
                    int        failedFrames          = frame.ExecuteAllTests(ensureCompilationDone, Settings.Default.CheckForCompatibleChanges);
                    if (failedFrames > 0)
                    {
                        Failed += 1;
                    }
                }
                EfsSystem.Instance.Runner = null;
                SynchronizerList.ResumeSynchronization();

                Span = DateTime.Now.Subtract(start);
            }
Exemplo n.º 4
0
        private static void Main(string[] args)
        {
            try
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                XmlConfigurator.Configure(new FileInfo("logconfig.xml"));

                Options.Options.SetSettings();
                EfsSystem.Instance.DictionaryChangesOnFileSystem += HandleInstanceDictionaryChangesOnFileSystem;

                MainWindow window = new MainWindow();
                Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;

                {
                    // TRICKY SECTION
                    // This thread is mandatory otherwise WCF does not create a new thread to handle the service requests.
                    // Since the call to Cycle is blocking, creating such threads is mandatory
                    Thread thread = ThreadUtil.CreateThread("EFS Service", HostEfsService);
                    thread.Start();
                }

                // Opens the Dictionary files and check them
                bool shouldPlace = true;
                foreach (string fileName in args)
                {
                    const bool        allowErrors       = false;
                    OpenFileOperation openFileOperation = new OpenFileOperation(fileName, EfsSystem.Instance, allowErrors, true);
                    openFileOperation.ExecuteUsingProgressDialog(GuiUtils.MdiWindow, "Opening file " + fileName, false);
                    if (openFileOperation.Dictionary != null)
                    {
                        window.SetupWindows(openFileOperation.Dictionary, shouldPlace);
                        shouldPlace = false;
                    }
                    else
                    {
                        Console.Out.WriteLine("Cannot open dictionary file " + fileName);
                    }
                }

                CheckModelOperation checkModel = new CheckModelOperation();
                checkModel.ExecuteUsingProgressDialog(GuiUtils.MdiWindow, "Checking model");

                Application.Run(window);
                CloseEfsService();
            }
            finally
            {
                Util.UnlockAllFiles();
            }

            EfsSystem.Instance.Stop();
            SynchronizerList.Stop();
        }
Exemplo n.º 5
0
            /// <summary>
            ///     Executes the work in the background task
            /// </summary>
            public override void ExecuteWork()
            {
                SynchronizerList.SuspendSynchronization();

                if (Window != null)
                {
                    Window.SetFrame(Frame);
                    MarkingHistory.PerformMark(() =>
                    {
                        try
                        {
                            // Compile everything
                            Frame.EFSSystem.Compiler.Compile_Synchronous(Frame.EFSSystem.ShouldRebuild);
                            Frame.EFSSystem.ShouldRebuild = false;

                            Failed = 0;
                            ArrayList subSequences = Frame.SubSequences;
                            subSequences.Sort();
                            foreach (SubSequence subSequence in subSequences)
                            {
                                if (subSequence.getCompleted())
                                {
                                    Dialog.UpdateMessage("Executing " + subSequence.Name);

                                    const bool explain        = false;
                                    const bool ensureCompiled = false;
                                    Frame.EFSSystem.Runner    = new Runner(subSequence, explain, ensureCompiled,
                                                                           Settings.Default.CheckForCompatibleChanges);

                                    int testCasesFailed = subSequence.ExecuteAllTestCases(Frame.EFSSystem.Runner);
                                    if (testCasesFailed > 0)
                                    {
                                        subSequence.AddError("Execution failed");
                                        Failed += 1;
                                    }
                                }
                                else
                                {
                                    subSequence.AddWarning(
                                        "Sub sequence not executed because it is not marked as completed");
                                }
                            }
                        }
                        finally
                        {
                            Frame.EFSSystem.Runner = null;
                        }
                    });
                }

                SynchronizerList.ResumeSynchronization();
            }
Exemplo n.º 6
0
        /// <summary>
        ///     Executes the operation in background using a progress handler
        /// </summary>
        /// <param name="mainForm">The enclosing form</param>
        /// <param name="message">The message to display on the dialog window</param>
        /// <param name="allowCancel">Indicates that the opeation can be canceled</param>
        public virtual void ExecuteUsingProgressDialog(Form mainForm, string message, bool allowCancel = true)
        {
            DateTime start = DateTime.Now;

            Util.DontNotify(() =>
            {
                try
                {
                    SynchronizerList.SuspendSynchronization();

                    if (ShowDialog)
                    {
                        Dialog = new ProgressDialog(message, this, allowCancel);
                        mainForm.Invoke((MethodInvoker)(() => Dialog.ShowDialog(mainForm)));
                    }
                    else
                    {
                        ExecuteWork();
                    }
                }
                catch (ThreadAbortException)
                {
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message + @"\n" + e.StackTrace, @"Exception raised");
                    // DefaultDesktopOnly option is added in order to avoid exceptions during nightbuild execution
                    MessageBox.Show(e.Message + @"\n" + e.StackTrace, @"Exception raised", MessageBoxButtons.OK,
                                    MessageBoxIcon.Error, MessageBoxDefaultButton.Button1,
                                    MessageBoxOptions.DefaultDesktopOnly);
                }
                finally
                {
                    Span = DateTime.Now.Subtract(start);
                    SynchronizerList.ResumeSynchronization();
                }
            });
        }