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."); } var assemblyNamePrefix = Path.GetDirectoryName(outputPath).Split(new char[] { '\\', '/' }).Last(); var assemblyName = Path.Combine( assemblyNamePrefix, Path.GetFileName(outputPath).Replace(".js", "") ); switch (extensions[0]) { 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: CompileResult = CompilerUtil.Compile(absoluteFilenames, assemblyName, compilerOptions: compilerOptions); Assembly = CompileResult.Assembly; break; } if (typeInfo != null) { typeInfo.ClearCaches(); } StubbedAssemblies = stubbedAssemblies; TypeInfo = typeInfo; AssemblyCache = assemblyCache; var ended = DateTime.UtcNow.Ticks; CompilationElapsed = TimeSpan.FromTicks(ended - started); }
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); }
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); }