예제 #1
0
        public ParseResult Run([NotNull] string code, [CanBeNull] string gold, RecoveryStrategy recoveryStrategy)
        {
            if (_parserHost == null)
            {
                _parserHost       = new ParserHost();
                _compositeGrammar = _parserHost.MakeCompositeGrammar(SynatxModules);
            }
            var source = new SourceSnapshot(code);

            if (StartRule == null)
            {
                return(null);
            }

            try
            {
                var res = _parserHost.DoParsing(source, _compositeGrammar, StartRule, recoveryStrategy);
                this.Exception = null;
                return(res);
            }
            catch (Exception ex)
            {
                this.Exception = ex;
                return(null);
            }
        }
예제 #2
0
        public ParseResult Run(RecoveryStrategy recoveryStrategy)
        {
            if (TestSuit.TestState == TestState.Ignored)
            {
                return(null);
            }

            Nitra.DebugStrategies.RecoveryDebug.CurrentTestName = Name;

            var result = TestSuit.Run(Code, Gold, recoveryStrategy);

            if (result == null)
            {
                return(null);
            }

            var gold = Gold;
            var ast  = result.CreateAst();
            var prettyPrintResult = ast.ToString(PrettyPrintOptions.DebugIndent | PrettyPrintOptions.MissingNodes);

            PrettyPrintResult = prettyPrintResult;
            TestState         = gold == prettyPrintResult ? TestState.Success : TestState.Failure;
            Result            = result;
            return(result);
        }
예제 #3
0
    protected Retryer(RecoveryStrategy recoveryStrategy, bool disposeOnError, CancellationToken cancellationToken)
    {
        this.recoveryStrategy  = recoveryStrategy;
        this.cancellationToken = cancellationToken;
        this.disposeOnError    = disposeOnError;

        if (cancellationToken.CanBeCanceled)
        {
            cancellationToken.Register(OnCanceled);
        }
    }
예제 #4
0
 internal RecoveringHookRetryer(string sourcePath,
                                RecoveryStrategy recoveryStrategy,
                                IReadOnlyList <string> sourcePatterns,
                                IReadOnlyList <string> sourceIgnorePatterns,
                                FileSystemEventHandler?onCreated,
                                FileSystemEventHandler?onModified,
                                FileSystemEventHandler?onDeleted,
                                CancellationToken cancellationToken)
     : base(recoveryStrategy, disposeOnError: false, cancellationToken)
 {
     this.sourcePath           = sourcePath;
     this.sourcePatterns       = sourcePatterns;
     this.sourceIgnorePatterns = sourceIgnorePatterns;
     this.onCreated            = onCreated;
     this.onModified           = onModified;
     this.onDeleted            = onDeleted;
 }
예제 #5
0
파일: TestVm.cs 프로젝트: hwwang/Nitra
        public ParseResult Run(RecoveryStrategy recoveryStrategy)
        {
            if (TestSuit.TestState == TestState.Ignored)
            return null;

              Nitra.DebugStrategies.RecoveryDebug.CurrentTestName = Name;

              var result = TestSuit.Run(Code, Gold, recoveryStrategy);
              if (result == null)
            return null;

              var gold = Gold;
              var ast = result.CreateAst();
              var prettyPrintResult = ast.ToString(PrettyPrintOptions.DebugIndent | PrettyPrintOptions.MissingNodes);
              PrettyPrintResult = prettyPrintResult;
              TestState = gold == prettyPrintResult ? TestState.Success : TestState.Failure;
              Result = result;
              return result;
        }
예제 #6
0
    /// <param name="recoveryStrategy"> If you'd like to specify <see cref="RecoveryStrategy.None"/>, instead call <see cref="FileSystemHook.Hook(string, IEnumerable{string}, IEnumerable{string}?, FileSystemEventHandler?, FileSystemEventHandler?, FileSystemEventHandler?, ErrorEventHandler?, CancellationToken, bool)"/>. </param>
    public static IDisposable RecoverableHook(RecoveryStrategy recoveryStrategy,
                                              string sourcePath,
                                              IEnumerable <string> sourcePatterns,
                                              IEnumerable <string>?sourceIgnorePatterns = null,
                                              FileSystemEventHandler?onCreated          = null,
                                              FileSystemEventHandler?onModified         = null,
                                              FileSystemEventHandler?onDeleted          = null,
                                              OnError?errorObserver = null,
                                              CancellationToken cancellationToken = default)
    {
        if (recoveryStrategy is null)
        {
            throw new ArgumentNullException(nameof(recoveryStrategy));
        }

        var patterns       = sourcePatterns?.ToList() ?? throw new ArgumentNullException(nameof(sourcePatterns));
        var ignorePatterns = sourceIgnorePatterns?.ToArray() ?? Array.Empty <string>();

        var retryer = new RecoveringHookRetryer(sourcePath, recoveryStrategy, patterns, ignorePatterns, onCreated, onModified, onDeleted, cancellationToken);

        retryer.Start();
        return(retryer.Task);
    }
예제 #7
0
        private void RunTests(RecoveryStrategy recoveryStrategy)
        {
            if (_testsTreeView.ItemsSource == null)
            return;

              var testSuits = (ObservableCollection<TestSuitVm>)_testsTreeView.ItemsSource;

              foreach (var testSuit in testSuits)
              {
            foreach (var test in testSuit.Tests)
              RunTest(test, recoveryStrategy);

            testSuit.TestStateChanged();
              }
        }
예제 #8
0
        private void RunTest(RecoveryStrategy recoveryStrategy)
        {
            {
            var test = _testsTreeView.SelectedItem as TestVm;
            if (test != null)
            {
              RunTest(test, recoveryStrategy);
              test.TestSuit.TestStateChanged();

              if (test.TestState == TestState.Failure)
            _testResultDiffTabItem.IsSelected = true;
            }
              }
              var testSuit = _testsTreeView.SelectedItem as TestSuitVm;
              if (testSuit != null)
              {
            foreach (var test in testSuit.Tests)
              RunTest(test, recoveryStrategy);
            testSuit.TestStateChanged();
              }
        }
예제 #9
0
        private void RunTest(TestVm test, RecoveryStrategy recoveryStrategy)
        {
            test.Run(recoveryStrategy);

              ShowDiff(test);
        }
예제 #10
0
파일: TestSuitVm.cs 프로젝트: hwwang/Nitra
        public ParseResult Run([NotNull] string code, [CanBeNull] string gold, RecoveryStrategy recoveryStrategy)
        {
            if (_parserHost == null)
              {
            _parserHost = new ParserHost();
            _compositeGrammar = _parserHost.MakeCompositeGrammar(SynatxModules);
              }
              var source = new SourceSnapshot(code);

              if (StartRule == null)
            return null;

              try
              {
            var res = _parserHost.DoParsing(source, _compositeGrammar, StartRule, recoveryStrategy);
            this.Exception = null;
            return res;
              }
              catch (Exception ex)
              {
            this.Exception = ex;
            return null;
              }
        }