Пример #1
0
        /// <summary>
        /// Returns a list of paths with dates (part D ) removed
        /// </summary>
        /// <param name="dssFilename"></param>
        /// <returns></returns>
        public static string[] GetCatalog(string dssFilename)
        {
            string       dir      = Path.GetDirectoryName(dssFilename);
            string       fnScript = FileUtility.GetTempFileNameInDirectory(dir, ".txt");
            StreamWriter sw       = new StreamWriter(fnScript);


            if (Path.GetFileName(dssFilename).IndexOf(" ") >= 0)
            {
                System.Windows.Forms.MessageBox.Show("Warning: The dss filename has a space.  ");
            }

            sw.WriteLine(Path.GetFileName(dssFilename));

            sw.WriteLine("CA");// create (N)ew (C)ondenced catalog  (F)ull batch mode.
            sw.Close();

            string dssutl = HecDssSeries.GetPathToDssUtl();

            ProgramRunner pr = new ProgramRunner();

            pr.Run(dssutl, "input=" + Path.GetFileName(fnScript), dir);
            pr.WaitForExit();
            return(ParseRawCatalog(pr.Output));
        }
        public void TestExpectErrorBecauseOnlyOneFileParameter()
        {
            var programRunner = new ProgramRunner(new [] { "ResTest/NamespaceDeclarationInjectionTest/MainFile.js" });
            var result        = programRunner.Run();

            Assert.AreEqual(ProgramRunnerExit.Error, result);
        }
Пример #3
0
        /// <summary>
        /// Executes the specified SQL script file.
        /// </summary>
        /// <param name="scriptFileName">Name of the script file.</param>
        /// <param name="userName">Name of the database user.</param>
        /// <param name="password">The database user's password.</param>
        /// <param name="useDatabase">The database to run the script under. If <c>null</c>, the script will run under
        /// the default database.</param>
        /// <returns>The same instance of this <see cref="BuildRunner"/>.</returns>
        public TRunner ExecuteSqlScriptFile(
            string scriptFileName,
            string userName,
            string password,
            string useDatabase)
        {
            ProgramRunner
            .AddArgument("-U")
            .AddArgument(userName)
            .AddArgument("-P")
            .AddArgument(password)
            .AddArgument("-i")
            .AddArgument(scriptFileName)
            .AddArgument("-r1")
            .AddArgument("-m-1");

            if (useDatabase != null)
            {
                ProgramRunner
                .AddArgument("-d")
                .AddArgument(useDatabase);
            }

            ProgramRunner.Run(@"C:\Program Files\Microsoft SQL Server\90\Tools\Binn\osql.exe", false);

            return(ReturnThisTRunner());
        }
Пример #4
0
        static void Main(string[] args)
        {
            ConsoleWriter writer = null;

            try                                                   //BugFix #2b
            {
                HttpClient httpClient = new HttpClient();

                JokeRepository jokeRepository = new JokeRepository(httpClient);
                NameRepository nameRepository = new NameRepository(httpClient);

                writer = new ConsoleWriter();
                IReader reader = new ConsoleReader(writer);

                UserQuestions    userQuestions    = new UserQuestions(reader, writer);
                UserInteractions userInteractions = new UserInteractions(writer, userQuestions);

                JokeService jokeService = new JokeService();

                ProgramRunner programRunner = new ProgramRunner(userInteractions, jokeRepository, nameRepository, jokeService);

                programRunner.Run();
            }
            catch (Exception)
            {
                if (writer != null)
                {
                    writer.WriteLine("Something went terribly wrong.");
                    writer.WriteLine("Are you sure you're connected to the internet?");
                }
            }
        }
        // ReSharper disable once InconsistentNaming
        public void TestBasicHtmlVarWOVars()
        {
            var programRunner = new ProgramRunner(new [] { "ResTest/BasicHtmlVarWOVarsTest/MainFile.js", "ResTest/BasicHtmlVarWOVarsTest/MainFile.out.js" });
            var result        = programRunner.Run();

            // var output = programRunner.JsMrgOutput;

            Assert.AreEqual(ProgramRunnerExit.Done, result);
        }
Пример #6
0
        public double[] ComputeCoefficients(ForecastEquation eq, string pathToR)
        {
            var tbl = eq.ComputeHistoricalCoefficients(eq.StartYear, eq.EndYear);

            // perf.Report("done."); // 1.2 seconds with cache/  33 seconds without
            dataFile = FileUtility.GetTempFileName(".csv");
            CsvFile.WriteToCSV(tbl, dataFile, false);


            dataFile = dataFile.Replace("\\", "/");
            var rInput = new List <string>();

            rInput.Add("# Forecast " + eq.Name);
            rInput.Add("a <- read.csv(\"" + dataFile + "\")");
            rInput.Add("b <- subset(a, select=-Year)");
            rInput.Add("cor(b)");
            rInput.Add("summary(b)");

            string s = "fit <- lm(Y1 ~ ";

            for (int i = 1; i < tbl.Columns.Count - 1; i++)
            {
                s += " + X" + i;
            }
            s += ", data=a)";
            rInput.Add(s);
            rInput.Add("options(width=240)");
            rInput.Add("summary(fit)");
            rInput.Add("coefficients(fit)");

            string   rFile = FileUtility.GetTempFileName(".txt");
            TextFile rtf   = new TextFile(rInput.ToArray());

            rtf.SaveAs(rFile);
            rFile = rFile.Replace("\\", "/");

            var exe = Path.Combine(pathToR, "R\\bin\\R.exe");

            if (!File.Exists(exe))
            {
                throw new Exception("Could not find the R statistic program.  It should be in a sub directory R");
            }

            ProgramRunner pr = new ProgramRunner();

            pr.Run(exe, "--no-restore --no-save --quiet < \"" + rFile);
            pr.WaitForExit();

            Coefficients = GetCoefficients(pr.Output);


            Output = pr.Output;

            return(Coefficients);
        }
Пример #7
0
        public void TestBasicHtmlVar2()
        {
            var programRunner = new ProgramRunner(new [] { "ResTest/BasicHtmlVar2Test/MainFile2.js", "ResTest/BasicHtmlVar2Test/MainFile2.out.js" });
            var result        = programRunner.Run();
            var output        = programRunner.JsMrgOutput;

            Assert.AreEqual(ProgramRunnerExit.Done, result);
            Assert.True(output.Contains("<div class=\\\"someContainer\\\">"));
            Assert.True(output.Contains("<div class=\\\"\" + foo + \"\\\">\" + bar + \"</div>"));
            Assert.IsTrue(output.Contains("'<div class=\\'someContainer\\'><div class=\\'' + foo + '\\'>' + bar + '</div></div>';"));
        }
        public void TestNamespaceDeclarationInjection()
        {
            var programRunner = new ProgramRunner(new [] { "ResTest/NamespaceDeclarationInjectionTest/MainFile.js", "ResTest/NamespaceDeclarationInjectionTest/MainFile.out.js" });
            var result        = programRunner.Run();
            var output        = programRunner.JsMrgOutput;

            Assert.AreEqual(ProgramRunnerExit.Done, result);
            Assert.True(output.Contains("YTILS.create = { };"));
            Assert.True(output.Contains("YTILS.defaults = { };"));
            Assert.True(output.Contains("YTILS.dependency = { };"));
        }
Пример #9
0
        public override void RunJob(
            string projectRoot,
            ProjectConfig project,
            ProjectBuildTarget target,
            ProjectBuildJob job)
        {
            string old = Directory.GetCurrentDirectory();

            Directory.SetCurrentDirectory(projectRoot);
            ProgramRunner.Run(job.Arguments);
            Directory.SetCurrentDirectory(old);
        }
Пример #10
0
        public TRunner Gendarme(params string[] projectNames)
        {
            string reportDir      = EnsureBuildLogsTestDirectoryExists();
            string reportFileName = string.Format(
                CultureInfo.InvariantCulture,
                "{0}.GendarmeReport.xml",
                ProductId);
            string gendarmeXmlReportFile = Path.Combine(reportDir, reportFileName);

            ProgramRunner
            .AddArgument("--html")
            .AddArgument("{0}.GendarmeReport.html", ProductId)
            .AddArgument("--xml")
            .AddArgument(gendarmeXmlReportFile)
            .AddArgument("--severity")
            .AddArgument("all");

            new List <string>(projectNames).ForEach(
                projectName =>
            {
                string outputPath = GetProjectOutputPath(projectName);
                if (outputPath == null)
                {
                    return;
                }

                VSProjectWithFileInfo projectInfo = (VSProjectWithFileInfo)Solution.FindProjectByName(projectName);

                string projectOutputType       = projectInfo.Project.Properties["OutputType"];
                string projectAssemblyName     = projectInfo.Project.Properties["AssemblyName"];
                string projectAssemblyFileName = string.Format(
                    CultureInfo.InvariantCulture,
                    "{0}.{1}",
                    projectAssemblyName,
                    projectOutputType == "Library" ? "dll" : "exe");

                string projectAssemblyFullPath = Path.Combine(
                    Path.Combine(
                        projectInfo.ProjectDirectoryPath,
                        outputPath),
                    projectAssemblyFileName);

                ProgramRunner.AddArgument(projectAssemblyFullPath);
            });

            string gendarmePath = MakePathFromRootDir(LibDir + @"\Gendarme\gendarme.exe");

            AssertFileExists("Gendarme.exe", gendarmePath);
            ProgramRunner.Run(gendarmePath, true);

            return(ReturnThisTRunner());
        }
Пример #11
0
        private static bool RunPscp(string passwd, string args)
        {
            string dir = Path.GetDirectoryName(Application.ExecutablePath);
            var    exe = Path.Combine(dir, "pscp.exe");

            if (!File.Exists(exe))
            {
                exe = "pscp.exe";
            }

            if (!File.Exists(exe))
            {
                throw new FileNotFoundException(exe);
            }

            pr = new ProgramRunner();
            pr.Run(exe, args);
            pr.SendCommand("y");

            int exitCode = pr.WaitForExit();


            var output = pr.Output;

            foreach (var item in pr.Output)
            {
                Logger.WriteLine(item);
            }

            if (exitCode != 0)
            {
                throw new IOException("Error copying with PSCP " + args.Replace(passwd, "xxxxx"));
            }

            return(exitCode == 0);
            // var output = ProgramRunner.RunExecutable(exe, args);
            //TextFile tf = new TextFile(output);

            //if (tf.IndexOf("The server's host key is not cached in the registry.") >= 0)
            //{
            //    // try again.
            //     pr = new ProgramRunner();
            //   // pr.WriteLine += new ProgramRunner.InfoEventHandler(pr_WriteLine);
            //    pr.Run("pscp", args.Replace("-batch",""));
            //    pr.SendCommand("y");
            //    exitCode =  pr.WaitForExit();

            //  //  tf = new TextFile(pr.Output);

            //}
        }
Пример #12
0
        public DetergentBuildRunner RunTests2(string projectName, bool collectCoverageData)
        {
            Log("Runs tests on '{0}' assembly ({1})", new object[] { projectName, collectCoverageData ? "with coverage" : "without coverage" });
            string buildLogsDir = EnsureBuildLogsTestDirectoryExists();
            VSProjectWithFileInfo testProjectWithFileInfo = (VSProjectWithFileInfo)Solution.FindProjectByName(projectName);
            string projectTargetPath = GetProjectOutputPath(testProjectWithFileInfo.ProjectName);

            projectTargetPath = Path.Combine(testProjectWithFileInfo.ProjectDirectoryPath, projectTargetPath) + testProjectWithFileInfo.ProjectName + ".dll";
            projectTargetPath = Path.GetFullPath(MakePathFromRootDir(projectTargetPath));
            string gallioEchoExePath = MakePathFromRootDir(Path.Combine(LibDir, @"Gallio\bin\Gallio.Echo.exe"));

            try
            {
                //if (collectCoverageData)
                //{
                //    ProgramRunner.AddArgument(Path.Combine(LibDir, @"NCover v1.5.8\CoverLib.dll")).AddArgument("/s").Run("regsvr32");
                //    ProgramRunner.AddArgument(gallioEchoExePath);
                //}
                ProgramRunner
                .AddArgument(projectTargetPath)
                .AddArgument("/runner:NCover")
                .AddArgument("/report-directory:{0}", new object[] { buildLogsDir })
                .AddArgument("/report-name-format:TestResults-{0}", new object[] { TestRuns })
                .AddArgument("/report-type:xml")
                .AddArgument("/verbosity:verbose");
                //if (collectCoverageData)
                //{
                //    ProgramRunner.AddArgument("//x").AddArgument(@"{0}\Coverage-{1}.xml", new object[] { buildLogsDir, TestRuns }).AddArgument("//ea").AddArgument("MbUnit.Framework.TestFixtureAttribute").AddArgument("//w").AddArgument(Path.GetDirectoryName(projectTargetPath)).AddArgument("//v").Run(MakePathFromRootDir(Path.Combine(libDir, @"NCover v1.5.8\NCover.Console.exe")));
                //    CoverageResultsExist = true;
                //}
                //else
                //{
                ProgramRunner.Run(gallioEchoExePath);
                //}
                IncrementTestRunsCounter();
            }
            finally
            {
                //if (collectCoverageData)
                //{
                //    ProgramRunner.AddArgument(Path.Combine(LibDir, @"NCover v1.5.8\CoverLib.dll")).AddArgument("/s").AddArgument("/u").Run("regsvr32");
                //}
            }

            return(this);
        }
Пример #13
0
        private static void Main(string[] args)
        {
            var testsConfig = new AltruismTestsConfig();

            var programRunner = new ProgramRunner(testsConfig,
                                                  new FormsSingleTestRunner(testsConfig), new OptimizationScheme(new ListFitnessTest(null),
                                                                                                                 new List <TopTestScheme>
            {
                new TopTestScheme(208, 8),
                new TopTestScheme(48, 48),
                new TopTestScheme(10, 104),
                new TopTestScheme(5, 208),
                new TopTestScheme(1, 208)
            }));

            programRunner.Run(args);
        }
Пример #14
0
        public void TestBasicHtmlVar()
        {
            var programRunner = new ProgramRunner(new[]
                                                  { "ResTest/BasicHtmlVarTest/MainFile.js", "ResTest/BasicHtmlVarTest/MainFile.out.js" });
            var result = programRunner.Run();
            var output = programRunner.JsMrgOutput;

            Assert.AreEqual(ProgramRunnerExit.Done, result);

            var containsSomeContainer = output.Contains("<div class=\\\"someContainer\\\">");

            Assert.True(containsSomeContainer);

            var expectedFooBarString = "<div class=\\\"\" + foo + \"\\\">\" + bar + \"</div>";
            var containsFooBar       = output.Contains(expectedFooBarString);

            Assert.True(containsFooBar);
        }
Пример #15
0
        private static void Main(string[] args)
        {
            var testsConfig = new EmotionalTestsConfig();

            testsConfig.SetDefaultConstants();
            testsConfig.Init();

            var programRunner = new ProgramRunner(testsConfig,
                                                  new EmotionalSingleTestRunner(testsConfig), new OptimizationScheme(new ListFitnessTest(null),
                                                                                                                     new List <TopTestScheme>
            {
                new TopTestScheme(208, 8),
                new TopTestScheme(48, 48),
                new TopTestScheme(10, 104),
                new TopTestScheme(5, 208),
                new TopTestScheme(1, 208)
            }));

            programRunner.Run(args);
        }
Пример #16
0
        private static void Main(string[] args)
        {
            var testsConfig    = new SocialGPTestsConfig();
            var simplifierTest = new GPSimplifierFitnessTest(null);

            var programRunner = new ProgramRunner(
                testsConfig, new FormsSingleTestRunner(testsConfig),
                new GPOptimizationScheme(new ListFitnessTest(null), 208,
                                         new List <TopTestScheme>
            {
                new TopTestScheme(208, 8),
                new TopTestScheme(104, 16),
                new TopTestScheme(48, 48),
                new TopTestScheme(10, 104),
                new TopTestScheme(5, 208),
                new TopTestScheme(1, 208)
            }, simplifierTest));

            programRunner.Run(args);
        }
Пример #17
0
        private void DumpPathToTempFile(string fnOut)
        {
            string fnScript = FileUtility.GetTempFileNameInDirectory(PathToFile, ".txt");

            StreamWriter sw = new StreamWriter(fnScript);

            sw.WriteLine(Path.GetFileName(m_filename));
            sw.WriteLine("CA.NCF");// create (N)ew (C)ondenced catalog  (F)ull batch mode.
            sw.WriteLine("fo f12.3");
            sw.WriteLine("wr.t to=" + Path.GetFileName(fnOut) + " "
                         + " A=" + path.A
                         + " B=" + path.B
                         + " C=" + path.C
                         // +" d="+path.D skip part d (dates...) we want all dates..
                         + " E=" + path.E
                         + " F=" + path.F);


            if (!path.IsValid)
            {
                MessageBox.Show("Warning: Path'" + path.CondensedName + "' contains invalid characters");
            }


            sw.Close();

            string dssutl = GetPathToDssUtl();

            ProgramRunner pr = new ProgramRunner();

            pr.Run(dssutl, "input=" + Path.GetFileName(fnScript), PathToFile);
            pr.WaitForExit();
            string[] stdout = pr.Output;
            //string[] stdout = HecDssProgramRunner.Run(dssutl, "input=" + fnScript, PathToFile);

            Console.WriteLine("---ReadTimeSeries() ");
            Console.WriteLine(String.Join("\n", stdout));

            File.Delete(fnScript);
        }
Пример #18
0
        static void Main(string[] args)
        {
            ProgramRunner runner = new ProgramRunner();

            runner.Run <Day6>();
        }
Пример #19
0
        public TRunner FxCop()
        {
            ScriptExecutionEnvironment.LogTaskStarted("Running FxCop analysis");

            string fxProjectPath = MakePathFromRootDir(productId) + ".FxCop";

            AssertFileExists("FxCop project file", fxProjectPath);

            string fxReportPath = EnsureBuildLogsTestDirectoryExists();

            fxReportPath = Path.Combine(fxReportPath, productId);
            fxReportPath = String.Format(
                CultureInfo.InvariantCulture,
                "{0}.FxCopReport.xml",
                fxReportPath);

            ProgramRunner
            .AddArgument(@"/project:{0}", fxProjectPath)
            .AddArgument(@"/out:{0}", fxReportPath)
            .AddArgument(@"/dictionary:CustomDictionary.xml")
            .AddArgument(@"/ignoregeneratedcode");

            string fxCopCmdPath = MakePathFromRootDir(
                Path.Combine(libDir, @"Microsoft FxCop 1.36\FxCopCmd.exe"));

            AssertFileExists("FxCopCmd.exe", fxCopCmdPath);
            ProgramRunner.Run(fxCopCmdPath, true);

            // check if the report file was generated
            bool isReportFileGenerated = File.Exists(fxReportPath);

            // FxCop returns different exit codes for different things
            // see http://msdn.microsoft.com/en-us/library/bb164705(VS.80).aspx for the list of exit codes
            // exit code 4 means "Project load error" but it occurs when the old FxCop violations exist
            // which are then removed from the code
            if ((ProgramRunner.LastExitCode != 0 && ProgramRunner.LastExitCode != 4) || isReportFileGenerated)
            {
                if (IsRunningUnderCruiseControl)
                {
                    if (File.Exists(fxReportPath))
                    {
                        string fxcopReportFileName = Path.GetFileName(fxReportPath);
                        try
                        {
                            CopyFile(fxReportPath, Path.Combine(ccnetDir, fxcopReportFileName), true);
                        }
                        catch (IOException)
                        {
                            Log(
                                "Warning: could not copy FxCop report file '{0}' to the CC.NET dir",
                                fxReportPath);
                        }
                    }
                }
                else if (IsRunningUnderHudson)
                {
                }
                else
                {
                    // run FxCop GUI
                    ProgramRunner
                    .AddArgument(fxProjectPath)
                    .Run(MakePathFromRootDir(Path.Combine(libDir, @"Microsoft FxCop 1.36\FxCop.exe")));
                }

                Fail("FxCop found violations in the code.");
            }

            ScriptExecutionEnvironment.LogTaskFinished();
            return(ReturnThisTRunner());
        }
        private ProgramRunnerExit RunProgramForHelp(string[] args)
        {
            var programRunner = new ProgramRunner(args);

            return(programRunner.Run());
        }
Пример #21
0
 private static void Main()
 {
     ProgramRunner.Run();
 }
Пример #22
0
        static void Main(string[] args)
        {
            var programRunner = new ProgramRunner(args);

            programRunner.Run();
        }
Пример #23
0
        private static void Main()
        {
            var runner = new ProgramRunner();

            runner.Run <Day2>();
        }