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(); }
/// <summary> /// Perform all functional tests defined in the .EFS file provided /// </summary> /// <param name="args"></param> /// <returns>the error code of the program</returns> private static int Main(string[] args) { int retVal = 0; EfsSystem efsSystem = EfsSystem.Instance; try { Console.Out.WriteLine("EFS Tester"); // Load the dictionaries provided as parameters Util.PleaseLockFiles = false; foreach (string arg in args) { Console.Out.WriteLine("Loading dictionary " + arg); Dictionary dictionary = Util.Load(efsSystem, new Util.LoadParams(arg) { LockFiles = false, Errors = null, UpdateGuid = false, ConvertObsolete = false }); if (dictionary == null) { Console.Out.WriteLine("Cannot load dictionary " + arg); return(-1); } } // Translate the sub sequences, if required Console.Out.WriteLine("Translating sub sequences"); foreach (Dictionary dictionary in efsSystem.Dictionaries) { foreach (Frame frame in dictionary.Tests) { foreach (SubSequence subSequence in frame.SubSequences) { if (subSequence.getCompleted()) { if (dictionary.TranslationDictionary != null) { subSequence.Translate(); } } } } } // Make sure everything is recompiled Console.Out.WriteLine("Recompiling everything"); efsSystem.Compiler.Compile_Synchronous(true); // Ensure the model is consistent Console.Out.WriteLine("Checking model"); foreach (Dictionary dictionary in efsSystem.Dictionaries) { RuleCheckerVisitor checker = new RuleCheckerVisitor(dictionary); checker.visit(dictionary); } // Dumps all errors found Util.IsThereAnyError isThereAnyError = new Util.IsThereAnyError(); if (isThereAnyError.ErrorsFound.Count > 0) { foreach (ElementLog error in isThereAnyError.ErrorsFound) { Console.Out.WriteLine(error.Log); } return(-1); } { // Perform functional test for last loaded dictionary Dictionary dictionary = efsSystem.Dictionaries.FindLast(x => true); Console.Out.WriteLine("Processing tests from dictionary " + dictionary.Name); foreach (Frame frame in dictionary.Tests) { Console.Out.WriteLine("Executing frame " + frame.FullName); foreach (SubSequence subSequence in frame.SubSequences) { Console.Out.WriteLine("Executing sub sequence " + subSequence.FullName); if (subSequence.getCompleted()) { Runner runner = new Runner(subSequence, false, true); runner.RunUntilStep(null); bool failed = false; foreach (ModelEvent evt in runner.FailedExpectations()) { Expect expect = evt as Expect; if (expect != null) { string message = expect.Message.Replace('\n', ' '); Console.Out.WriteLine(" failed :" + message); failed = true; } else { ModelInterpretationFailure modelInterpretationFailure = evt as ModelInterpretationFailure; if (modelInterpretationFailure != null) { Console.Out.WriteLine(" failed : " + modelInterpretationFailure.Message); failed = true; } } } if (failed) { Console.Out.WriteLine(" -> Failed"); retVal = -1; } else { Console.Out.WriteLine(" -> Success"); } } else { Console.Out.WriteLine(" -> Not executed because it is not marked as completed"); } } } } } finally { Util.UnlockAllFiles(); efsSystem.Stop(); } return(retVal); }