Esempio n. 1
0
        string Compile(ScriptPath spath, bool tapwasupdated)
        {
            string path = spath.Path;

            if (!File.Exists(path))
            {
                throw new FileNotFoundException("source file not found", path);
            }
            string outpath = TapFromSource(spath);
            string pdbpath = PdbFromTap(outpath);

            string[] sa = GetSubjectAssemblies(); // this includes tap.exe copied with CopyMe
            TAPApp.VLog(3, "subject assemblies:" + string.Join(",", sa.ToArray()));
            if (!tapwasupdated && !TAPApp.IsOutdated(outpath, path) && !TAPApp.IsOutdated(pdbpath, path) &&
                !IsOutdated(outpath, sa))
            {
                TAPApp.VLog(2, outpath + " is up to date");
                return(outpath);
            }
            TAPApp.VLog(3, "building {0}", outpath);
            using (CodeDomProvider prov = new CSharpCodeProvider(new Dictionary <string, string> {
                { "CompilerVersion", "v3.5" }
            })) {                                       // maybe make configurable in a <system.codedom><compilers>...
                var cp = new CompilerParameters();
                cp.GenerateExecutable      = true;
                cp.IncludeDebugInformation = true;
                cp.OutputAssembly          = outpath;
                //cp.CompilerOptions+=String.Concat("/d:DEBUG /lib:\"",GetMyImagePath(),"\"");
#if __MonoCS__
                cp.CompilerOptions += "/d:DEBUG /nowarn:169";
#else
                cp.CompilerOptions += string.Concat("/d:DEBUG /pdb:", pdbpath);
#endif
                cp.ReferencedAssemblies.Add("System.dll");
                cp.ReferencedAssemblies.Add("System.Core.dll");

                cp.ReferencedAssemblies.AddRange(sa);
                cp.ReferencedAssemblies.AddRange(TAPApp.Refs.ToArray());
                CompilerResults cr     = prov.CompileAssemblyFromFile(cp, new [] { path });
                bool            errors = cr.Errors.Count > 0;
                if (errors)
                {
                    TAPApp.ELog("Errors building");
                }
                if (errors || TAPApp.Verbose > 1)
                {
                    foreach (string i in cr.Output)
                    {
                        TAPApp.Log(i);
                    }
                }
                if (!errors)
                {
                    return(cr.PathToAssembly);
                }
                return(null);
            }
        }
Esempio n. 2
0
 public override void OutputReceived(string s, bool force)
 {
     if (s != null)
     {
         TAPApp.DLog(4, "received {0}.", s);
         if (force || TAPApp.Verbose > 0)
         {
             TAPApp.Log(s);
         }
     }
 }
Esempio n. 3
0
 public void ParseLine(string line)
 {
     if (Counters.FirstLine)
     {
         Counters.FirstLine = false;
         string[] p = Match(PlanRE, line);
         if (p != null)
         {
             Plan(int.Parse(p[0]));
             return;
         }
     }
     string[] m = Match(ResultRE, line);
     if (m != null)
     {
         bool ok   = m[0] == "ok";
         bool todo = m[3] == "TODO";
         if (todo)
         {
             ++Counters.NTodo;
         }
         if (ok)
         {
             ++Counters.NOk;
             if (todo)
             {
                 ++Counters.NTodoSucc;
             }
         }
         else
         {
             if (todo)
             {
                 ++Counters.NOk;
             }
             else
             {
                 ++Counters.NNotOk;
             }
         }
         int expectedidx = Counters.NOk + Counters.NNotOk;
         int idx         = int.Parse(m[1]);
         if (idx != expectedidx)
         {
             TAPApp.Log("# tapparser: unexpected index number {0}; expected {1}.", idx, expectedidx);
         }
         if (m[3] == "SKIP")
         {
             ++Counters.NSkipped;
         }
     }
 }
Esempio n. 4
0
            public int Show()
            {
                int    all     = NOk + NNotOk;
                int    exit    = 1;
                string scripts = NScripts == 1?"script":"scripts";

                if (!FirstLine && !Mismatch && NNotOk == 0 && NRunFailed == 0)
                {
                    TAPApp.Log("# all OK. ({0} {1})", NOk, TestTests(NOk));
                    if (NTodoSucc != 0)
                    {
                        TAPApp.Log("#   {0} todo {1} succeeded unexpectedly.", NTodoSucc, TestTests(NTodoSucc));
                    }
                    exit = 0;
                }
                else
                {
                    string pfix = "FAILED.";
                    if (FirstLine)
                    {
                        TAPApp.Log("# {0} No output.", pfix);
                    }
                    if (NRunFailed != 0)
                    {
                        int nrunok = NScripts - NRunFailed;
                        TAPApp.Log("# {0} {1}/{2} {3} run ({4:D0}%)", pfix, nrunok, NScripts, scripts, (int)(((double)nrunok / NScripts) * 100));
                        pfix = "  ";
                    }
                    if (NNotOk != 0)
                    {
                        TAPApp.Log("# {0} {1}/{2} {3} passed ({4:D0}%)", pfix, NOk, all, TestTests(NOk), (int)(((double)NOk / all) * 100));
                        pfix = "  ";
                    }
                    if (Mismatch)
                    {
                        TAPApp.Log("# {0} Number of planned tests did not match number of tests.", pfix);
                        pfix = "  ";
                        TAPApp.Log("# {0} planned: {1} run: {2}", pfix, NPlanned, all);
                    }
                }
                TAPApp.Log("# Wall clock time: {0}", End - Start);
                return(exit);
            }
Esempio n. 5
0
 static public void ShowTotals(List <string> paths)
 {
     if (Total.NScripts == 0)
     {
         string instr = "";
         if (paths.Count != 0)
         {
             instr = string.Join(", ", paths.ToArray());
         }
         TAPApp.Log("not ok 1 - No matching test scripts. Paths: {0}.", instr);
         Exit = 1;
     }
     else if (Total.NScripts > 1)
     {
         TAPApp.Log("# result after {0} scripts:", Total.NScripts);
         UpdateExit(Total.Show());
         TAPApp.DLog(2, "exit is {0}", Exit);
     }
 }