예제 #1
0
        private static void DiscoverUnitTests(IEnumerable <IXTestDiscoverer> tds, string slnPath, string slnSnapPath, string discoveredUnitTestsStore, string discoveredUnitDTestsStore, string buildOutputRoot, DateTime timeFilter, string[] ignoredTests)
        {
            Logger.LogInfo("DiscoverUnitTests: starting discovering.");
            var testsPerAssembly  = new PerDocumentLocationXTestCases();
            var dtestsPerAssembly = new PerDocumentLocationDTestCases();

            FindAndExecuteForEachAssembly(
                buildOutputRoot,
                timeFilter,
                (string assemblyPath) =>
            {
                var disc = new XUnitTestDiscoverer();
                disc.TestDiscovered.AddHandler(
                    new FSharpHandler <XTestCase>(
                        (o, ea) =>
                {
                    if (ea.CodeFilePath != null)
                    {
                        var cfp         = PathBuilder.rebaseCodeFilePath(FilePath.NewFilePath(slnPath), FilePath.NewFilePath(slnSnapPath), FilePath.NewFilePath(ea.CodeFilePath));
                        ea.CodeFilePath = cfp.Item;
                    }
                    var dl = new DocumentLocation {
                        document = FilePath.NewFilePath(ea.CodeFilePath), line = DocumentCoordinate.NewDocumentCoordinate(ea.LineNumber)
                    };
                    var tests = testsPerAssembly.GetOrAdd(dl, _ => new ConcurrentBag <XTestCase>());
                    tests.Add(ea);
                    var dtests = dtestsPerAssembly.GetOrAdd(dl, _ => new ConcurrentBag <DTestCase>());
                    dtests.Add(FromXTestCase(ea));
                }));
                disc.DiscoverTests(tds, FilePath.NewFilePath(assemblyPath), ignoredTests);
            });

            testsPerAssembly.Serialize(FilePath.NewFilePath(discoveredUnitTestsStore));
            dtestsPerAssembly.Serialize(FilePath.NewFilePath(discoveredUnitDTestsStore));
            Logger.LogInfo("Written discovered unit tests to {0} & {1}.", discoveredUnitTestsStore, discoveredUnitDTestsStore);
        }
예제 #2
0
        private static void FindSequencePointForType2(FilePath projectPath, FilePath projectSnapshotPath, PerDocumentSequencePoints perDocSP, ModuleDefinition module, TypeDefinition type)
        {
            foreach (MethodDefinition meth in type.Methods)
            {
                if (IsMethodSkipped(meth))
                {
                    continue;
                }

                var sps = from i in meth.Body.Instructions
                          where i.SequencePoint != null
                          where i.SequencePoint.StartLine != 0xfeefee
                          select new { module, meth, i.SequencePoint };

                int id = 0;
                foreach (var sp in sps)
                {
                    var fp     = PathBuilder.rebaseCodeFilePath(projectPath, projectSnapshotPath, FilePath.NewFilePath(sp.SequencePoint.Document.Url));
                    var seqPts = perDocSP.GetOrAdd(fp, _ => new ConcurrentBag <R4nd0mApps.TddStud10.Common.Domain.SequencePoint>());

                    seqPts.Add(new R4nd0mApps.TddStud10.Common.Domain.SequencePoint
                    {
                        id = new SequencePointId
                        {
                            methodId = new MethodId(AssemblyId.NewAssemblyId(sp.module.Mvid), MdTokenRid.NewMdTokenRid(sp.meth.MetadataToken.RID)),
                            uid      = id++
                        },
                        document    = fp,
                        startLine   = DocumentCoordinate.NewDocumentCoordinate(sp.SequencePoint.StartLine),
                        startColumn = DocumentCoordinate.NewDocumentCoordinate(sp.SequencePoint.StartColumn),
                        endLine     = DocumentCoordinate.NewDocumentCoordinate(sp.SequencePoint.EndLine),
                        endColumn   = DocumentCoordinate.NewDocumentCoordinate(sp.SequencePoint.EndColumn),
                    });
                }
            }
        }
예제 #3
0
        private static Tuple <bool, TestId> IsSequencePointAtStartOfAUnitTest(RunStartParams rsp, Mono.Cecil.Cil.SequencePoint sp, FilePath assemblyPath, Func <DocumentLocation, IEnumerable <DTestCase> > findTest)
        {
            if (sp == null)
            {
                return(new Tuple <bool, TestId>(false, null));
            }

            var dl = new DocumentLocation {
                document = PathBuilder.rebaseCodeFilePath(rsp.Solution.Path, rsp.Solution.SnapshotPath, FilePath.NewFilePath(sp.Document.Url)), line = DocumentCoordinate.NewDocumentCoordinate(sp.StartLine)
            };
            var test = findTest(dl).FirstOrDefault(t => t.Source.Equals(assemblyPath));

            if (test == null)
            {
                return(new Tuple <bool, TestId>(false, null));
            }
            else
            {
                return(new Tuple <bool, TestId>(
                           true,
                           new TestId(assemblyPath, dl)));
            }
        }
예제 #4
0
        private MofSpecification ParseMofSpecification()
        {
            Token                token;
            DocumentRange        documentRange;
            List <MofProduction> mofProductions = new List <MofProduction>();

            if (this.m_queue.Count > 0)
            {
                if (this.m_queue.Dequeue().Type == TokenType.StartOfInput)
                {
                    QualifierList qualifierList = null;
                    while (true)
                    {
                        if (this.m_queue.Count <= 0)
                        {
                            documentRange = new DocumentRange();
                            throw new ParseFailureException("No EndOfInput token found at the end of the input", documentRange);
                        }
                        token = this.m_queue.Peek();
                        TokenType type = token.Type;
                        if (type == TokenType.EndOfInput)
                        {
                            if (qualifierList == null)
                            {
                                return(new MofSpecification(mofProductions.ToArray()));
                            }
                            else
                            {
                                throw new ParseFailureException("Found qualifiers that are not applied to any production.", token.Location);
                            }
                        }
                        else
                        {
                            if (type == TokenType.Identifier)
                            {
                                if (qualifierList == null)
                                {
                                    qualifierList = new QualifierList(new Qualifier[0]);
                                }
                                TokenIdentifier tokenIdentifier = (TokenIdentifier)token;
                                if (!tokenIdentifier.IsKeyword)
                                {
                                    throw new ParseFailureException(string.Format("Unexpected identifier: {0}", tokenIdentifier), tokenIdentifier.Location);
                                }
                                else
                                {
                                    TokenKeyword tokenKeyword = (TokenKeyword)token;
                                    KeywordType  keywordType  = tokenKeyword.KeywordType;
                                    if (keywordType == KeywordType.CLASS)
                                    {
                                        mofProductions.Add(this.ParseClass(qualifierList));
                                        qualifierList = null;
                                        continue;
                                    }
                                    else
                                    {
                                        if (keywordType != KeywordType.INSTANCE)
                                        {
                                        }
                                        throw new ParseFailureException(string.Format("Unexpected keyword: {0}", tokenKeyword), tokenKeyword.Location);
                                    }
                                }
                            }
                            else if (type == TokenType.Alias)
                            {
                                break;
                            }
                            else if (type == TokenType.Pragma)
                            {
                                if (qualifierList == null)
                                {
                                    mofProductions.Add(this.ParseCompilerDirective());
                                    continue;
                                }
                                else
                                {
                                    throw new ParseFailureException("Qualifiers are not legal on pragmas.", token.Location);
                                }
                            }
                            if (type != TokenType.OpenBracket)
                            {
                                break;
                            }
                            qualifierList = this.ParseQualifierList();
                        }
                    }
                    throw new ParseFailureException("Unexpected token", token.Location);
                }
                else
                {
                    DocumentCoordinate documentCoordinate  = new DocumentCoordinate();
                    DocumentCoordinate documentCoordinate1 = new DocumentCoordinate();
                    throw new ParseFailureException("Expected a StartOfInput token.", new DocumentRange(this.m_filePath, documentCoordinate, documentCoordinate1));
                }
            }
            documentRange = new DocumentRange();
            throw new ParseFailureException("No EndOfInput token found at the end of the input", documentRange);
        }