Exemplo n.º 1
0
 public void FixtureSetUp () {
     EvaluatorPool = new EvaluatorPool(
         UseDebugJSShell 
             ? ComparisonTest.DebugJSShellPath 
             : ComparisonTest.JSShellPath, 
         JSShellOptions,
         (e) =>
             e.WriteInput(ComparisonTest.EvaluatorSetupCode),
         SetupEvaluatorEnvironment()
     );
 }
Exemplo n.º 2
0
 public void FixtureSetUp()
 {
     EvaluatorPool = new EvaluatorPool(
         UseDebugJSShell
             ? ComparisonTest.DebugJSShellPath
             : ComparisonTest.JSShellPath,
         JSShellOptions,
         (e) =>
         e.WriteInput(ComparisonTest.EvaluatorSetupCode),
         SetupEvaluatorEnvironment()
         );
 }
Exemplo n.º 3
0
        public ComparisonTest(
            EvaluatorPool pool,
            IEnumerable<string> filenames, string outputPath, 
            string[] stubbedAssemblies = null, TypeInfoProvider typeInfo = null,
            AssemblyCache assemblyCache = null
        )
        {
            var started = DateTime.UtcNow.Ticks;
            OutputPath = outputPath;
            EvaluatorPool = pool;

            var extensions = (from f in filenames select Path.GetExtension(f).ToLower()).Distinct().ToArray();
            var absoluteFilenames = (from f in filenames select Path.Combine(TestSourceFolder, f));

            if (extensions.Length != 1)
                throw new InvalidOperationException("Mixture of different source languages provided.");

            var assemblyNamePrefix = Path.GetDirectoryName(outputPath).Split(new char[] { '\\', '/' }).Last();
            var assemblyName = Path.Combine(
                assemblyNamePrefix,
                Path.GetFileName(outputPath).Replace(".js", "")
            );

            switch (extensions[0]) {
                case ".cs":
                    Assembly = CompilerUtil.CompileCS(absoluteFilenames, assemblyName);
                    break;
                case ".vb":
                    Assembly = CompilerUtil.CompileVB(absoluteFilenames, assemblyName);
                    break;
                case ".exe":
                case ".dll":
                    var fns = absoluteFilenames.ToArray();
                    if (fns.Length > 1)
                        throw new InvalidOperationException("Multiple binary assemblies provided.");

                    Assembly = Assembly.LoadFile(fns[0]);
                    break;
                default:
                    throw new ArgumentException("Unsupported source file type for test");
            }

            if (typeInfo != null)
                typeInfo.ClearCaches();

            StubbedAssemblies = stubbedAssemblies;
            TypeInfo = typeInfo;
            AssemblyCache = assemblyCache;

            var ended = DateTime.UtcNow.Ticks;
            CompilationElapsed = TimeSpan.FromTicks(ended - started);
        }
Exemplo n.º 4
0
 public void FixtureSetUp()
 {
     EvaluatorPool = new EvaluatorPool(
         ComparisonTest.JSShellPath, "",
         (e) =>
         e.WriteInput(
             "load({0}, {1}, {2});",
             Util.EscapeString(ComparisonTest.CoreJSPath),
             Util.EscapeString(ComparisonTest.BootstrapJSPath),
             Util.EscapeString(ComparisonTest.XMLJSPath)
             )
         );
 }
Exemplo n.º 5
0
        public void Dispose()
        {
            if (EvaluatorPool != null)
            {
                EvaluatorPool.Dispose();
                EvaluatorPool = null;
            }

            if (DefaultTypeInfoProvider != null)
            {
                DefaultTypeInfoProvider.Dispose();
                DefaultTypeInfoProvider = null;
            }
        }
Exemplo n.º 6
0
 public ComparisonTest(
     EvaluatorPool pool, 
     string filename, string[] stubbedAssemblies = null, 
     TypeInfoProvider typeInfo = null, AssemblyCache assemblyCache = null
 )
     : this(pool,
         new[] { filename }, 
         Path.Combine(
             TestSourceFolder,
             MapSourceFileToTestFile(filename)
         ), 
         stubbedAssemblies, typeInfo, assemblyCache)
 {
 }
Exemplo n.º 7
0
 public ComparisonTest(
     EvaluatorPool pool,
     string filename, string[] stubbedAssemblies = null,
     TypeInfoProvider typeInfo = null, AssemblyCache assemblyCache = null
     ) : this(
         pool,
         new[] { filename },
         Path.Combine(
             TestSourceFolder,
             MapSourceFileToTestFile(filename)
             ),
         stubbedAssemblies, typeInfo, assemblyCache
         )
 {
 }
Exemplo n.º 8
0
 public void FixtureSetUp () {
     EvaluatorPool = new EvaluatorPool(
         UseDebugJSShell 
             ? ComparisonTest.DebugJSShellPath 
             : ComparisonTest.JSShellPath, 
         JSShellOptions,
         (e) =>
         {
             e.WriteInput(ComparisonTest.EvaluatorSetupCode);
             // When we'll find option to read environment variables in SpiderMonkey, delete this.
             e.WriteInput(ComparisonTest.EvaluatorPrepareEnvironmentCode(SetupEvaluatorEnvironment()));
             e.WriteInput(ComparisonTest.EvaluatorRunCode);
         },
         SetupEvaluatorEnvironment()
     );
 }
Exemplo n.º 9
0
        public void FixtureSetUp () {
            var setupCodePath = 

            EvaluatorPool = new EvaluatorPool(
                ComparisonTest.JSShellPath, 
                JSShellOptions,
                (e) =>
                {
                    var initCode =
                        ComparisonTest.EvaluatorSetupCode +
                        Environment.NewLine +
                        // When we'll find option to read environment variables in SpiderMonkey, delete this.
                        ComparisonTest.EvaluatorPrepareEnvironmentCode(SetupEvaluatorEnvironment()) +
                        Environment.NewLine +
                        ComparisonTest.EvaluatorRunCode;

                    e.WriteInput(initCode);
                },
                SetupEvaluatorEnvironment()
            );
        }
Exemplo n.º 10
0
        public void FixtureSetUp()
        {
            var setupCodePath =

                EvaluatorPool = new EvaluatorPool(
                    ComparisonTest.JSShellPath,
                    JSShellOptions,
                    (e) =>
            {
                var initCode =
                    ComparisonTest.EvaluatorSetupCode +
                    Environment.NewLine +
                    // When we'll find option to read environment variables in SpiderMonkey, delete this.
                    ComparisonTest.EvaluatorPrepareEnvironmentCode(SetupEvaluatorEnvironment()) +
                    Environment.NewLine +
                    ComparisonTest.EvaluatorRunCode;

                e.WriteInput(initCode);
            },
                    SetupEvaluatorEnvironment()
                    );
        }
Exemplo n.º 11
0
        public ComparisonTest(
            EvaluatorPool pool,
            IEnumerable <string> filenames, string outputPath,
            string[] stubbedAssemblies  = null, TypeInfoProvider typeInfo = null,
            AssemblyCache assemblyCache = null, string compilerOptions    = ""
            )
        {
            var started = DateTime.UtcNow.Ticks;

            OutputPath    = outputPath;
            EvaluatorPool = pool;

            var extensions        = (from f in filenames select Path.GetExtension(f).ToLower()).Distinct().ToArray();
            var absoluteFilenames = (from f in filenames select Path.Combine(TestSourceFolder, Portability.NormalizeDirectorySeparators(f)));

            if (extensions.Length != 1)
            {
                throw new InvalidOperationException("Mixture of different source languages provided.");
            }

            SourceDirectory = Path.GetDirectoryName(absoluteFilenames.First());

            var assemblyNamePrefix = Path.GetDirectoryName(outputPath).Split(new char[] { '\\', '/' }).Last();
            var assemblyName       = Path.Combine(
                assemblyNamePrefix,
                Path.GetFileName(outputPath).Replace(".js", "")
                );

            JSFilenames = null;

            if (UseAppDomains)
            {
                AssemblyAppDomain = AppDomain.CreateDomain("TestAssemblyDomain", null, new AppDomainSetup {
                    ApplicationBase = AppDomain.CurrentDomain.BaseDirectory,
                });
            }
            else
            {
                AssemblyAppDomain = AppDomain.CurrentDomain;
            }

            switch (extensions[0])
            {
            case ".exe":
            case ".dll":
                var fns = absoluteFilenames.ToArray();
                if (fns.Length > 1)
                {
                    throw new InvalidOperationException("Multiple binary assemblies provided.");
                }
                AssemblyUtility = CrossDomainHelper.CreateFromAssemblyPathOnRemoteDomain(AssemblyAppDomain, fns[0], extensions[0] == ".exe").AssemblyUtility;
                break;

            case ".js":
                JSFilenames     = absoluteFilenames.ToArray();
                Metacomments    = null;
                AssemblyUtility = null;
                break;

            default:
                bool ignore = false;
                try
                {
                    var helper = CrossDomainHelper.CreateFromCompileResultOnRemoteDomain(AssemblyAppDomain,
                                                                                         absoluteFilenames, assemblyName,
                                                                                         compilerOptions, CurrentMetaRevision);
                    Metacomments        = helper.Metacomments;
                    AssemblyUtility     = helper.AssemblyUtility;
                    CompilationCacheHit = helper.WasCached;
                }
                catch (TargetInvocationException exception)
                {
                    if (exception.InnerException is CompilerNotFoundException)
                    {
                        Assert.Ignore(exception.Message);
                    }
                    else
                    {
                        throw;
                    }
                }
                catch (CompilerNotFoundException exception)
                {
                    Assert.Ignore(exception.Message);
                }
                break;
            }

            if (typeInfo != null)
            {
                typeInfo.ClearCaches();
            }

            StubbedAssemblies = stubbedAssemblies;
            TypeInfo          = typeInfo;
            AssemblyCache     = assemblyCache;

            var ended = DateTime.UtcNow.Ticks;

            CompilationElapsed = TimeSpan.FromTicks(ended - started);
        }
Exemplo n.º 12
0
        public ComparisonTest(
            EvaluatorPool pool,
            IEnumerable <string> filenames, string outputPath,
            string[] stubbedAssemblies  = null, TypeInfoProvider typeInfo = null,
            AssemblyCache assemblyCache = null
            )
        {
            var started = DateTime.UtcNow.Ticks;

            OutputPath    = outputPath;
            EvaluatorPool = pool;

            var extensions        = (from f in filenames select Path.GetExtension(f).ToLower()).Distinct().ToArray();
            var absoluteFilenames = (from f in filenames select Path.Combine(TestSourceFolder, f));

            if (extensions.Length != 1)
            {
                throw new InvalidOperationException("Mixture of different source languages provided.");
            }

            var assemblyNamePrefix = Path.GetDirectoryName(outputPath).Split(new char[] { '\\', '/' }).Last();
            var assemblyName       = Path.Combine(
                assemblyNamePrefix,
                Path.GetFileName(outputPath).Replace(".js", "")
                );

            switch (extensions[0])
            {
            case ".cs":
                Assembly = CompilerUtil.CompileCS(absoluteFilenames, assemblyName);
                break;

            case ".vb":
                Assembly = CompilerUtil.CompileVB(absoluteFilenames, assemblyName);
                break;

            case ".exe":
            case ".dll":
                var fns = absoluteFilenames.ToArray();
                if (fns.Length > 1)
                {
                    throw new InvalidOperationException("Multiple binary assemblies provided.");
                }

                Assembly = Assembly.LoadFile(fns[0]);
                break;

            default:
                throw new ArgumentException("Unsupported source file type for test");
            }

            if (typeInfo != null)
            {
                typeInfo.ClearCaches();
            }

            StubbedAssemblies = stubbedAssemblies;
            TypeInfo          = typeInfo;
            AssemblyCache     = assemblyCache;

            var ended = DateTime.UtcNow.Ticks;

            CompilationElapsed = TimeSpan.FromTicks(ended - started);
        }
Exemplo n.º 13
0
 public void FixtureSetUp()
 {
     EvaluatorPool = new EvaluatorPool(
         ComparisonTest.JSShellPath, "",
         (e) =>
             e.WriteInput(
                 "load({0}, {1}, {2});",
                 Util.EscapeString(ComparisonTest.CoreJSPath),
                 Util.EscapeString(ComparisonTest.BootstrapJSPath),
                 Util.EscapeString(ComparisonTest.XMLJSPath)
             )
     );
 }