Esempio n. 1
0
        protected string RunBuildTest(Zone zone, AutoEvaluation job, out bool suc)
        {
            int retval = -1;
            ExternalToolFactory extfact = ExternalToolFactory.GetInstance();

            IExternalTool exttool = extfact.CreateExternalTool(job.RunTool);

            exttool.Arguments = job.RunToolArgs;

            DateTime begin = DateTime.Now;

            try {
                retval = exttool.Execute(zone.LocalPath, job.TimeLimit * 1000);
            } catch (ToolExecutionException er) {
                suc = false;
                m_logger.Log("Error: " + er.Message, TestLogger.LogType.ERROR);
                return(FormErrorXml(AutoResult.CRITICALLYFLAWED, er.Message, job.Points));
            } catch (Exception) {
                suc = false;
                string ermsg = "Unexpected tool execution error. Contact administrator";
                m_logger.Log("Error: " + ermsg, TestLogger.LogType.ERROR);
                return(FormErrorXml(AutoResult.CRITICALLYFLAWED, ermsg, job.Points));
            }

            DateTime end = DateTime.Now;

            int time = Convert.ToInt32(end.Subtract(begin).TotalSeconds);

            suc = (retval == 0);
            return(FormBuildXml(suc, time,
                                String.Format("{0}\n\n{1}", exttool.Output, exttool.ErrorOutput),
                                job.Points));
        }
Esempio n. 2
0
        protected string RunTest(Zone zone, AutoEvaluation job)
        {
            ExternalToolFactory extfact = ExternalToolFactory.GetInstance();

            //Get interface to external running tool
            IExternalTool exttool = extfact.CreateExternalTool(job.RunTool);

            exttool.Arguments = job.RunToolArgs;

            //Execute the test with the tool
            try {
                if (exttool.Execute(zone.LocalPath, job.TimeLimit * 1000) != 0)
                {
                    return(FormErrorXml(AutoResult.CRITICALLYFLAWED,
                                        exttool.ErrorOutput, job.Points));
                }
                else
                {
                    return(ValidateResult(exttool.Output));
                }
            } catch (ToolExecutionException er) {
                m_logger.Log("Error: " + er.Message, TestLogger.LogType.ERROR);
                return(FormErrorXml(AutoResult.CRITICALLYFLAWED, er.Message, job.Points));
            } catch (ResultFormatException er) {
                m_logger.Log("Error: " + er.Message, TestLogger.LogType.ERROR);
                return(FormErrorXml(AutoResult.CRITICALLYFLAWED, er.Message, job.Points));
            } catch (Exception) {
                string ermsg = "Unexpected tool execution error. Contact administrator";
                m_logger.Log("Error: " + ermsg, TestLogger.LogType.ERROR);
                return(FormErrorXml(AutoResult.CRITICALLYFLAWED, ermsg, job.Points));
            }
        }
Esempio n. 3
0
        public string Discover(AutoEvaluation eval, out double points, out int time, out int count)
        {
            //Get Perl
            IExternalTool perl = ExternalToolFactory.GetInstance().CreateExternalTool("Perl",
                                                                                      "5.0", ExternalToolFactory.VersionCompare.ATLEAST);

            if (perl == null)
            {
                throw new JUnitToolException(
                          "Unable to find Perl v5.0 or later. Please check the installation or contact the administrator");
            }

            //Get all files on the disk
            string tpath = ExportToTemp(eval);

            //Run disco program
            perl.Arguments = "jdisco.pl i";
            perl.Execute(tpath);
            Directory.Delete(tpath, true);

            //Validate XML
            string    xmltests = perl.Output;
            XmlWizard xmlwiz   = new XmlWizard();

            if (!xmlwiz.ValidateXml(xmltests, Path.Combine(Globals.WWWDirectory, "Xml/testsuite.xsd")))
            {
                throw new JUnitToolException("Invalid JUnit Test Suite. Check to make sure the test suite conforms to FrontDesk standards");
            }

            //Write XML
            FileSystem fs      = new FileSystem(Globals.CurrentIdentity);
            CFile      zone    = fs.GetFile(eval.ZoneID);
            string     tspath  = Path.Combine(zone.FullPath, "__testsuite.xml");
            CFile      xmldesc = fs.GetFile(tspath);

            if (xmldesc == null)
            {
                xmldesc = fs.CreateFile(tspath, false, null);
            }
            xmldesc.Data = xmltests.ToCharArray();
            fs.Edit(xmldesc);
            fs.Save(xmldesc);

            //Copy disco program over
            CFile.FileList dfiles = new CFile.FileList();
            dfiles.Add(fs.GetFile(@"c:\system\junit\jdisco.pl"));
            dfiles.Add(fs.GetFile(@"c:\system\junit\JUnitDiscover.class"));
            dfiles.Add(fs.GetFile(@"c:\system\junit\JUnitDiscover$ClassFileFilter.class"));
            fs.CopyFiles(zone, dfiles, true);

            //Get suite metadata
            GetSuiteInfo(xmltests, out points, out time, out count);

            //Punt all previous results
            RemoveResults(eval);

            return(xmltests);
        }