public void Test_Setup()
        {
            _script = Script.MakeBasic("exe", "c++");

            _expects = new Project();
            _expects.Package.Add(1);

            _parser = new GnuParser();
        }
        public void Test_Setup()
        {
            _script = Script.MakeBasic("exe", "c++");

            _expects = new Project();
            _expects.Package.Add(1);
            _expects.Package[0].Config.Add(2);

            _parser = new Vs2003Parser();
        }
        public void Test_Setup()
        {
            _script = Script.MakeBasic("exe", "c#");

            _expects = new Project();
            _expects.Package.Add(2);
            _expects.Package[0].Config.Add(2);
            _expects.Package[1].Config.Add(2);

            _parser = new MonoDevParser();
        }
        public void Test_Setup()
        {
            _script = Script.MakeBasic("dll", "c++");
            _script.Append("project.bindir = 'bin'");
            _script.Append("project.libdir = 'lib'");

            _expects = new Project();
            _expects.Package.Add(1);
            _expects.Package[0].Config.Add(2);

            _parser = new Vs6Parser();
        }
        public static void Run(Script script, Parser parser, Project expected, string[] options)
        {
            /* Remember where Premake is located */
            string executable = Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar + "premake";

            /* Create a temporary directory for this run */
            string temp = Path.GetTempPath() + Guid.NewGuid().ToString() + Path.DirectorySeparatorChar;
            Directory.CreateDirectory(temp);
            Directory.SetCurrentDirectory(temp);

            /* Create any required files */
            foreach (string filename in _files)
            {
                string dirname = Path.GetDirectoryName(filename);
                if (dirname != String.Empty && !Directory.Exists(dirname))
                    Directory.CreateDirectory(dirname);
                File.Create(filename).Close();
            }

            try
            {
                /* Write out the script */
                script.WriteFile("premake.lua");

                /* Run premake */
                string args = (options != null) ? String.Join(" ", options) : String.Empty;

                Process process = new Process();
                process.StartInfo.FileName = executable;
                process.StartInfo.Arguments = args + " --target " + parser.TargetName;
                process.StartInfo.CreateNoWindow = true;
                process.StartInfo.WorkingDirectory = Directory.GetCurrentDirectory();
                process.StartInfo.RedirectStandardOutput = true;
                process.StartInfo.RedirectStandardError = true;
                process.StartInfo.UseShellExecute = false;
                process.Start();
                process.WaitForExit();
                Errors = process.StandardError.ReadToEnd();
                Output = process.StandardOutput.ReadToEnd();
                if (process.ExitCode != 0)
                {
                    string message = (Errors != String.Empty) ? Errors : Output;
                    throw new InvalidOperationException("Premake aborted with code " + process.ExitCode + ": \n" + message);
                }

                /* Start building the results right here */
                Project actual = new Project();

                /* Locate the name of the just-written project file */
                MatchCollection matches = Regex.Matches(script.ToString(), "project.name = '(.+)'");
                actual.Name = matches[0].Groups[1].ToString();

                matches = Regex.Matches(script.ToString(), "project.path = '(.+)'");
                actual.Path = (matches.Count > 0) ? matches[0].Groups[1].ToString() : "";

                /* Parse the results */
                parser.Parse(actual, Path.Combine(actual.Path, actual.Name));

                /* SHARPDEV_DEPENDENCY_BUG: Dependencies have disappeared! */
            #if SHARPDEV_DEPENDENCY_BUG
                foreach (Package p in actual.Package)
                {
                    Console.WriteLine(p.Name + ":");
                    foreach (Configuration config in p.Config)
                    {
                        Console.WriteLine("  " + config.Name + ": " + config.Dependencies.Length);
                    }
                }
            #endif
                expected.CompareTo(actual);
            }
            finally
            {
                Directory.SetCurrentDirectory(Path.GetDirectoryName(executable));
                Directory.Delete(temp, true);
                _files.Clear();
                _scripts.Clear();
            }
        }