コード例 #1
0
    private void MakeForeignCodeSample()
    {
        string Sample     = "PlatformerGame";
        string DestSample = "PlatformerGame";
        var    Src        = CombinePaths(CmdEnv.LocalRoot, Sample);

        if (!DirectoryExists(Src))
        {
            throw new AutomationException("Can't find source directory to make foreign sample {0}.", Src);
        }

        var Dest = ParseParamValue("ForeignDest", CombinePaths(@"C:\testue4\foreign\", DestSample + "_ _Dir"));

        LogInformation("Make a foreign sample {0} -> {1}", Src, Dest);

        CloneDirectory(Src, Dest);
        DeleteDirectory_NoExceptions(CombinePaths(Dest, "Intermediate"));
        DeleteDirectory_NoExceptions(CombinePaths(Dest, "Saved"));
        DeleteDirectory_NoExceptions(CombinePaths(Dest, "Plugins", "FootIK", "Intermediate"));

        //RenameFile(CombinePaths(Dest, Sample + ".uproject"), CombinePaths(Dest, DestSample + ".uproject"));

        var IniFile = CombinePaths(Dest, "Config", "DefaultEngine.ini");
        var Ini     = new VersionFileUpdater(new FileReference(IniFile));

        Ini.ReplaceLine("GameName=", DestSample);
        Ini.Commit();
    }
コード例 #2
0
        public void VersionFileUpdaterFindsFiles()
        {
            b.Info.Flow();

            MockVersionFileUpdater msut = new MockVersionFileUpdater();
            VersionFileUpdater     sut  = (VersionFileUpdater)msut;

            msut.Mock.AddFilesystemFile("XX");
        }
コード例 #3
0
        public void Regex_MatchesForFile()
        {
            VersionFileUpdater sut = new VersionFileUpdater();
            var rx = sut.GetRegex("AssemblyInformationalVersion");

            Assert.True(rx.IsMatch("[assembly: AssemblyInformationalVersion(\"0.0.0.0\")]"), "1 Invalid match for an assembly version");
            Assert.True(rx.IsMatch("[assembly: AssemblyInformationalVersion(\"0.0.0\")]"), "2 Invalid match for an assembly version");
            Assert.True(rx.IsMatch("[assembly: AssemblyInformationalVersion(\"0.0\")]"), "3 Invalid match for an assembly version");
            Assert.True(rx.IsMatch("[assembly: AssemblyInformationalVersion(\"0\")]"), "4 Invalid match for an assembly version");
            Assert.True(rx.IsMatch("[assembly: AssemblyInformationalVersion(\"\")]"), "5 Invalid match for an assembly version");
            Assert.True(rx.IsMatch("[assembly:      AssemblyInformationalVersion     (\"0.0.0.0\"   )     ]"), "7 Invalid match for an assembly version");
            Assert.True(rx.IsMatch("[assembly     :AssemblyInformationalVersion(\"0.0.0.0\")]"), "8 Invalid match for an assembly version");
        }
コード例 #4
0
        public void Update_AsmVersion_Works()
        {
            Plisky.Build.CompleteVersion cv = new Plisky.Build.CompleteVersion(new VersionUnit("1"), new VersionUnit("1", "."), new VersionUnit("1", "."), new VersionUnit("1", "."));
            string srcFile = @"D:\Files\Code\git\Scratchpad\PliskyVersioning\_Dependencies\TestData\TestFileStructure\JustAssemblyVersion.txt";
            string fn      = ts.GetFileAsTemporary(srcFile);

            VersionFileUpdater sut = new VersionFileUpdater(cv);

            sut.PerformUpdate(fn, FileUpdateType.Assembly4);

            Assert.False(ts.DoesFileContainThisText(fn, "0.0.0.0"), "No update was made to the file at all");
            Assert.True(ts.DoesFileContainThisText(fn, "1.1"), "The file does not appear to have been updated correctly.");
            Assert.True(ts.DoesFileContainThisText(fn, "AssemblyVersion(\"1.1\")"), "The file does not have the full version in it");
        }
コード例 #5
0
        public void Bug464_BuildVersionsNotUpdatedDuringBuild()
        {
            string             srcFile = @"D:\Files\Code\git\PliskyBuild\PliskyBuildTasks\_Dependencies\TestData\BugData\B464_AsmInfo_Source.txt";
            string             fn      = ts.GetFileAsTemporary(srcFile);
            var                cv      = new CompleteVersion(new VersionUnit("2"), new VersionUnit("0", "."), new VersionUnit("Unicorn", "-"), new VersionUnit("0", ".", VersionIncrementBehaviour.ContinualIncrement));
            VersionFileUpdater sut     = new VersionFileUpdater(cv);

            sut.PerformUpdate(fn, FileUpdateType.Assembly2);
            sut.PerformUpdate(fn, FileUpdateType.AssemblyInformational);
            sut.PerformUpdate(fn, FileUpdateType.AssemblyFile);

            Assert.False(ts.DoesFileContainThisText(fn, "AssemblyFileVersion(\"2.0.0\""), "The file version should be three digits and present");
            Assert.True(ts.DoesFileContainThisText(fn, "AssemblyInformationalVersion(\"2.0-Unicorn.0\""), "The informational version should be present");
            Assert.True(ts.DoesFileContainThisText(fn, "AssemblyVersion(\"2.0\")"), "the assembly version should be two digits and present.");
        }
コード例 #6
0
        public void UpdateStd_AddsStdInfoWhenMissing()
        {
            var                reid    = TestResources.GetIdentifiers(TestResourcesReferences.NetStdNone);
            string             srcFile = uth.GetTestDataFile(reid);
            CompleteVersion    cv      = new CompleteVersion(new VersionUnit("1"), new VersionUnit("1", "."), new VersionUnit("1", "."), new VersionUnit("1", "."));
            VersionFileUpdater sut     = new VersionFileUpdater(cv);
            var                before  = ts.GetVersion(FileUpdateType.StdInformational, srcFile);

            sut.PerformUpdate(srcFile, FileUpdateType.StdInformational);

            var after = ts.GetVersion(FileUpdateType.StdInformational, srcFile);

            Assert.True(string.IsNullOrEmpty(before));
            Assert.False(string.IsNullOrEmpty(after));
        }
コード例 #7
0
        public void Update_AsmFileVer_Works()
        {
            b.Info.Flow();
            var                reid    = TestResources.GetIdentifiers(TestResourcesReferences.JustFileVer);
            string             srcFile = uth.GetTestDataFile(reid);
            CompleteVersion    cv      = new CompleteVersion(new VersionUnit("1"), new VersionUnit("1", "."), new VersionUnit("1", "."), new VersionUnit("1", "."));
            string             fn      = ts.GetFileAsTemporary(srcFile);
            VersionFileUpdater sut     = new VersionFileUpdater(cv);

            sut.PerformUpdate(fn, FileUpdateType.NetFile);

            Assert.False(ts.DoesFileContainThisText(fn, "0.0.0.0"), "No update was made to the file at all");
            Assert.True(ts.DoesFileContainThisText(fn, "1.1"), "The file does not appear to have been updated correctly.");
            Assert.True(ts.DoesFileContainThisText(fn, "AssemblyFileVersion(\"1.1.1.1\")"), "The file does not have the full version in it");
        }
コード例 #8
0
        public void Update_StdCSProjInfo_Works()
        {
            var                reid    = TestResources.GetIdentifiers(TestResourcesReferences.NetStdAll3);
            string             srcFile = uth.GetTestDataFile(reid);
            CompleteVersion    cv      = new CompleteVersion(new VersionUnit("1"), new VersionUnit("1", "."), new VersionUnit("1", "."), new VersionUnit("1", "."));
            VersionFileUpdater sut     = new VersionFileUpdater(cv);
            var                before  = ts.GetVersion(FileUpdateType.StdInformational, srcFile);

            Assert.NotEmpty(before);

            sut.PerformUpdate(srcFile, FileUpdateType.StdInformational);

            var after = ts.GetVersion(FileUpdateType.StdInformational, srcFile);

            Assert.NotEqual <string>(before, after);
        }
コード例 #9
0
        public void Update_DoesNotAlterOtherAttributes()
        {
            Plisky.Build.CompleteVersion cv = new Plisky.Build.CompleteVersion(new VersionUnit("1"), new VersionUnit("1", "."), new VersionUnit("1", "."), new VersionUnit("1", "."));
            string srcFile = @"D:\Files\Code\git\Scratchpad\PliskyVersioning\_Dependencies\TestData\TestFileStructure\DoesNotChange\assemblyinfo.txt";
            string fn      = ts.GetFileAsTemporary(srcFile);

            VersionFileUpdater sut = new VersionFileUpdater(cv);

            sut.PerformUpdate(fn, FileUpdateType.Assembly4);

            Assert.False(ts.DoesFileContainThisText(fn, " AssemblyVersion(\"1.0.0.0\")"), "No update was made to the file at all");
            Assert.True(ts.DoesFileContainThisText(fn, "[assembly: AssemblyFileVersion(\"1.0.0.0\")]"), "The file does not appear to have been updated correctly.");
            Assert.True(ts.DoesFileContainThisText(fn, "[assembly: AssemblyCompany(\"\")]"), "Collatoral Damage - Another element in the file was updated - Company");
            Assert.True(ts.DoesFileContainThisText(fn, "[assembly: Guid(\"557cc26f-fcb2-4d0e-a34e-447295115fc3\")]"), "Collatoral Damage - Another element in the file was updated - Guid");
            Assert.True(ts.DoesFileContainThisText(fn, "// [assembly: AssemblyVersion(\"1.0.*\")]"), "Collatoral Damage - Another element in the file was updated - Comment");
            Assert.True(ts.DoesFileContainThisText(fn, "using System.Reflection;"), "Collatoral Damage - Another element in the file was updated - Reflection First Line");
        }
コード例 #10
0
        public void LiteralReplace_Version3_IsThreeDigits()
        {
            b.Info.Flow();

            var             reid    = TestResources.GetIdentifiers(TestResourcesReferences.VersionV3Txt);
            string          srcFile = uth.GetTestDataFile(reid);
            CompleteVersion cv      = new CompleteVersion(new VersionUnit("1"), new VersionUnit("1", "."), new VersionUnit("1", "."), new VersionUnit("1", "."));

            VersionFileUpdater sut = new VersionFileUpdater(cv);

            sut.PerformUpdate(srcFile, FileUpdateType.TextFile, DisplayType.Release);
            string result = File.ReadAllText(srcFile);

            Assert.DoesNotContain("XXX-VERSION3-XXX", result);
            Assert.DoesNotContain("1.1.1.1", result);
            Assert.Contains("1.1.1", result);
        }
コード例 #11
0
        public void Regex_MatchesForAssembly()
        {
            VersionFileUpdater sut = new VersionFileUpdater();
            //var rxstr = "\\s*\\[\\s*assembly\\s*:\\s*AssemblyVersion\\s*\\(\\s*\\\"\\s*[0-9A-z\\-.*]*\\s*\\\"\\s*\\)\\s*\\]";
            //var rx = new Regex(rxstr, RegexOptions.IgnoreCase);
            var rx = sut.GetRegex("AssemblyVersion");

            Assert.True(rx.IsMatch("[assembly: AssemblyVersion(\"0.0.0.0\")]"), "1 Invalid match for an assembly version");
            Assert.True(rx.IsMatch("[assembly: AssemblyVersion(\"0.0.0\")]"), "2 Invalid match for an assembly version");
            Assert.True(rx.IsMatch("[assembly: AssemblyVersion(\"0.0\")]"), "3 Invalid match for an assembly version");
            Assert.True(rx.IsMatch("[assembly: AssemblyVersion(\"0\")]"), "4 Invalid match for an assembly version");
            Assert.True(rx.IsMatch("[assembly: AssemblyVersion(\"\")]"), "5 Invalid match for an assembly version");
            Assert.True(rx.IsMatch("[assembly:      AssemblyVersion     (\"0.0.0.0\"   )     ]"), "7 Invalid match for an assembly version");
            Assert.True(rx.IsMatch("[assembly     :AssemblyVersion(\"0.0.0.0\")]"), "8 Invalid match for an assembly version");

            // Assert.False(rx.IsMatch("//[assembly: AssemblyVersion(\"0.0.0.0\")]"), "6 Invalid match for an assembly version");
            // Assert.False(rx.IsMatch("   //    [assembly: AssemblyVersion(\"0.0.0.0\")]"), "9 Invalid match for an assembly version");
        }
コード例 #12
0
        public void Bug464_BuildVersionsNotUpdatedDuringBuild()
        {
            var ident = TestResources.GetIdentifiers(TestResourcesReferences.Bug464RefContent);

            string srcFile = uth.GetTestDataFile(ident);

            string fn = ts.GetFileAsTemporary(srcFile);
            var    cv = new CompleteVersion(new VersionUnit("2"), new VersionUnit("0", "."),
                                            new VersionUnit("Unicorn", "-"),
                                            new VersionUnit("0", ".", DigitIncremementBehaviour.ContinualIncrement));
            VersionFileUpdater sut = new VersionFileUpdater(cv);

            sut.PerformUpdate(fn, FileUpdateType.NetAssembly);
            sut.PerformUpdate(fn, FileUpdateType.NetInformational);
            sut.PerformUpdate(fn, FileUpdateType.NetFile);

            Assert.False(ts.DoesFileContainThisText(fn, "AssemblyFileVersion(\"2.0.0\""), "The file version should be three digits and present");
            Assert.True(ts.DoesFileContainThisText(fn, "AssemblyInformationalVersion(\"2.0-Unicorn.0\""), "The informational version should be present");
            Assert.True(ts.DoesFileContainThisText(fn, "AssemblyVersion(\"2.0\")"), "the assembly version should be two digits and present.");
        }
コード例 #13
0
        public void Update_DoesNotAlterOtherAttributes()
        {
            b.Info.Flow();

            var    reid    = TestResources.GetIdentifiers(TestResourcesReferences.NoChangeAssemInfo);
            string srcFile = uth.GetTestDataFile(reid);

            CompleteVersion cv = new CompleteVersion(new VersionUnit("1"), new VersionUnit("1", "."), new VersionUnit("1", "."), new VersionUnit("1", "."));
            string          fn = ts.GetFileAsTemporary(srcFile);

            VersionFileUpdater sut = new VersionFileUpdater(cv);

            sut.PerformUpdate(fn, FileUpdateType.NetAssembly);

            Assert.False(ts.DoesFileContainThisText(fn, " AssemblyVersion(\"1.0.0.0\")"), "No update was made to the file at all");
            Assert.True(ts.DoesFileContainThisText(fn, "[assembly: AssemblyFileVersion(\"1.0.0.0\")]"), "The file does not appear to have been updated correctly.");
            Assert.True(ts.DoesFileContainThisText(fn, "[assembly: AssemblyCompany(\"\")]"), "Collatoral Damage - Another element in the file was updated - Company");
            Assert.True(ts.DoesFileContainThisText(fn, "[assembly: Guid(\"557cc26f-fcb2-4d0e-a34e-447295115fc3\")]"), "Collatoral Damage - Another element in the file was updated - Guid");
            Assert.True(ts.DoesFileContainThisText(fn, "// [assembly: AssemblyVersion(\"1.0.*\")]"), "Collatoral Damage - Another element in the file was updated - Comment");
            Assert.True(ts.DoesFileContainThisText(fn, "using System.Reflection;"), "Collatoral Damage - Another element in the file was updated - Reflection First Line");
        }
コード例 #14
0
        public void LiteralReplace_DefaultReplacesVersionAndReleaseName()
        {
            b.Info.Flow();

            var             reid    = TestResources.GetIdentifiers(TestResourcesReferences.ReleaseNameAndVerTxt);
            string          srcFile = uth.GetTestDataFile(reid);
            CompleteVersion cv      = new CompleteVersion(new VersionUnit("1"), new VersionUnit("1", "."), new VersionUnit("1", "."), new VersionUnit("1", "."));

            cv.ReleaseName = "Unicorn";

            VersionFileUpdater sut = new VersionFileUpdater(cv);

            sut.PerformUpdate(srcFile, FileUpdateType.TextFile, DisplayType.Release);


            string result = File.ReadAllText(srcFile);

            Assert.DoesNotContain("XXX-RELEASENAME-XXX", result);
            Assert.Contains("Unicorn", result);
            Assert.DoesNotContain("XXX-VERSION-XXX", result);
            Assert.Contains("1.1.1.1", result);
        }
コード例 #15
0
        public void Update_Nuspec_BugNoUpdate()
        {
            b.Info.Flow();
            // BUG Case - for some reason nuspec was not being updated.  B_NuspecUpdateFailed

            var    reid    = TestResources.GetIdentifiers(TestResourcesReferences.BugNuspecUpdateFail);
            string srcFile = uth.GetTestDataFile(reid);

            CompleteVersion    cv  = new CompleteVersion(new VersionUnit("1"), new VersionUnit("1", "."), new VersionUnit("1", "."), new VersionUnit("1", "."));
            VersionFileUpdater sut = new VersionFileUpdater(cv);

            string knownStartPoint  = "<version>1.7.2.0</version>";
            string destinationPoint = "<version>1.1.1.1</version>";
            string txt = File.ReadAllText(srcFile);

            sut.PerformUpdate(srcFile, FileUpdateType.Nuspec, DisplayType.Release);
            string txt2 = File.ReadAllText(srcFile);

            Assert.True(txt.IndexOf(knownStartPoint) > 0);
            Assert.False(txt.IndexOf(destinationPoint) > 0);
            Assert.False(txt2.IndexOf(knownStartPoint) > 0);
            Assert.True(txt2.IndexOf(destinationPoint) > 0);
        }