예제 #1
0
        static void RunTest(Test test)
        {
            string wd = Environment.CurrentDirectory;

            const string prefix   = "__pfx_nunit";
            const string name_cs  = prefix + ".cs";
            const string name_exe = prefix + ".exe";
            const string name_swf = prefix + ".swf";

            string mainFile = Path.Combine(wd, name_cs);

            File.WriteAllText(mainFile, test.MainCode);

            var compilerOptions = new CompilerOptions
            {
                Target   = CompilerTarget.ConsoleApp,
                Output   = name_exe,
                NoLogo   = true,
                NoConfig = true,
                NoStdlib = true
            };

            GlobalSettings.AddCommonReferences(compilerOptions);
            compilerOptions.AddRef(_asmpath);
            compilerOptions.Input.Add(name_cs);

            string cout = CompilerConsole.Run(compilerOptions);

            if (CompilerConsole.HasErrors(cout))
            {
                Console.WriteLine(cout);
                Environment.Exit(-1);
            }

            string path_exe = Path.Combine(wd, name_exe);
            string path_swf = Path.Combine(wd, name_swf);

            var asm = LoadAssembly(path_exe);

            MakeSwf(asm, path_swf);
            RunPlayer(test, path_swf);
            Report.AddTest(test);
        }
예제 #2
0
        private static void SetCompilerOptions(TestCase tc, CompilerLanguage lang, CompilerOptions options)
        {
            options.Language = lang;
            options.Debug    = tc.Debug;
            options.Optimize = tc.Optimize;
            options.Unsafe   = tc.Unsafe;
            options.Output   = tc.ExePath;
            options.Target   = CompilerTarget.ConsoleApp;
            options.NoLogo   = true;
            options.Checked  = false;

            options.Define("TARGET_JVM");             //to remove unsafe
            options.Define("NET_2_0");
            options.Defines.AddRange(tc.Defines);

            if (tc.VM == VM.CLR)
            {
                options.Define("MSCLR");
            }
            else if (tc.VM == VM.AVM)
            {
                options.Define("AVM");
            }

            //common refs
            if (tc.VM == VM.AVM)
            {
                GlobalSettings.AddCommonReferences(options);

                options.AddRef(Path.Combine(GlobalSettings.LibsDirectory, "flash.v10.2.dll"));

                options.NoConfig = true;
                options.NoStdlib = true;

                if (lang == CompilerLanguage.VB)
                {
                    //options.NoVBRuntime = true;
                    options.VBRuntime = GlobalSettings.Libs.VBRuntime;
                    //options.CompactFramework = true;
                    options.SDKPath = GlobalSettings.Dirs.Libs;
                    options.NoWarn  = true;
                }
            }
            else
            {
                options.AddRef("System.Core.dll");
            }

            if (tc.IsNUnit)
            {
                if (tc.VM == VM.CLR)
                {
                    string nunit = QA.GetNUnitFrameworkPath(GlobalOptions.UseCommonDirectory ? "" : tc.Root);
                    options.AddRef(nunit);
                }
                else
                {
                    options.AddRef(GlobalSettings.GetLibPath(QA.NUnitFrameworkDll));
                }
                options.AddRef(tc.GetNUnitTestsPath(tc.Root));
            }

            options.Input.AddRange(tc.SourceFiles.Names);
        }