private bool TryDeleteTempFiles(bool lastTry) { var result = true; if (_codeGenDir != null && _codeGenDir.Exists) { Log("Trying to delete temporary files at \"{0}\"", _codeGenDir); try { _codeGenDir.Delete(true); // <- clean as much as possible } catch (Exception e) { if (lastTry) Log("Failure: \"{0}\"", e); result = false; } } if (_tempSite != null && _tempSite.Exists) try { Log("Trying to delete temporary files at \"{0}\"", _tempSite); _tempSite.Delete(true); // <- progressively clean as much as possible } catch (Exception e) { if (lastTry) Log("failure: \"{0}\"", e); result = false; } return result; }
public void Init() { var builder = new ContainerBuilder(); builder.RegisterType<RubyScriptingRuntime>().As<IScriptingRuntime>(); builder.RegisterType<ScriptingManager>().As<IScriptingManager>(); _container = builder.Build(); _scriptingRuntime = _container.Resolve<IScriptingRuntime>(); _scriptingManager = _container.Resolve<IScriptingManager>(); _tempFolderName = _tempFixtureFolderName.Combine(System.IO.Path.GetRandomFileName()); try { _tempFolderName.Delete(); } catch { } _tempFolderName.CreateDirectory(); }
public void Init() { var builder = new ContainerBuilder(); builder.RegisterType <RubyScriptingRuntime>().As <IScriptingRuntime>(); builder.RegisterType <ScriptingManager>().As <IScriptingManager>(); _container = builder.Build(); _scriptingRuntime = _container.Resolve <IScriptingRuntime>(); _scriptingManager = _container.Resolve <IScriptingManager>(); _tempFolderName = _tempFixtureFolderName.Combine(System.IO.Path.GetRandomFileName()); try { _tempFolderName.Delete(); } catch { } _tempFolderName.CreateDirectory(); }
public static void BeforeTestRun() { try { _orchardTemp.Delete(true).CreateDirectory(); } catch { } }
public void Initialize(string templateName, string virtualDirectory, DynamicCompilationOption dynamicCompilationOption) { var stopwatch = new Stopwatch(); stopwatch.Start(); var baseDir = Path.Get(AppDomain.CurrentDomain.BaseDirectory); _tempSite = _orchardTemp.Combine(System.IO.Path.GetRandomFileName()); try { _tempSite.Delete(); } catch { } // Trying the two known relative paths to the Orchard.Web directory. // The second one is for the target "spec" in orchard.proj. _orchardWebPath = baseDir; while (!_orchardWebPath.Combine("Orchard.proj").Exists&& _orchardWebPath.Parent != null) { _orchardWebPath = _orchardWebPath.Parent; } _orchardWebPath = _orchardWebPath.Combine("src").Combine("Orchard.Web"); Log("Initialization of ASP.NET host for template web site \"{0}\":", templateName); Log(" Source location: \"{0}\"", _orchardWebPath); Log(" Temporary location: \"{0}\"", _tempSite); _knownModules = _orchardWebPath.Combine("Modules").Directories.Where(d => d.Combine("module.txt").Exists).Select(d => d.FileName).ToList(); //foreach (var filename in _knownModules) // Log("Available Module: \"{0}\"", filename); _knownThemes = _orchardWebPath.Combine("Themes").Directories.Where(d => d.Combine("theme.txt").Exists).Select(d => d.FileName).ToList(); //foreach (var filename in _knownThemes) // Log("Available Theme: \"{0}\"", filename); _knownBinAssemblies = _orchardWebPath.Combine("bin").GetFiles("*.dll").Select(f => f.FileNameWithoutExtension); //foreach (var filename in _knownBinAssemblies) // Log("Assembly in ~/bin: \"{0}\"", filename); Log("Copy files from template \"{0}\"", templateName); baseDir.Combine("Hosting").Combine(templateName) .DeepCopy(_tempSite); if (dynamicCompilationOption != DynamicCompilationOption.Enabled) { var sourceConfig = baseDir.Combine("Hosting").Combine("TemplateConfigs"); var siteConfig = _tempSite.Combine("Config"); switch (dynamicCompilationOption) { case DynamicCompilationOption.Disabled: File.Copy(sourceConfig.Combine("DisableDynamicCompilation.HostComponents.config"), siteConfig.Combine("HostComponents.config")); break; case DynamicCompilationOption.Force: File.Copy(sourceConfig.Combine("ForceDynamicCompilation.HostComponents.config"), siteConfig.Combine("HostComponents.config")); break; } } Log("Copy binaries of the \"Orchard.Web\" project"); _orchardWebPath.Combine("bin") .ShallowCopy("*.dll", _tempSite.Combine("bin")) .ShallowCopy("*.pdb", _tempSite.Combine("bin")); Log("Copy SqlCe native binaries"); if (_orchardWebPath.Combine("bin").Combine("x86").IsDirectory) { _orchardWebPath.Combine("bin").Combine("x86") .DeepCopy("*.*", _tempSite.Combine("bin").Combine("x86")); } if (_orchardWebPath.Combine("bin").Combine("amd64").IsDirectory) { _orchardWebPath.Combine("bin").Combine("amd64") .DeepCopy("*.*", _tempSite.Combine("bin").Combine("amd64")); } // Copy binaries of this project, so that remote execution of lambda // can be achieved through serialization to the ASP.NET appdomain // (see Execute(Action) method) Log("Copy Orchard.Specflow test project binaries"); baseDir.ShallowCopy( path => IsSpecFlowTestAssembly(path) && !_tempSite.Combine("bin").Combine(path.FileName).Exists, _tempSite.Combine("bin")); Log("Copy Orchard recipes"); _orchardWebPath.Combine("Modules").Combine("Orchard.Setup").Combine("Recipes").DeepCopy("*.xml", _tempSite.Combine("Modules").Combine("Orchard.Setup").Combine("Recipes")); StartAspNetHost(virtualDirectory); Log("ASP.NET host initialization completed in {0} sec", stopwatch.Elapsed.TotalSeconds); }
public void CreateDb() { var types = new[] { typeof(BlogRecord), typeof(BodyRecord), typeof(BlogArchiveRecord), typeof(ContentItemVersionRecord), typeof(ContentItemRecord), typeof(ContentTypeRecord) }; _tempFolderName = _tempFixtureFolderName.Combine(System.IO.Path.GetRandomFileName()); try { _tempFixtureFolderName.Delete(true); } catch {} _tempFixtureFolderName.CreateDirectory(); _sessionFactory = DataUtility.CreateSessionFactory( _tempFolderName, types); var builder = new ContainerBuilder(); _folders = new StubFolders(); var manager = (IDataServicesProviderFactory) new DataServicesProviderFactory(new[] { new Meta <CreateDataServicesProvider>( (dataFolder, connectionString) => new SqlCeDataServicesProvider(dataFolder, connectionString), new Dictionary <string, object> { { "ProviderName", "SqlCe" } }) }); builder.RegisterInstance(new ShellSettings { Name = ShellSettings.DefaultName, DataTablePrefix = "TEST", DataProvider = "SqlCe" }); builder.RegisterInstance(AppDataFolderTests.CreateAppDataFolder(_tempFixtureFolderName)).As <IAppDataFolder>(); builder.RegisterType <SessionConfigurationCache>().As <ISessionConfigurationCache>(); builder.RegisterType <SqlCeDataServicesProvider>().As <IDataServicesProvider>(); builder.RegisterInstance(manager).As <IDataServicesProviderFactory>(); builder.RegisterType <NullInterpreter>().As <IDataMigrationInterpreter>(); builder.RegisterType <SessionFactoryHolder>().As <ISessionFactoryHolder>(); builder.RegisterType <DefaultDatabaseCacheConfiguration>().As <IDatabaseCacheConfiguration>(); builder.RegisterType <CompositionStrategy>().As <ICompositionStrategy>(); builder.RegisterInstance(_folders).As <IExtensionFolders>(); builder.RegisterType <StubLoaders>().As <IExtensionLoader>(); builder.RegisterType <ExtensionManager>().As <IExtensionManager>(); builder.RegisterType <SchemaCommandGenerator>().As <ISchemaCommandGenerator>(); builder.RegisterGeneric(typeof(Repository <>)).As(typeof(IRepository <>)); builder.RegisterType <StubCacheManager>().As <ICacheManager>(); builder.RegisterType <StubParallelCacheContext>().As <IParallelCacheContext>(); builder.RegisterType <StubAsyncTokenProvider>().As <IAsyncTokenProvider>(); builder.RegisterType <StubHostEnvironment>().As <IHostEnvironment>(); _session = _sessionFactory.OpenSession(); builder.RegisterInstance(new DefaultContentManagerTests.TestSessionLocator(_session)).As <ISessionLocator>(); builder.RegisterInstance(new ShellBlueprint()); _container = builder.Build(); _generator = _container.Resolve <ISchemaCommandGenerator>(); _folders.Manifests.Add("Feature1", @" Name: Module1 Version: 0.1 CoeveryVersion: 1 Features: Feature1: Description: Feature "); }