public void TestCancellationToken() { Logger logger = Utils.CleanContext(); var builder = Utils.CreateBuilder(); var commands = new List <Command>(); for (var i = 0; i < 8; ++i) { commands.Add(new DummyBlockingCommand { Delay = 1000000 }); } for (var i = 0; i < 8; ++i) { commands.Add(new DummyAwaitingCommand { Delay = 1000000 }); } IEnumerable <BuildStep> steps = builder.Root.Add(commands); var cancelThread = new Thread(() => { Thread.Sleep(1000); logger.Warning("Cancelling build!"); builder.CancelBuild(); }); cancelThread.Start(); builder.Run(Builder.Mode.Build); foreach (BuildStep step in steps) { Assert.That(step.Status, Is.EqualTo(ResultStatus.Cancelled)); } }
public void TestUseBuildCacheOutput() { Utils.CleanContext(); Utils.GenerateSourceFile("input1", "{32E4EDF4-E8AA-4D13-B111-9BD8AA2A8B07}"); var builder1 = Utils.CreateBuilder(false); builder1.Root.Add(new InputOutputCommand { Delay = 100, Source = new ObjectUrl(UrlType.File, Utils.GetSourcePath("input1")), OutputUrl = "/db/url1" }); builder1.Run(Builder.Mode.Build); var builder2 = Utils.CreateBuilder(true); CommandBuildStep step = builder2.Root.Add(new InputOutputCommand { Delay = 100, Source = new ObjectUrl(UrlType.File, Utils.GetSourcePath("input1")), OutputUrl = "/db/url1" }); builder2.Run(Builder.Mode.Build); builder2.WriteIndexFile(false); Assert.That(step.Status, Is.EqualTo(ResultStatus.NotTriggeredWasSuccessful)); Assert.IsTrue(step.Result.OutputObjects.Keys.Contains(new ObjectUrl(UrlType.ContentLink, "/db/url1"))); var indexMap = AssetIndexMap.Load(VirtualFileSystem.ApplicationDatabaseIndexPath); indexMap.UseTransaction = true; indexMap.LoadNewValues(); ObjectId outputId; bool objectIdFound = indexMap.TryGetValue("/db/url1", out outputId); Assert.IsTrue(objectIdFound); Assert.That(step.Result.OutputObjects[new ObjectUrl(UrlType.ContentLink, "/db/url1")], Is.EqualTo(outputId)); }
public void TestConcurrencyReadWriteAccess() { Utils.CleanContext(); Utils.GenerateSourceFile("input1", "{99D73F8B-587A-4869-97AE-4A7185D88AC9}"); var inputDep = new ObjectUrl(UrlType.File, Utils.GetSourcePath("input1")); var builder = Utils.CreateBuilder(false); CommandBuildStep step = builder.Root.Add(new InputOutputTestCommand { Delay = 100, Source = new ObjectUrl(UrlType.File, Utils.GetSourcePath("input1")), OutputUrl = "/db/url1", InputDependencies = { inputDep } }); CommandBuildStep concurrencyStep1 = builder.Root.Add(new InputOutputTestCommand { Delay = 100, Source = new ObjectUrl(UrlType.Content, "/db/url1"), OutputUrl = "/db/url1", InputDependencies = { inputDep } }); CommandBuildStep concurrencyStep2 = builder.Root.Add(new InputOutputTestCommand { Delay = 150, Source = new ObjectUrl(UrlType.Content, "/db/url1"), OutputUrl = "/db/url2", InputDependencies = { inputDep } }); BuildStep.LinkBuildSteps(step, concurrencyStep1); BuildStep.LinkBuildSteps(step, concurrencyStep2); builder.Run(Builder.Mode.Build); var logger = (LoggerResult)builder.Logger; Assert.That(logger.Messages.Any(x => x.Text.Contains("Command InputOutputTestCommand /db/url1 > /db/url1 is writing /db/url1 while command InputOutputTestCommand /db/url1 > /db/url2 is reading it"))); }
public void TestSpawnCommandOutput() { Utils.CleanContext(); Utils.GenerateSourceFile("input1", "{05D6BCFA-B1FE-4AD1-920F-0352A6DEC02D}"); Utils.GenerateSourceFile("input2", "{B9D01D6C-4048-4814-A2DF-9D317A492B10}"); var builder = Utils.CreateBuilder(true); var command = new InputOutputTestCommand { Delay = 100, Source = new ObjectUrl(UrlType.File, Utils.GetSourcePath("input1")), OutputUrl = "/db/url1" }; command.CommandsToSpawn.Add(new InputOutputTestCommand { Delay = 100, Source = new ObjectUrl(UrlType.File, Utils.GetSourcePath("input2")), OutputUrl = "/db/url2" }); CommandBuildStep step = builder.Root.Add(command); builder.Run(Builder.Mode.Build); builder.WriteIndexFile(false); var indexMap = ContentIndexMap.Load(VirtualFileSystem.ApplicationDatabaseIndexPath); indexMap.UseTransaction = true; indexMap.LoadNewValues(); ObjectId outputId; bool objectIdFound = indexMap.TryGetValue("/db/url2", out outputId); Assert.IsTrue(objectIdFound); }
public void TestSameCommandParallelExecution() { Utils.CleanContext(); var builder = Utils.CreateBuilder(false); var commands = new List<Command>(); for (int i = 0; i < 100; ++i) { TestCommand.ResetCounter(); commands.Add(new DummyBlockingCommand { Delay = 100 }); } IEnumerable<BuildStep> steps = builder.Root.Add(commands); builder.Run(Builder.Mode.Build); int successful = 0; int notTriggeredWasSuccessful = 0; foreach (BuildStep step in steps) { if (step.Status == ResultStatus.Successful) ++successful; if (step.Status == ResultStatus.NotTriggeredWasSuccessful) ++notTriggeredWasSuccessful; } Assert.That(successful, Is.EqualTo(1)); Assert.That(notTriggeredWasSuccessful, Is.EqualTo(commands.Count - 1)); }
public void TestCancelCallback() { Logger logger = Utils.CleanContext(); var builder = Utils.CreateBuilder(false); var commands = new List <Command>(); for (var i = 0; i < 10; ++i) { commands.Add(new BlockedCommand()); } IEnumerable <BuildStep> steps = builder.Root.Add(commands); var cancelThread = new Thread(() => { Thread.Sleep(1000); logger.Warning("Cancelling build!"); builder.CancelBuild(); }); cancelThread.Start(); builder.Run(Builder.Mode.Build); foreach (BuildStep step in steps) { Assert.That(step.Status, Is.EqualTo(ResultStatus.Cancelled)); } }
public void TestTwoCommandsSameOutput() { Utils.CleanContext(); Utils.GenerateSourceFile("input1", "{3F3C2132-911E-465C-B98F-020278ED4512}"); var builder = Utils.CreateBuilder(); CommandBuildStep step = builder.Root.Add(new InputOutputCommand { Delay = 100, Source = new ObjectUrl(UrlType.File, Utils.GetSourcePath("input1")), OutputUrl = "/db/url1" }); CommandBuildStep childStep = builder.Root.Add(new InputOutputCommand { Delay = 100, Source = new ObjectUrl(UrlType.File, Utils.GetSourcePath("input1")), OutputUrl = "/db/url1" }); BuildStep.LinkBuildSteps(step, childStep); builder.Run(Builder.Mode.Build); builder.WriteIndexFile(false); Assert.IsTrue(step.Result.OutputObjects.Keys.Contains(new ObjectUrl(UrlType.Internal, "/db/url1"))); Assert.IsTrue(childStep.Result.OutputObjects.Keys.Contains(new ObjectUrl(UrlType.Internal, "/db/url1"))); var indexMap = AssetIndexMap.Load(); indexMap.UseTransaction = true; indexMap.LoadNewValues(); ObjectId outputId; bool objectIdFound = indexMap.TryGetValue("/db/url1", out outputId); Assert.IsTrue(objectIdFound); Assert.That(childStep.Result.OutputObjects[new ObjectUrl(UrlType.Internal, "/db/url1")], Is.EqualTo(outputId)); }
public void TestMultipleDependencies() { Utils.CleanContext(); var builder = Utils.CreateBuilder(false); var firstStep = builder.Root.Add(new DummyBlockingCommand { Delay = 100 }); var parentStep = builder.Root.Add(new DummyBlockingCommand { Delay = 100 }); var step1 = builder.Root.Add(new DummyBlockingCommand { Delay = 100 }); var step2 = builder.Root.Add(new DummyBlockingCommand { Delay = 200 }); var finalStep = builder.Root.Add(new DummyBlockingCommand { Delay = 100 }); BuildStep.LinkBuildSteps(firstStep, parentStep); BuildStep.LinkBuildSteps(parentStep, step1); BuildStep.LinkBuildSteps(parentStep, step2); BuildStep.LinkBuildSteps(step1, finalStep); BuildStep.LinkBuildSteps(step2, finalStep); builder.Run(Builder.Mode.Build); Assert.That(firstStep.Status, Is.EqualTo(ResultStatus.Successful)); Assert.That(parentStep.Status, Is.EqualTo(ResultStatus.Successful)); Assert.That(step1.Status, Is.EqualTo(ResultStatus.Successful)); Assert.That(step2.Status, Is.EqualTo(ResultStatus.Successful)); Assert.That(finalStep.Status, Is.EqualTo(ResultStatus.Successful)); }
public void TestRemoteSpawnCommandOutput() { Utils.CleanContext(); Utils.GenerateSourceFile("input1", "{BB42A922-ED1B-4837-98D2-189EFAF6BF42}"); Utils.GenerateSourceFile("input2", "{8B212FA9-5F0D-4D29-A68B-01D87FF04AF4}"); var builder = Utils.CreateBuilder(); var command = new InputOutputCommand { Delay = 100, Source = new ObjectUrl(UrlType.File, Utils.GetSourcePath("input1")), OutputUrl = "/db/url1", ExecuteRemotely = true }; command.CommandsToSpawn.Add(new InputOutputCommand { Delay = 100, Source = new ObjectUrl(UrlType.File, Utils.GetSourcePath("input2")), OutputUrl = "/db/url2" }); CommandBuildStep step = builder.Root.Add(command); builder.Run(Builder.Mode.Build); builder.WriteIndexFile(false); Assert.That(step.SpawnedSteps.Count(), Is.EqualTo(1)); var indexMap = AssetIndexMap.Load(); indexMap.UseTransaction = true; indexMap.LoadNewValues(); ObjectId outputId; bool objectIdFound = indexMap.TryGetValue("/db/url2", out outputId); Assert.IsTrue(objectIdFound); Assert.That(step.SpawnedSteps.First().Result.OutputObjects[new ObjectUrl(UrlType.Internal, "/db/url2")], Is.EqualTo(outputId)); }
public void TestInputDependencies() { Utils.CleanContext(); Utils.GenerateSourceFile("input1", "{A7246DF6-3A68-40E2-BA58-6C9A0EFF552B}"); Utils.GenerateSourceFile("inputDeps", "{8EE7A4BC-88E1-4CC8-B03F-1E6EA8B23955}"); var builder = Utils.CreateBuilder(); var inputDep = new ObjectUrl(UrlType.File, Utils.GetSourcePath("inputDeps")); var command = new InputOutputCommand { Delay = 100, Source = new ObjectUrl(UrlType.File, Utils.GetSourcePath("input1")), OutputUrl = "/db/url1" }; command.InputDependencies.Add(inputDep); CommandBuildStep step = builder.Root.Add(command); builder.Run(Builder.Mode.Build); var indexMap = AssetIndexMap.Load(); indexMap.UseTransaction = true; indexMap.LoadNewValues(); ObjectId inputDepId; bool inputDepFound = step.Result.InputDependencyVersions.TryGetValue(inputDep, out inputDepId); Assert.IsTrue(inputDepFound); }
public void TestInputFromPreviousOutput() { Utils.CleanContext(); Utils.GenerateSourceFile("input1", "{E7635471-8551-4C80-9E37-A1EBAFC3869E}"); var builder = Utils.CreateBuilder(); CommandBuildStep step = builder.Root.Add(new InputOutputCommand { Delay = 100, Source = new ObjectUrl(UrlType.File, Utils.GetSourcePath("input1")), OutputUrl = "/db/url1" }); builder.Root.Add(new WaitBuildStep()); CommandBuildStep childStep = builder.Root.Add(new InputOutputCommand { Delay = 100, Source = new ObjectUrl(UrlType.Internal, "/db/url1"), OutputUrl = "/db/url2" }); BuildStep.LinkBuildSteps(step, childStep); builder.Run(Builder.Mode.Build); builder.WriteIndexFile(false); Assert.IsTrue(step.Result.OutputObjects.Keys.Contains(new ObjectUrl(UrlType.Internal, "/db/url1"))); Assert.IsTrue(childStep.Result.OutputObjects.Keys.Contains(new ObjectUrl(UrlType.Internal, "/db/url2"))); var indexMap = AssetIndexMap.Load(); indexMap.UseTransaction = true; indexMap.LoadNewValues(); ObjectId outputId; bool objectIdFound = indexMap.TryGetValue("/db/url2", out outputId); Assert.IsTrue(objectIdFound); Assert.That(childStep.Result.OutputObjects[new ObjectUrl(UrlType.Internal, "/db/url2")], Is.EqualTo(outputId)); }
public void TestRetrievingResultFromCache() { Utils.CleanContext(); ExecuteSimpleBuilder(ResultStatus.Successful); TestCommand.ResetCounter(); ExecuteSimpleBuilder(ResultStatus.NotTriggeredWasSuccessful); }
public void TestSpawnCommandOutput() { Utils.CleanContext(); Utils.GenerateSourceFile("input1", "{05D6BCFA-B1FE-4AD1-920F-0352A6DEC02D}"); Utils.GenerateSourceFile("input2", "{B9D01D6C-4048-4814-A2DF-9D317A492B10}"); var builder = Utils.CreateBuilder(); var command = new InputOutputCommand { Delay = 100, Source = new ObjectUrl(UrlType.File, Utils.GetSourcePath("input1")), OutputUrl = "/db/url1" }; command.CommandsToSpawn.Add(new InputOutputCommand { Delay = 100, Source = new ObjectUrl(UrlType.File, Utils.GetSourcePath("input2")), OutputUrl = "/db/url2" }); CommandBuildStep step = builder.Root.Add(command); builder.Run(Builder.Mode.Build); builder.WriteIndexFile(false); Assert.That(step.SpawnedSteps.Count(), Is.EqualTo(1)); var indexMap = AssetIndexMap.Load(); indexMap.UseTransaction = true; indexMap.LoadNewValues(); ObjectId outputId; bool objectIdFound = indexMap.TryGetValue("/db/url2", out outputId); Assert.IsTrue(objectIdFound); Assert.That(step.SpawnedSteps.First().Result.OutputObjects[new ObjectUrl(UrlType.Internal, "/db/url2")], Is.EqualTo(outputId)); }
public void TestSpawnAndAwaitCommandResults() { Utils.CleanContext(); ExecuteSpawnAndAwaitCommands(ResultStatus.Successful); TestCommand.ResetCounter(); ExecuteSpawnAndAwaitCommands(ResultStatus.NotTriggeredWasSuccessful); }
public void TestConcurrencyWriteAccess() { Utils.CleanContext(); Utils.GenerateSourceFile("input1", "{99D73F8B-587A-4869-97AE-4A7185D88AC9}"); Utils.GenerateSourceFile("input2", "{9FEABA51-4CE6-4DB0-9866-45A7492FD1B7}"); var inputDep = new ObjectUrl(UrlType.File, Utils.GetSourcePath("input1")); var builder = Utils.CreateBuilder(); CommandBuildStep step1 = builder.Root.Add(new InputOutputCommand { Delay = 100, Source = new ObjectUrl(UrlType.File, Utils.GetSourcePath("input1")), OutputUrl = "/db/url1", InputDependencies = { inputDep } }); CommandBuildStep step2 = builder.Root.Add(new InputOutputCommand { Delay = 100, Source = new ObjectUrl(UrlType.File, Utils.GetSourcePath("input2")), OutputUrl = "/db/url2", InputDependencies = { inputDep } }); builder.Root.Add(new WaitBuildStep()); CommandBuildStep concurrencyStep1 = builder.Root.Add(new InputOutputCommand { Delay = 100, Source = new ObjectUrl(UrlType.Internal, "/db/url1"), OutputUrl = "/db/url", InputDependencies = { inputDep } }); CommandBuildStep concurrencyStep2 = builder.Root.Add(new InputOutputCommand { Delay = 150, Source = new ObjectUrl(UrlType.Internal, "/db/url2"), OutputUrl = "/db/url", InputDependencies = { inputDep } }); BuildStep.LinkBuildSteps(step1, concurrencyStep1); BuildStep.LinkBuildSteps(step2, concurrencyStep2); Utils.StartCapturingLog(); builder.Run(Builder.Mode.Build); string log = Utils.StopCapturingLog(); Assert.That(log.Contains("Commands InputOutputCommand /db/url2 > /db/url and InputOutputCommand /db/url1 > /db/url are both writing /db/url at the same time")); }
public void TestConcurrencyReadWriteAccess() { Utils.CleanContext(); Utils.GenerateSourceFile("input1", "{99D73F8B-587A-4869-97AE-4A7185D88AC9}"); var inputDep = new ObjectUrl(UrlType.File, Utils.GetSourcePath("input1")); var builder = Utils.CreateBuilder(); CommandBuildStep step = builder.Root.Add(new InputOutputCommand { Delay = 100, Source = new ObjectUrl(UrlType.File, Utils.GetSourcePath("input1")), OutputUrl = "/db/url1", InputDependencies = { inputDep } }); builder.Root.Add(new WaitBuildStep()); CommandBuildStep concurrencyStep1 = builder.Root.Add(new InputOutputCommand { Delay = 100, Source = new ObjectUrl(UrlType.Internal, "/db/url1"), OutputUrl = "/db/url1", InputDependencies = { inputDep } }); CommandBuildStep concurrencyStep2 = builder.Root.Add(new InputOutputCommand { Delay = 150, Source = new ObjectUrl(UrlType.Internal, "/db/url1"), OutputUrl = "/db/url2", InputDependencies = { inputDep } }); BuildStep.LinkBuildSteps(step, concurrencyStep1); BuildStep.LinkBuildSteps(step, concurrencyStep2); Utils.StartCapturingLog(); builder.Run(Builder.Mode.Build); string log = Utils.StopCapturingLog(); Assert.That(log.Contains("Command InputOutputCommand /db/url1 > /db/url1 is writing /db/url1 while command InputOutputCommand /db/url1 > /db/url2 is reading it")); }
public void TestExceptionDependencies() { Logger logger = Utils.CleanContext(); CommandDependenciesCommon(logger, new ExceptionCommand(), new DummyBlockingCommand { Delay = 100 }, ResultStatus.Failed, ResultStatus.NotTriggeredPrerequisiteFailed); }
public void TestCancelPrerequisites() { Logger logger = Utils.CleanContext(); var builder = Utils.CreateBuilder(false); var steps1 = new List <BuildStep>(); var steps2 = new List <BuildStep>(); var steps3 = new List <BuildStep>(); for (var i = 0; i < 4; ++i) { BuildStep parentStep = builder.Root.Add(new DummyBlockingCommand { Delay = 10 }); steps1.Add(parentStep); for (var j = 0; j < 4; ++j) { BuildStep step = builder.Root.Add(new DummyBlockingCommand { Delay = 1000000 }); BuildStep.LinkBuildSteps(parentStep, step); steps2.Add(step); for (var k = 0; k < 4; ++k) { BuildStep childStep = builder.Root.Add(new DummyBlockingCommand { Delay = 1000000 }); BuildStep.LinkBuildSteps(step, childStep); steps3.Add(childStep); } } } var cancelThread = new Thread(() => { Thread.Sleep(1000); logger.Warning("Cancelling build!"); builder.CancelBuild(); }); cancelThread.Start(); builder.Run(Builder.Mode.Build); foreach (BuildStep step in steps1) { Assert.That(step.Status, Is.EqualTo(ResultStatus.Successful)); } foreach (BuildStep step in steps2) { Assert.That(step.Status, Is.EqualTo(ResultStatus.Cancelled)); } foreach (BuildStep step in steps3) { Assert.That(step.Status, Is.EqualTo(ResultStatus.NotTriggeredPrerequisiteFailed)); } }
public void TestCancelledDependencies() { Logger logger = Utils.CleanContext(); CommandDependenciesCommon(logger, new DummyBlockingCommand { Delay = 1000000 }, new DummyBlockingCommand { Delay = 100 }, ResultStatus.Cancelled, ResultStatus.NotTriggeredPrerequisiteFailed, true); }
public void TestCommandDependencies() { Logger logger = Utils.CleanContext(); CommandDependenciesCommon(logger, new DummyBlockingCommand { Delay = 100 }, new DummyBlockingCommand { Delay = 100 }, ResultStatus.Successful, ResultStatus.Successful); }
public void TestInputFromPreviousOutputWithCache() { Utils.CleanContext(); Utils.GenerateSourceFile("input1", "{E60A3248-B4D8-43F6-9A73-975FD9A653FC}"); var builder1 = Utils.CreateBuilder(); CommandBuildStep step = builder1.Root.Add(new InputOutputCommand { Delay = 100, Source = new ObjectUrl(UrlType.File, Utils.GetSourcePath("input1")), OutputUrl = "/db/url1" }); builder1.Root.Add(new WaitBuildStep()); CommandBuildStep childStep = builder1.Root.Add(new InputOutputCommand { Delay = 100, Source = new ObjectUrl(UrlType.Internal, "/db/url1"), OutputUrl = "/db/url2" }); BuildStep.LinkBuildSteps(step, childStep); builder1.Run(Builder.Mode.Build); VirtualFileSystem.FileDelete("/data/db/index"); var builder2 = Utils.CreateBuilder(); step = builder2.Root.Add(new InputOutputCommand { Delay = 100, Source = new ObjectUrl(UrlType.File, Utils.GetSourcePath("input1")), OutputUrl = "/db/url1" }); builder2.Root.Add(new WaitBuildStep()); childStep = builder2.Root.Add(new InputOutputCommand { Delay = 100, Source = new ObjectUrl(UrlType.Internal, "/db/url1"), OutputUrl = "/db/url2" }); BuildStep.LinkBuildSteps(step, childStep); builder2.Run(Builder.Mode.Build); builder2.WriteIndexFile(false); Assert.That(step.Status, Is.EqualTo(ResultStatus.NotTriggeredWasSuccessful)); Assert.That(childStep.Status, Is.EqualTo(ResultStatus.NotTriggeredWasSuccessful)); Assert.IsTrue(step.Result.OutputObjects.Keys.Contains(new ObjectUrl(UrlType.Internal, "/db/url1"))); Assert.IsTrue(childStep.Result.OutputObjects.Keys.Contains(new ObjectUrl(UrlType.Internal, "/db/url2"))); var indexMap = AssetIndexMap.Load(); indexMap.UseTransaction = true; indexMap.LoadNewValues(); ObjectId outputId; bool objectIdFound = indexMap.TryGetValue("/db/url2", out outputId); Assert.IsTrue(objectIdFound); Assert.That(childStep.Result.OutputObjects[new ObjectUrl(UrlType.Internal, "/db/url2")], Is.EqualTo(outputId)); }
public void TestBlockingCommands() { Utils.CleanContext(); var builder = Utils.CreateBuilder(false); var commands = new List<Command>(); for (int i = 0; i < 100; ++i) commands.Add(new DummyBlockingCommand { Delay = 100 }); IEnumerable<BuildStep> steps = builder.Root.Add(commands); builder.Run(Builder.Mode.Build); foreach (BuildStep step in steps) Assert.That(step.Status, Is.EqualTo(ResultStatus.Successful)); }
public void TestBuilder() { Utils.CleanContext(); if (File.Exists(QueryMetadataProvider.DefaultDatabaseFilename)) { File.Delete(QueryMetadataProvider.DefaultDatabaseFilename); } using (var provider = new QueryMetadataProvider()) { const string TestStringKeyName = "TestString"; const string TestFloatKeyName = "TestFloat"; var testStringKey = new MetadataKey(TestStringKeyName, MetadataKey.DatabaseType.String); var testFloatKey = new MetadataKey(TestFloatKeyName, MetadataKey.DatabaseType.Float); // Create database bool result = provider.Create(QueryMetadataProvider.DefaultDatabaseFilename); Assert.True(result); // Add a key and retrieve it provider.AddKey(testStringKey); provider.AddKey(testFloatKey); provider.Write(new ObjectMetadata("/assets/${PathVariable}/url1", testStringKey, "Test1")); provider.Write(new ObjectMetadata("/assets/${PathVariable}/url2", testStringKey, "Test2")); provider.Write(new ObjectMetadata("/assets/${PathVariable}/url3", testFloatKey, 42.69f)); } var builder = Utils.CreateBuilder(); var commands = new List <Command>(); builder.MetadataDatabaseDirectory = "./"; builder.InitialVariables.Add("PathVariable".ToUpperInvariant(), "path/via/variable"); commands.Add(new EchoCommand("/assets/${PathVariable}/url1", "Metadata TestString: (${Metadata:TestString})")); commands.Add(new EchoCommand("/assets/${PathVariable}/url2", "Metadata TestString: (${Metadata:TestString})")); commands.Add(new EchoCommand("/assets/${PathVariable}/url3", "Metadata TestFloat: (${Metadata:TestFloat})")); commands.Add(new EchoCommand("/assets/${PathVariable}/url4", "Non existing metadata: (${Metadata:NonExisting})")); builder.Root.Add(commands); builder.Run(Builder.Mode.Build); Assert.That(((EchoCommand)commands[0]).Echo, Is.EqualTo("Metadata TestString: (Test1)")); Assert.That(((EchoCommand)commands[1]).Echo, Is.EqualTo("Metadata TestString: (Test2)")); Assert.That(((EchoCommand)commands[2]).Echo, Is.EqualTo("Metadata TestFloat: (" + 42.69f + ")")); Assert.That(((EchoCommand)commands[3]).Echo, Is.EqualTo("Non existing metadata: ()")); }
public void TestConcurrencyReadWriteAccess2() { Utils.CleanContext(); Utils.GenerateSourceFile("input1", "{99D73F8B-587A-4869-97AE-4A7185D88AC9}"); var inputDep = new ObjectUrl(UrlType.File, Utils.GetSourcePath("input1")); var buildStepList1 = new ListBuildStep { new ListBuildStep { new InputOutputCommand { Delay = 100, Source = inputDep, OutputUrl = "/db/url1", InputDependencies = { inputDep } } }, new WaitBuildStep(), new InputOutputCommand { Delay = 1500, Source = new ObjectUrl(UrlType.Internal, "/db/url1"), OutputUrl = "/db/dump1", InputDependencies = { inputDep } }, }; var buildStepList2 = new ListBuildStep { new ListBuildStep { new InputOutputCommand { Delay = 100, Source = inputDep, OutputUrl = "/db/url1", InputDependencies = { inputDep } } }, new WaitBuildStep(), new InputOutputCommand { Delay = 1500, Source = new ObjectUrl(UrlType.Internal, "/db/url1"), OutputUrl = "/db/dump2", InputDependencies = { inputDep } }, }; var builder = Utils.CreateBuilder(); builder.ThreadCount = 1; builder.Root.Add(buildStepList1); builder.Root.Add(buildStepList2); Utils.StartCapturingLog(); var buildResult = builder.Run(Builder.Mode.Build); Assert.That(buildResult, Is.EqualTo(BuildResultCode.Successful)); }
public void TestSingleCommandTwiceWithInputChange() { Utils.CleanContext(); Utils.GenerateSourceFile("input1", "{71938BC2-6876-406E-84E9-4F4E862651D5}"); var builder1 = Utils.CreateBuilder(); CommandBuildStep step1 = builder1.Root.Add(new InputOutputCommand { Delay = 100, Source = new ObjectUrl(UrlType.File, Utils.GetSourcePath("input1")), OutputUrl = "/db/url1" }); builder1.Run(Builder.Mode.Build); // Modifying input file Utils.GenerateSourceFile("input1", "{5794B336-55F9-400A-B99D-DA61C9F09CCE}", true); var builder2 = Utils.CreateBuilder(); CommandBuildStep step2 = builder2.Root.Add(new InputOutputCommand { Delay = 100, Source = new ObjectUrl(UrlType.File, Utils.GetSourcePath("input1")), OutputUrl = "/db/url1" }); builder2.Run(Builder.Mode.Build); builder2.WriteIndexFile(false); Assert.IsTrue(step1.Result.OutputObjects.Keys.Contains(new ObjectUrl(UrlType.Internal, "/db/url1"))); Assert.IsTrue(step2.Result.OutputObjects.Keys.Contains(new ObjectUrl(UrlType.Internal, "/db/url1"))); var indexMap = AssetIndexMap.Load(); indexMap.UseTransaction = true; indexMap.LoadNewValues(); ObjectId outputId; bool objectIdFound = indexMap.TryGetValue("/db/url1", out outputId); Assert.IsTrue(objectIdFound); Assert.That(step1.Status, Is.EqualTo(ResultStatus.Successful)); Assert.That(step2.Status, Is.EqualTo(ResultStatus.Successful)); Assert.That(step1.Result.OutputObjects[new ObjectUrl(UrlType.Internal, "/db/url1")], !Is.EqualTo(outputId)); Assert.That(step2.Result.OutputObjects[new ObjectUrl(UrlType.Internal, "/db/url1")], Is.EqualTo(outputId)); }
public void TestInputDependenciesChange() { Utils.CleanContext(); Utils.GenerateSourceFile("input1", "{A7246DF6-3A68-40E2-BA58-6C9A0EFF552B}"); Utils.GenerateSourceFile("inputDeps", "{8EE7A4BC-88E1-4CC8-B03F-1E6EA8B23955}"); var inputDep = new ObjectUrl(UrlType.File, Utils.GetSourcePath("inputDeps")); var builder1 = Utils.CreateBuilder(); CommandBuildStep step1 = builder1.Root.Add(new InputOutputCommand { Delay = 100, Source = new ObjectUrl(UrlType.File, Utils.GetSourcePath("input1")), OutputUrl = "/db/url1", InputDependencies = { inputDep } }); builder1.Run(Builder.Mode.Build); Utils.GenerateSourceFile("inputDeps", "{E505A61B-5F2A-4BB8-8F6C-3788C76BAE5F}", true); var builder2 = Utils.CreateBuilder(); CommandBuildStep step2 = builder2.Root.Add(new InputOutputCommand { Delay = 100, Source = new ObjectUrl(UrlType.File, Utils.GetSourcePath("input1")), OutputUrl = "/db/url1", InputDependencies = { inputDep } }); builder2.Run(Builder.Mode.Build); var indexMap = AssetIndexMap.Load(); indexMap.LoadNewValues(); Assert.That(step1.Status, Is.EqualTo(ResultStatus.Successful)); Assert.That(step2.Status, Is.EqualTo(ResultStatus.Successful)); ObjectId inputDepId1; ObjectId inputDepId2; Assert.IsTrue(step1.Result.InputDependencyVersions.TryGetValue(inputDep, out inputDepId1)); Assert.IsTrue(step2.Result.InputDependencyVersions.TryGetValue(inputDep, out inputDepId2)); Assert.That(inputDepId1, !Is.EqualTo(inputDepId2)); }
public void TestSpawnAndAwaitCommands() { Utils.CleanContext(); ExecuteSimpleBuilder(ResultStatus.Successful); }
public void TestRemoteSingleOutput() { Utils.CleanContext(); Utils.GenerateSourceFile("input1", "{78F451F2-CA9D-40C7-A084-396B4E87D1FF}"); CommonSingleOutput(true); }
public void TestSingleOutput() { Utils.CleanContext(); Utils.GenerateSourceFile("input1", "{1A89566A-D39D-4858-8F65-12FA64C03DED}"); CommonSingleOutput(false); }