public void OutputsUnderSharedOpaqueInSubdirAreScrubbed() { var file = X("out/subdir/MyFile.txt"); var spec0 = ProduceFileUnderSharedOpaque(file); AddModule("Module0", ("spec0.dsc", spec0), placeInRoot: true); RunEngine(rememberAllChangedTrackedInputs: true); var objDir = Configuration.Layout.ObjectDirectory.ToString(Context.PathTable); // Make sure the file was produced Assert.True(File.Exists(Path.Combine(objDir, file))); // Change the spec so now another file is produced var anotherFile = X("out/MyOtherFile.txt"); spec0 = ProduceFileUnderSharedOpaque(anotherFile); // Overrite the spec with the new content and run the engine again File.WriteAllText(Path.Combine(Configuration.Layout.SourceDirectory.ToString(Context.PathTable), "spec0.dsc"), spec0); RunEngine(rememberAllChangedTrackedInputs: true); IgnoreWarnings(); // Make sure the new output is produced Assert.True(File.Exists(Path.Combine(objDir, anotherFile))); // Make sure the old output is deleted Assert.False(File.Exists(Path.Combine(objDir, file))); }
public void SharedOpaqueOutputsAreScrubbedRegardlessOfDirectoriesKnownToTheGraph() { var file = X("out/subdir1/subdir2/MyFile.txt"); var spec0 = ProduceFileUnderSharedOpaque(file); AddModule("Module0", ("spec0.dsc", spec0), placeInRoot: true); RunEngine(rememberAllChangedTrackedInputs: true); var objDir = Configuration.Layout.ObjectDirectory.ToString(Context.PathTable); // Make sure the file was produced Assert.True(File.Exists(Path.Combine(objDir, file))); // Change the spec so now another file is produced and the nested directory where the old output was is // declared as an input to the pip (so therefore becomes part of the graph) var anotherFile = X("out/MyOtherFile.txt"); spec0 = ProduceFileUnderSharedOpaque(anotherFile, dependencies: "f`out/subdir1/subdir2`"); // Overrite the spec with the new content and run the engine again File.WriteAllText(Path.Combine(Configuration.Layout.SourceDirectory.ToString(Context.PathTable), "spec0.dsc"), spec0); RunEngine(rememberAllChangedTrackedInputs: true); IgnoreWarnings(); // Make sure the new output is produced Assert.True(File.Exists(Path.Combine(objDir, anotherFile))); // Make sure the old output is deleted Assert.False(File.Exists(Path.Combine(objDir, file))); }
public void ExclusionsUnderSharedOpaquesAreNotScrubbed() { var file = X("out/subdir/MyFile.txt"); var spec0 = ProduceFileUnderSharedOpaque(file, exclusions: "d`obj/out/subdir/exclusion`"); AddModule("Module0", ("spec0.dsc", spec0), placeInRoot: true); // Produce two empty directories, which should be removed if the scrubbing process reaches them var objDir = Configuration.Layout.ObjectDirectory.ToString(Context.PathTable); var dir1 = Path.Combine(objDir, X("out/subdir/exclusion/dir1")); var dir2 = Path.Combine(objDir, X("out/subdir/no-exclusion/dir2")); FileUtilities.CreateDirectory(dir1); FileUtilities.CreateDirectory(dir2); RunEngine(); IgnoreWarnings(); // Make sure the file was produced Assert.True(File.Exists(Path.Combine(objDir, file))); // Dir1 should still be there, since it was under the exclusions Assert.True(Directory.Exists(dir1)); // Dir2 should be scrubbed Assert.False(Directory.Exists(dir2)); }
public void OutputsUnderSharedOpaqueAreProperlyMarkedEvenOnCacheReplay() { var file = X("out/SharedOpaqueOutput.txt"); var spec0 = ProduceFileUnderSharedOpaque(file); AddModule("Module0", ("spec0.dsc", spec0), placeInRoot: true); RunEngine(rememberAllChangedTrackedInputs: true); var objDir = Configuration.Layout.ObjectDirectory.ToString(Context.PathTable); var producedFile = Path.Combine(objDir, file); // Make sure the file was produced Assert.True(File.Exists(producedFile)); // And that it has been marked as shared opaque output XAssert.IsTrue(SharedOpaqueOutputHelper.IsSharedOpaqueOutput(producedFile)); File.Delete(producedFile); // Replay from cache this time RunEngine(rememberAllChangedTrackedInputs: true); IgnoreWarnings(); // Make sure this is a cache replay AssertVerboseEventLogged(global::BuildXL.Scheduler.Tracing.LogEventId.ProcessPipCacheHit); // And check again that the file is still properly marked XAssert.IsTrue(SharedOpaqueOutputHelper.IsSharedOpaqueOutput(producedFile)); }
public void DoubleWriteFailure() { const string spec = @" import {Cmd, Transformer} from 'Sdk.Transformers'; const step1 = Transformer.writeFile(p`obj/a.txt`, 'A'); const step2 = Transformer.execute({ tool: { exe: f`${Environment.getPathValue('ComSpec')}`, }, workingDirectory: d`.`, arguments: [ Cmd.rawArgument('/d /c echo step2 > obj\a.txt'), ], outputs: [ p`obj/a.txt`, ], }); "; AddModule("TestModule", ("test.dsc", spec), placeInRoot: true); RunEngine(expectSuccess: false); AssertErrorEventLogged(EventId.InvalidOutputDueToSimpleDoubleWrite); }
public void OutputsUnderSharedOpaqueHaveAWellKnownCreationTimeEvenOnCacheReplay() { var file = X("out/SharedOpaqueOutput.txt"); var spec0 = ProduceFileUnderSharedOpaque(file); AddModule("Module0", ("spec0.dsc", spec0), placeInRoot: true); RunEngine(rememberAllChangedTrackedInputs: true); var objDir = Configuration.Layout.ObjectDirectory.ToString(Context.PathTable); var producedFile = Path.Combine(objDir, file); // Make sure the file was produced Assert.True(File.Exists(producedFile)); // And that it has a well-known creation time XAssert.AreEqual(WellKnownTimestamps.OutputInSharedOpaqueTimestamp, FileUtilities.GetFileTimestamps(producedFile).CreationTime); File.Delete(producedFile); // Replay from cache this time RunEngine(rememberAllChangedTrackedInputs: true); IgnoreWarnings(); // Make sure this is a cache replay AssertVerboseEventLogged(EventId.ProcessPipCacheHit); // And check the timestamp again XAssert.AreEqual(WellKnownTimestamps.OutputInSharedOpaqueTimestamp, FileUtilities.GetFileTimestamps(producedFile).CreationTime); }
private void SetupTestData() { var spec0 = @" import {Artifact, Cmd, Tool, Transformer} from 'Sdk.Transformers'; namespace Namespace1.MyValueInTheSameNamespace { const subnamespace = 'MyValue'; } namespace Namespace2 { const valueInOtherNamespace = 'MyValue'; } namespace Namespace1 { export const value1 = 'Value from current module which is private'; } const step1 = Transformer.writeAllLines( p`obj/a.txt`, [ Namespace1.value1, ] ); "; var spec1 = @" @@public export const value1 = 'Value from module1'; "; AddModule("Module0", ("spec0.dsc", spec0), placeInRoot: true); AddModule("Module1", ("spec1.dsc", spec1)); }
private void AddCscDeployemnt() { AddSdk(GetTestDataValue("MicrosoftNetCompilersSdkLocation")); var spec = @" import {Artifact, Cmd, Tool, Transformer} from 'Sdk.Transformers'; const pkgContents = importFrom('Microsoft.Net.Compilers').Contents.all; @@public export const tool = { exe: pkgContents.getFile(r`tools/csc.exe`), description: 'Microsoft C# Compiler', runtimeDependencies: pkgContents.contents, untrackedDirectoryScopes: [ d`${Context.getMount('ProgramData').path}`, ], dependsOnWindowsDirectories: true, prepareTempDirectory: true, }; @@public export interface Arguments { outputPath: Path; targetType?: 'library' | 'exe'; sources: File[]; } @@public export interface Result { binary: File } @@public export function compile(args: Arguments) : Result { let result = Transformer.execute({ tool: tool, workingDirectory: d`.`, arguments: [ Cmd.option('/out:', Artifact.output(args.outputPath)), Cmd.option('/target:', args.targetType), Cmd.files(args.sources), ], }); return { binary: result.getOutputFile(args.outputPath), }; } "; AddModule("Sdk.Managed.Tools.Csc", ("cscHack.dsc", spec)); }
public void AllowedRewrittenSourcesAreNotFlaggedAsSharedOpaques() { var objDir = Configuration.Layout.ObjectDirectory.ToString(Context.PathTable); var file = X("out/SharedOpaqueOutput.txt"); var producedFile = Path.Combine(objDir, file); // Create the file beforehand so it introduces an allowed rewrite Directory.CreateDirectory(Directory.GetParent(producedFile).FullName); string originalContent = "content"; string rewrittenContent = "rewritten"; File.WriteAllText(producedFile, originalContent); var spec0 = ProduceFileUnderSharedOpaque(file, allowSourceRewrites: true, allowUndeclaredReads: true, content: rewrittenContent); AddModule("Module0", ("spec0.dsc", spec0), placeInRoot: true); RunEngine(rememberAllChangedTrackedInputs: true); // Make sure the file was produced with rewritten content Assert.True(File.Exists(producedFile)); Assert.Equal(rewrittenContent, File.ReadAllText(producedFile).Trim(' ', '\r', '\n')); // And that it has not been marked as shared opaque output XAssert.IsFalse(SharedOpaqueOutputHelper.IsSharedOpaqueOutput(producedFile)); // We should place the file as a copy, not hardlinked to the cache, and therefore the file should be modifiable // This operation will throw otherwise File.AppendAllText(producedFile, " we should be able to modify the file"); // Restore the file to its initial shape File.Delete(producedFile); File.WriteAllText(producedFile, originalContent); // Replay from cache this time RunEngine(rememberAllChangedTrackedInputs: true); // Make sure the file was produced with rewritten content Assert.True(File.Exists(producedFile)); Assert.Equal(rewrittenContent, File.ReadAllText(producedFile).Trim(' ', '\r', '\n')); IgnoreWarnings(); // Make sure this is a cache replay AssertVerboseEventLogged(global::BuildXL.Scheduler.Tracing.LogEventId.ProcessPipCacheHit); // And check again that the file is still not marked XAssert.IsFalse(SharedOpaqueOutputHelper.IsSharedOpaqueOutput(producedFile)); // We should place the file as a copy, not hardlinked to the cache, and therefore the file should be modifiable // This operation will throw otherwise File.AppendAllText(producedFile, " we should be able to modify the file"); }
public void TestResourceBasedCancellationIsNotAllowedWithSharedOpaques() { var spec0 = SpecWithOpaques(); AddModule("Module0", ("spec0.dsc", spec0), placeInRoot: true); // enable resource based cancellation Configuration.Schedule.DisableProcessRetryOnResourceExhaustion = false; // do not need to run the pips - the check happens before execution phase Configuration.Engine.Phase = EnginePhases.Schedule; RunEngine(expectSuccess: false); AssertErrorEventLogged(global::BuildXL.Engine.Tracing.LogEventId.ResourceBasedCancellationIsEnabledWithSharedOpaquesPresent); }
public void StaticOutputBecomingASharedOpaqueOutputIsProperlyMarkedAsSharedOpaqueOutput() { var file = X($"out/MyFile.txt"); XAssert.PossiblySucceeded(FileUtilities.TryDeleteFile(file)); var message = Guid.NewGuid().ToString(); var spec0 = ProduceFileStatically(file, content: message); AddModule("Module0", ("spec0.dsc", spec0), placeInRoot: true); RunEngine(rememberAllChangedTrackedInputs: true); var objDir = Configuration.Layout.ObjectDirectory.ToString(Context.PathTable); var producedFile = Path.Combine(objDir, file); // Make sure the file was produced Assert.True(File.Exists(producedFile)); // Since this is a statically declared file, it shouldn't be marked as a shared opaque output XAssert.IsFalse(SharedOpaqueOutputHelper.IsSharedOpaqueOutput(producedFile), "Statically declared file marked as shared opaque output: " + producedFile); // Delete the created file (since scrubbing is not on for this test, we have to simulate it) File.Delete(producedFile); // Overrite the spec so now the same file is generated as a shared opaque output spec0 = ProduceFileUnderSharedOpaque(file, content: message); File.WriteAllText(Path.Combine(Configuration.Layout.SourceDirectory.ToString(Context.PathTable), "spec0.dsc"), spec0); // Run the pip RunEngine(rememberAllChangedTrackedInputs: true); // Check the timestamp is the right one XAssert.IsTrue(SharedOpaqueOutputHelper.IsSharedOpaqueOutput(producedFile), "SOD file not marked on cache miss"); // Delete the file File.Delete(producedFile); // Replay from cache. Since the file content is unchanged, the cache should have a blob // corresponding to the first pip, where the file was a statically declared output RunEngine(rememberAllChangedTrackedInputs: true); IgnoreWarnings(); // Make sure this is a cache replay AssertVerboseEventLogged(global::BuildXL.Scheduler.Tracing.LogEventId.ProcessPipCacheHit); // Check the timestamp is the right one now XAssert.IsTrue(SharedOpaqueOutputHelper.IsSharedOpaqueOutput(producedFile), "SOD file not marked on cache replay"); }
public ActionResult AssignModulesByTeamLead(AddModule addModule) { if (addModule != null) { try { Projects projects = db.Projects.FirstOrDefault(projec => projec.Project_Id == addModule.Project_ID); ProjectModules projectModules = new ProjectModules(); projects.No_Of_Modules = addModule.Num_Ofmodules; projectModules.ProjectId = addModule.Project_ID; projectModules.Module_Name = addModule.ModuleName; projectModules.Assigned_Dev_Id = addModule.Assign_Developer; projectModules.Assigned_Tester_Id = addModule.Assign_Tester; db.ProjectModules.Add(projectModules); db.SaveChanges(); ViewBag.assMod = "Module assigned"; } catch (Exception ex) { ViewBag.assMod = ex.Message; } } return(View()); }
public void Should_throw_exception_when_page_is_not_found() { var command = new AddModule { SiteId = Guid.NewGuid(), PageId = Guid.NewGuid(), ModuleTypeId = Guid.NewGuid(), Zone = "Zone", SortOrder = 1, Title = "Title" }; var moduleRepositoryMock = new Mock <IModuleRepository>(); var pageRepositoryMock = new Mock <IPageRepository>(); pageRepositoryMock.Setup(x => x.GetById(command.SiteId, command.PageId)).Returns((Page)null); var createModuleValidatorMock = new Mock <IValidator <CreateModule> >(); createModuleValidatorMock.Setup(x => x.Validate(It.IsAny <CreateModule>())).Returns(new ValidationResult()); var addPageModuleValidatorMock = new Mock <IValidator <AddPageModule> >(); addPageModuleValidatorMock.Setup(x => x.Validate(It.IsAny <AddPageModule>())).Returns(new ValidationResult()); var addModuleHandler = new AddModuleHandler(moduleRepositoryMock.Object, pageRepositoryMock.Object, createModuleValidatorMock.Object, addPageModuleValidatorMock.Object); Assert.Throws <Exception>(() => addModuleHandler.Handle(command)); }
private void NewMenuItemClick(object sender, RoutedEventArgs e) { try { if (Framework.Database.IsConnected() == false) { Framework.Notification.Display(Properties.Resources.DatabaseConnectionRequired, 5000); Framework.EventBus.Publish(new PreferencesEvent(this, typeof(IDatabase))); return; } if (ModuleHandler.GetClient() == null) { Framework.Notification.Display(Properties.Resources.ServerConnectionRequired, 5000); Framework.EventBus.Publish(new PreferencesEvent(this, typeof(INetwork))); return; } this.CallBackDelegate += ModuleHandler.CreateModule; var popup = Framework.Dialog; var cou = new AddModule(this, popup); popup.SetChild(cou); popup.ShowBlocking(); this.CallBackDelegate -= ModuleHandler.CreateModule; } catch (Exception error) { Framework.EventBus.Publish(error); } }
public void Should_return_events() { var command = new AddModule { SiteId = Guid.NewGuid(), PageId = Guid.NewGuid(), ModuleTypeId = Guid.NewGuid(), Zone = "Zone", SortOrder = 1, Title = "Title" }; var moduleRepositoryMock = new Mock <IModuleRepository>(); var pageRepositoryMock = new Mock <IPageRepository>(); pageRepositoryMock.Setup(x => x.GetById(command.SiteId, command.PageId)).Returns(new Page()); var createModuleValidatorMock = new Mock <IValidator <CreateModule> >(); createModuleValidatorMock.Setup(x => x.Validate(It.IsAny <CreateModule>())).Returns(new ValidationResult()); var addPageModuleValidatorMock = new Mock <IValidator <AddPageModule> >(); addPageModuleValidatorMock.Setup(x => x.Validate(It.IsAny <AddPageModule>())).Returns(new ValidationResult()); var addModuleHandler = new AddModuleHandler(moduleRepositoryMock.Object, pageRepositoryMock.Object, createModuleValidatorMock.Object, addPageModuleValidatorMock.Object); var events = addModuleHandler.Handle(command); var enumerable = events as IList <IEvent> ?? events.ToList(); Assert.AreEqual(typeof(ModuleCreated), enumerable.FirstOrDefault().GetType()); Assert.AreEqual(typeof(PageModuleAdded), enumerable.Skip(1).FirstOrDefault().GetType()); }
public void Should_create_module() { var command = new AddModule { SiteId = Guid.NewGuid(), PageId = Guid.NewGuid(), ModuleTypeId = Guid.NewGuid(), Zone = "Zone", SortOrder = 1, Title = "Title" }; var moduleRepositoryMock = new Mock <IModuleRepository>(); moduleRepositoryMock.Setup(x => x.Create(It.IsAny <Module>())); var pageRepositoryMock = new Mock <IPageRepository>(); pageRepositoryMock.Setup(x => x.GetById(command.SiteId, command.PageId)).Returns(new Page()); var createModuleValidatorMock = new Mock <IValidator <CreateModule> >(); createModuleValidatorMock.Setup(x => x.Validate(It.IsAny <CreateModule>())).Returns(new ValidationResult()); var addPageModuleValidatorMock = new Mock <IValidator <AddPageModule> >(); addPageModuleValidatorMock.Setup(x => x.Validate(It.IsAny <AddPageModule>())).Returns(new ValidationResult()); var addModuleHandler = new AddModuleHandler(moduleRepositoryMock.Object, pageRepositoryMock.Object, createModuleValidatorMock.Object, addPageModuleValidatorMock.Object); addModuleHandler.Handle(command); moduleRepositoryMock.Verify(x => x.Create(It.IsAny <Module>())); }
internal static async Task AddModuleAsync([NotNull] AddModule srv) { var(id, success, message) = await TryAddModuleAsync(srv.Request.ModuleType, srv.Request.Id); srv.Response.Success = success; srv.Response.Message = message ?? ""; srv.Response.Id = id ?? ""; }
public void StaticOutputBecomingASharedOpaqueOutputHasWellKnownCreationTime() { var file = X("out/MyFile.txt"); var spec0 = ProduceFileStatically(file); AddModule("Module0", ("spec0.dsc", spec0), placeInRoot: true); RunEngine(rememberAllChangedTrackedInputs: true); var objDir = Configuration.Layout.ObjectDirectory.ToString(Context.PathTable); var producedFile = Path.Combine(objDir, file); // Make sure the file was produced Assert.True(File.Exists(producedFile)); // Since this is a statically declared file, the creation timestamp should not be the one used for shared opaques XAssert.AreNotEqual(WellKnownTimestamps.OutputInSharedOpaqueTimestamp, FileUtilities.GetFileTimestamps(producedFile).CreationTime); // Delete the created file (since scrubbing is not on for this test, we have to simulate it) File.Delete(producedFile); // Overrite the spec so now the same file is generated as a shared opaque output spec0 = ProduceFileUnderSharedOpaque(file); File.WriteAllText(Path.Combine(Configuration.Layout.SourceDirectory.ToString(Context.PathTable), "spec0.dsc"), spec0); // Run the pip RunEngine(rememberAllChangedTrackedInputs: true); // Check the timestamp is the right one XAssert.AreEqual(WellKnownTimestamps.OutputInSharedOpaqueTimestamp, FileUtilities.GetFileTimestamps(producedFile).CreationTime); // Delete the file File.Delete(producedFile); // Replay from cache. Since the file content is unchanged, the cache should have a blob // corresponding to the first pip, where the file was a statically declared output RunEngine(rememberAllChangedTrackedInputs: true); IgnoreWarnings(); // Make sure this is a cache replay AssertVerboseEventLogged(EventId.ProcessPipCacheHit); // Check the timestamp is the right one now XAssert.AreEqual(WellKnownTimestamps.OutputInSharedOpaqueTimestamp, FileUtilities.GetFileTimestamps(producedFile).CreationTime); }
public async Task <IActionResult> AddModule([FromBody] AddModule model) { model.SiteId = SiteId; model.ViewPermissionRoleIds = await _identityService.GetDefaultModuleViewPermissionRoleIds(); await Task.Run(() => _commandSender.Send <AddModule, Page>(model)); return(new NoContentResult()); }
public void SharedOpaqueOutputsOnFailingPipHaveWellKnownCreationTime() { var file = X("out/MyFile.txt"); var objDir = Configuration.Layout.ObjectDirectory.ToString(Context.PathTable); var producedFile = Path.Combine(objDir, file); var spec0 = ProduceFileUnderSharedOpaque(file, failOnExit: true); AddModule("Module0", ("spec0.dsc", spec0), placeInRoot: true); // Run the pip RunEngine(rememberAllChangedTrackedInputs: true, expectSuccess: false); AssertErrorEventLogged(EventId.PipProcessError); // Check the timestamp is the right one XAssert.AreEqual(WellKnownTimestamps.OutputInSharedOpaqueTimestamp, FileUtilities.GetFileTimestamps(producedFile).CreationTime); }
public void SharedOpaqueOutputsOnFailingPipMustBeProperlyMarked() { var file = X("out/MyFile.txt"); var objDir = Configuration.Layout.ObjectDirectory.ToString(Context.PathTable); var producedFile = Path.Combine(objDir, file); var spec0 = ProduceFileUnderSharedOpaque(file, failOnExit: true); AddModule("Module0", ("spec0.dsc", spec0), placeInRoot: true); // Run the pip RunEngine(rememberAllChangedTrackedInputs: true, expectSuccess: false); AssertErrorEventLogged(LogEventId.PipProcessError); // Check the timestamp is the right one XAssert.IsTrue(SharedOpaqueOutputHelper.IsSharedOpaqueOutput(producedFile), "SOD file not marked on pip failure"); }
public IActionResult AddModule([FromBody] AddModule model) { model.SiteId = SiteId; var defaultViewRoleIds = new List<Guid> { Administrator.Id }; var defaultEditRoleIds = new List<Guid> { Administrator.Id }; model.SetPageModulePermissions(defaultViewRoleIds, defaultEditRoleIds); _commandSender.Send<AddModule, Page>(model); return new NoContentResult(); }
public async Task <IActionResult> AddModule([FromBody] AddModule model) { model.SiteId = SiteId; var defaultViewRoleIds = await _roleService.GetDefaultModuleViewPermissionRoleIds(); var defaultEditRoleIds = await _roleService.GetDefaultModuleEditPermissionRoleIds(); model.SetPageModulePermissions(defaultViewRoleIds, defaultEditRoleIds); await Task.Run(() => _commandSender.Send <AddModule, Page>(model)); return(new NoContentResult()); }
public void EngineStateIsUpdatedAfterFailedScheduling() { SetupHelloWorld(); SetUpConfig(); EngineState afterFirst = RunEngine("First build"); RestartEngine(); AddModule("HelloWorld", ("hello.dsc", "invalid spec content"), placeInRoot: true); // Invalid spec SetUpConfig(); // Build should fail var afterFail = RunEngine("Engine State is Updated", expectSuccess: false, engineState: afterFirst); AssertErrorEventLogged(global::BuildXL.FrontEnd.Core.Tracing.LogEventId.TypeScriptSyntaxError, 5); AssertErrorEventLogged(global::BuildXL.FrontEnd.Core.Tracing.LogEventId.CannotBuildWorkspace); XAssert.IsNotNull(afterFail); XAssert.IsTrue(EngineState.IsUsable(afterFail)); XAssert.IsFalse(EngineState.IsUsable(afterFirst)); XAssert.AreNotSame(afterFirst, afterFail); }
public ActionResult AssignModulesByTeamLead(string tlid, string pId) { Projects projects = db.Projects.FirstOrDefault(pro => pro.Project_Id == pId && pro.TeamLead_Id == tlid); AddModule addModule = new AddModule(); if (projects != null) { addModule.Project_ID = projects.Project_Id; addModule.ProjectName = projects.Project_Name; addModule.Num_Ofmodules = projects.No_Of_Modules; } return(View(addModule)); }
public void DoubleWriteFailure() { string spec = @" import {Cmd, Transformer} from 'Sdk.Transformers'; const step1 = Transformer.writeFile(p`obj/a.txt`, 'A'); const step2 = Transformer.execute({ tool: {" + $"exe: f`{(OperatingSystemHelper.IsUnixOS ? "/bin/sh" : @"${Environment.getPathValue(""COMSPEC"")}")}`" + @"}, workingDirectory: d`.`, arguments: [ Cmd.rawArgument('" + $"{(OperatingSystemHelper.IsUnixOS ? "-c echo step2 > obj/a.txt" : @"/d /c echo step2 > obj\a.txt")}" + @"'), ], outputs: [ p`obj/a.txt`, ], }); "; AddModule("TestModule", ("test.dsc", spec), placeInRoot: true); RunEngine(expectSuccess: false); AssertErrorEventLogged(global::BuildXL.Pips.Tracing.LogEventId.InvalidOutputDueToSimpleDoubleWrite); }
public void UnsafeEmptyDirectoriesUnderSharedOpaqueAreNotScrubbedWhenDisabled(bool disableEmptyDirectoryScrubbing) { // The unsafe option should be off by default Assert.False(Configuration.Schedule.UnsafeDisableSharedOpaqueEmptyDirectoryScrubbing); // Create a directory that is not part of the spec var objDir = Configuration.Layout.ObjectDirectory.ToString(Context.PathTable); var untrackedDirectoryPath = Path.Combine(objDir, X("out/subdir/untracked/")); var file = X("out/subdir/MyFile.txt"); var spec0 = ProduceFileUnderSharedOpaque(file); AddModule("Module0", ("spec0.dsc", spec0), placeInRoot: true); Assert.False(Directory.Exists(untrackedDirectoryPath)); Directory.CreateDirectory(untrackedDirectoryPath); Configuration.Schedule.UnsafeDisableSharedOpaqueEmptyDirectoryScrubbing = disableEmptyDirectoryScrubbing; RunEngine(expectSuccess: true); // When the option is disabled, the untracked directory should be removed. Assert.Equal(Directory.Exists(untrackedDirectoryPath), disableEmptyDirectoryScrubbing); Configuration.Schedule.UnsafeDisableSharedOpaqueEmptyDirectoryScrubbing = false; }
public void TestCleanOnlyArgument() { var spec0 = SpecWithOpaques(); AddModule("Module0", ("spec0.dsc", spec0), placeInRoot: true); Configuration.Engine.CleanOnly = true; Configuration.Schedule.DisableProcessRetryOnResourceExhaustion = true; // first run to create all necessary directories leading to obj directory RunEngine(); var objectDirectoryPath = Configuration.Layout.ObjectDirectory.ToString(Context.PathTable); var shared = Path.Combine(objectDirectoryPath, "shared"); Directory.CreateDirectory(shared); var fileUnderShared = Path.Combine(shared, "foo.txt"); File.WriteAllText(fileUnderShared, Guid.NewGuid().ToString()); var exclusive = Path.Combine(objectDirectoryPath, "exclusive"); Directory.CreateDirectory(exclusive); var fileUnderExclusive = Path.Combine(exclusive, "foo.txt"); File.WriteAllText(fileUnderExclusive, Guid.NewGuid().ToString()); RunEngine(); // the opaque dir should be on disk but they should be empty XAssert.IsTrue(Directory.Exists(shared)); XAssert.IsTrue(Directory.Exists(exclusive)); XAssert.IsFalse(File.Exists(fileUnderShared)); XAssert.IsFalse(File.Exists(fileUnderExclusive)); }
public void Should_add_module_to_page() { var command = new AddModule { SiteId = Guid.NewGuid(), PageId = Guid.NewGuid(), ModuleTypeId = Guid.NewGuid(), Zone = "Zone", SortOrder = 2, Title = "Title" }; var page = PageFactory.Page(command.SiteId, command.PageId, "My Page"); page.Events.Clear(); var moduleRepositoryMock = new Mock <IModuleRepository>(); var pageRepositoryMock = new Mock <IPageRepository>(); pageRepositoryMock.Setup(x => x.GetById(command.SiteId, command.PageId)).Returns(page); pageRepositoryMock.Setup(x => x.Update(It.IsAny <Page>())); var createModuleValidatorMock = new Mock <IValidator <CreateModule> >(); createModuleValidatorMock.Setup(x => x.Validate(It.IsAny <CreateModule>())).Returns(new ValidationResult()); var addPageModuleValidatorMock = new Mock <IValidator <AddPageModule> >(); addPageModuleValidatorMock.Setup(x => x.Validate(It.IsAny <AddPageModule>())).Returns(new ValidationResult()); var addModuleHandler = new AddModuleHandler(moduleRepositoryMock.Object, pageRepositoryMock.Object, createModuleValidatorMock.Object, addPageModuleValidatorMock.Object); addModuleHandler.Handle(command); var @event = page.Events.OfType <PageModuleAdded>().SingleOrDefault(); Assert.IsNotNull(@event); }
public void Rewrite() { var shellCmd = OperatingSystemHelper.IsUnixOS ? (start : "-c \"", cmd : "/bin/cat ", end : " | /bin/cat \"") : (start : "/d /c ", cmd : "type ", end : " "); string spec = $@" import {{Artifact, Cmd, Tool, Transformer}} from 'Sdk.Transformers'; {GetExecuteFunction()} const cmd = {GetOsShellCmdToolDefinition()}; const step1 = Transformer.writeAllLines( p`obj/a.txt`, [ 'A' ]); const step2OutputPath = p`obj/b.txt`; const step2 = execute({{ tool: cmd, workingDirectory: d`.`, arguments: [ Cmd.rawArgument('{shellCmd.start}'), Cmd.rawArgument('{shellCmd.cmd}'), Cmd.argument(Artifact.none(step2OutputPath)), Cmd.rawArgument('{shellCmd.end}'), Cmd.rawArgument(' >> '), Cmd.argument(Artifact.rewritten(step1, step2OutputPath)), ], }}).getOutputFile(step2OutputPath); const step3OutputPath = p`obj/c.txt`; const step3 = execute({{ tool: cmd, workingDirectory: d`.`, arguments: [ Cmd.rawArgument('{shellCmd.start}'), Cmd.rawArgument('{shellCmd.cmd}'), Cmd.argument(Artifact.none(step3OutputPath)), Cmd.rawArgument('{shellCmd.end}'), Cmd.rawArgument(' >> '), Cmd.argument(Artifact.rewritten(step2, step3OutputPath)), ], }}).getOutputFile(step3OutputPath); const step4OutputPath = p`obj/d.txt`; const step4 = execute({{ tool: cmd, workingDirectory: d`.`, arguments: [ Cmd.rawArgument('{shellCmd.start}'), Cmd.rawArgument('{shellCmd.cmd}'), Cmd.argument(Artifact.none(step4OutputPath)), Cmd.rawArgument('{shellCmd.end}'), Cmd.rawArgument(' >> '), Cmd.argument(Artifact.rewritten(step3, step4OutputPath)), ], }}).getOutputFile(step4OutputPath); "; AddModule("test", ("spec.dsc", spec), placeInRoot: true); RunEngine(); string testFile = Path.Combine(Configuration.Layout.ObjectDirectory.ToString(Context.PathTable), "d.txt"); XAssert.IsTrue(File.Exists(testFile)); XAssert.AreEqual(@"AAAAAAAA", string.Join(string.Empty, File.ReadAllLines(testFile))); }