/// <summary> /// Checks the rules stored in the dictionary /// </summary> public void CheckRules() { ClearMessages(); // Rebuilds everything Interpreter.Compiler compiler = new Interpreter.Compiler(EFSSystem, EFSSystem.ShouldRebuild); compiler.Compile(); EFSSystem.ShouldRebuild = false; // Check rules RuleCheckerVisitor visitor = new RuleCheckerVisitor(this); visitor.visit(this, true); }
/// <summary> /// Checks the rules stored in the dictionary /// </summary> public void CheckRules() { Util.DontNotify(() => { try { // Rebuilds everything EFSSystem.Compiler.Compile_Synchronous(EFSSystem.ShouldRebuild); EFSSystem.ShouldRebuild = false; // Check rules RuleCheckerVisitor visitor = new RuleCheckerVisitor(this); visitor.visit(this, true); } catch (Exception) { } }); }
/// <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 (var 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(dictionary.TranslationDictionary); } } } } } // Make sure everything is recompiled Console.Out.WriteLine("Recompiling everything"); efsSystem.Compiler.Compile_Synchronous(true, false); // Ensure the model is consistent Console.Out.WriteLine("Checking model"); RuleCheckerVisitor.IsThereAnyError isThereAnyError = new RuleCheckerVisitor.IsThereAnyError(); foreach (Dictionary dictionary in efsSystem.Dictionaries) { RuleCheckerVisitor checker = new RuleCheckerVisitor(dictionary); checker.visit(dictionary); isThereAnyError.visit(dictionary); } // Dumps all errors found 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, 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', ' '); TestCase testCase = EnclosingFinder<TestCase>.find(expect.Expectation); if (testCase.ImplementationCompleted) { Console.Out.WriteLine(" failed (unexpected) :" + message); failed = true; } else { Console.Out.WriteLine(" failed (expected) : " + message); } } 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; }
/// <summary> /// Checks the rules stored in the dictionary /// </summary> public void CheckRules() { Util.DontNotify(() => { try { // Rebuilds everything EFSSystem.Compiler.Compile_Synchronous(EFSSystem.ShouldRebuild); EFSSystem.ShouldRebuild = false; MarkingHistory.PerformMark(() => { // Check rules RuleCheckerVisitor visitor = new RuleCheckerVisitor(this); visitor.visit(this, true); }); } catch (Exception) { } }); }