Esempio n. 1
0
        public static string Run(string input, Options options, out int exitCode)
        {
            var exepath = GetPath();

            if (string.IsNullOrEmpty(exepath) || !File.Exists(exepath))
            {
                exitCode = -1;
                return(String.Format("Error: File {0} does not exist", exepath));
            }

            if (options == null)
            {
                options = new Options();
            }

            var args = new StringBuilder();

            args.Append(options);
            if (args.Length > 0)
            {
                args.Append(" ");
            }
            args.Append(input);

            return(CommandPromt.Run(exepath, args.ToString(), out exitCode));
        }
Esempio n. 2
0
        public static string Run(Options options, out int exitCode, params string[] inputs)
        {
            string path = GetPath();

            if (!File.Exists(path))
            {
                exitCode = -1;
                return(String.Format("Error: File {0} does not exist", path));
            }

            if (options == null)
            {
                options = new Options();
            }

            var args = new StringBuilder();

            args.Append(options.ToString());
            int n = inputs.Length;

            for (int i = 0; i < n; ++i)
            {
                if (i > 0)
                {
                    args.Append(" ");
                }
                args.Append(inputs[i]);
            }

            return(CommandPromt.Run(path, args.ToString(), out exitCode));
        }
Esempio n. 3
0
        public static string Run(PfxCompilerOptions options, bool redirect)
        {
            string cmd  = Path.Combine(GetPath(), "pfc.exe");
            string args = options.ToString();
            int    exitCode;

            return(CommandPromt.Run(cmd, args, out exitCode, false, redirect));
        }
Esempio n. 4
0
        public static void Render(string dotFile, string pngPath)
        {
            int exitCode;

            if (string.IsNullOrEmpty(pngPath))
            {
                pngPath = Path.ChangeExtension(dotFile, ".png");
            }
            string args = string.Format("-Tpng {0} -o {1}", dotFile, pngPath);
            string cmd  = GetPath();

            CommandPromt.Run(cmd, args, out exitCode);
        }
Esempio n. 5
0
        public static string Run(string path, out int exitCode)
        {
            string tool = GetToolPath();

            if (!File.Exists(tool))
            {
                exitCode = -1;
                return(string.Format("Error: flashell.exe tool does not exist."));
            }

            string args = "";

            args += path;

            return(CommandPromt.Run(tool, args, out exitCode));
        }
Esempio n. 6
0
        public static bool Run(TestCase tc)
        {
            string ilasmPath = Path.Combine(FrameworkInfo.Root_2_0, "ilasm.exe");

            string args = "/nologo /exe ";

            if (tc.Debug)
            {
                args += "/debug ";
            }
            if (tc.Optimize)
            {
                args += "/optimize ";
            }
            args += "/output:" + tc.ExePath;

            foreach (var f in tc.SourceFiles)
            {
                args += " ";
                args += f.Name;
            }

            using (tc.Root.ChangeCurrentDirectory())
            {
                try
                {
                    int    exitCode;
                    string cout = CommandPromt.Run(ilasmPath, args, out exitCode);
                    if (exitCode != 0)
                    {
                        tc.Error = "Unable to assembly (ilasm.exe failed).";
                        return(false);
                    }
                    //TODO: check ilasm output
                }
                catch (Exception exc)
                {
                    tc.Error = String.Format("Unable to assembly test case {0}. Exception:{1}\n", tc.Name, exc);
                    return(false);
                }
            }
            return(true);
        }
Esempio n. 7
0
        public static string Run(Options options, params string[] inputs)
        {
            string path = GetPath();

            if (!File.Exists(path))
            {
                return(string.Format("Unable to find asc.jar"));
            }

            if (options == null)
            {
                options = new Options(); //use default options
            }
            var args = new StringBuilder();

            args.AppendFormat("-jar {0} ", path);
            args.Append(options.ToString());
            for (int i = 0; i < inputs.Length; ++i)
            {
                if (i > 0)
                {
                    args.Append(' ');
                }
                //args.Append("-in ");
                args.Append(inputs[i]);
            }

            int    exitCode;
            string cout = CommandPromt.Run("java", args.ToString(), out exitCode);

            if (exitCode != 0)
            {
                return(string.Format("Unable to compile ABC file.\n{0}", cout));
            }
            return(null);
        }
Esempio n. 8
0
        private static void Execute(TestCase test, TestDriverSettings settings)
        {
            if (test.IsBenchmark)
            {
                if (settings.IsSWF)
                {
                    var results = FlashPlayer.Run(test.OutputPath);
                    test.Output2 = results.Output;
                    return;
                }

                throw new NotImplementedException();
            }

            int exitCode1 = 0;

            if (!test.HasOutput)
            {
                test.VM      = VM.CLR;
                test.Output1 = CommandPromt.Run(test.ExePath, "", out exitCode1);
            }
            else
            {
                test.Output1 = test.Output;
            }

            int exitCode2;

            if (settings.IsClrEmulation)
            {
                try
                {
                    var console = new StringWriter();
                    var vm      = new VirtualMachine(console);
                    exitCode2    = vm.Run(test.ExePath, "", new string[0]);
                    test.Output2 = console.ToString();
                }
                catch (Exception e)
                {
                    exitCode2    = 0;
                    test.Output2 = e.ToString();
                }
            }
            else if (settings.IsJavaScript)
            {
                try
                {
                    test.Output2 = JsRunner.Run(test.OutputPath, null, out exitCode2);
                }
                catch (Exception e)
                {
                    exitCode2    = 0;
                    test.Output2 = e.ToString();
                }
            }
            else if (settings.IsABC)
            {
                var avmOpts = new AvmShell.Options();
                test.Output2 = AvmShell.Run(avmOpts, out exitCode2, test.OutputPath);
            }
            else if (settings.IsSWF)
            {
                //tc.Output2 = FlashShell.Run(outpath, out exitCode2);
                FlashPlayer.Path = @"c:\pfx\tools\fp10.exe";
                var results = FlashPlayer.Run(test.OutputPath);
                exitCode2    = results.ExitCode;
                test.Output2 = results.Output;
            }
            else
            {
                throw new NotImplementedException();
            }

            CreateDebugHooks(test, settings, test.OutputPath);

            if (test.CheckExitCode)
            {
                if (exitCode2 != 0)
                {
                    test.Error = string.Format("{0} returned non zero exit code {1}.",
                                               test.OutputPath, exitCode2);
                    return;
                }
                if (exitCode1 != 0)
                {
                    test.Error = string.Format("{0} returned non zero exit code {1}.",
                                               test.ExePath, exitCode1);
                    return;
                }
            }

            if (test.CompareOutputs)
            {
                test.Error = CompareTools.CompareLines(test.Output1, test.Output2, true);
            }
        }