示例#1
0
        public void CommandRunsSuccessfully()
        {
            this.SetupTest("PackageUnifiedNuGetLocalInstallNoDedup");

            if (File.Exists(this.GetPath(Path.Combine("Build", "Module.xml"))))
            {
                File.Delete(this.GetPath(Path.Combine("Build", "Module.xml")));
            }

            using (var reader = new StreamReader(this.GetPath(Path.Combine("Build", "Module.Template.xml"))))
            {
                var content = reader.ReadToEnd();
                content = content.Replace("{PATH_TO_NUGET_PKG}", SecurityElement.Escape(this.GetPath("Protoinject.nupkg")));
                using (var writer = new StreamWriter(this.GetPath(Path.Combine("Build", "Module.xml"))))
                {
                    writer.Write(content);
                }
            }

            if (Directory.Exists(this.GetPath("TestInstall")))
            {
                PathUtils.AggressiveDirectoryDelete(this.GetPath("TestInstall"));
            }

            this.OtherMode("resolve", "Windows");

            _assert.True(Directory.Exists(this.GetPath("TestInstall")));
            _assert.True(Directory.Exists(this.GetPath(Path.Combine("TestInstall", "Windows"))));
            _assert.False(Directory.Exists(this.GetPath(Path.Combine("TestInstall", "Windows", "_rels"))));
            _assert.True(Directory.Exists(this.GetPath(Path.Combine("TestInstall", "Windows", "Build"))));
        }
        public void GenerationIsCorrect()
        {
            this.SetupTest("SafeResolveDefaultsWithFeatureSet");

            if (Directory.Exists(this.GetPath("Package")))
            {
                PathUtils.AggressiveDirectoryDelete(this.GetPath("Package"));
            }

            var src = this.SetupSrcPackage();

            try
            {
                Directory.CreateDirectory(GetPath("Package"));
                File.Copy(GetPath("PackageTemp\\Test.txt"), GetPath("Package\\Test.txt"));

                this.Generate(args: "--redirect http://protobuild.org/hach-que/TestEmptyPackage local-git://" + src);

                _assert.False(File.Exists(GetPath("Package\\Test.txt")));
                _assert.True(Directory.Exists(GetPath("Package\\.git")));
            }
            finally
            {
                PathUtils.AggressiveDirectoryDelete(src);

                if (Directory.Exists(this.GetPath("Package")))
                {
                    PathUtils.AggressiveDirectoryDelete(this.GetPath("Package"));
                }
            }
        }
        public void GeneratedTemplateIsCorrect()
        {
            this.SetupTest("PackageTemplateAppliesCorrectly", true);

            // Make sure the Generated directory is removed so we have a clean test every time.
            if (Directory.Exists(this.GetPath("Generated")))
            {
                PathUtils.AggressiveDirectoryDelete(this.GetPath("Generated"));
            }

            Directory.CreateDirectory(GetPath("Generated"));

            var templateFolder = this.SetupSrcTemplate();

            try
            {
                this.OtherMode(
                    "start", "local-template-git://" + templateFolder, workingSubdirectory: "Generated");

                _assert.True(Directory.Exists(GetPath(Path.Combine("Generated", "Generated"))));
                _assert.True(Directory.Exists(GetPath(Path.Combine("Generated", "Generated.Content"))));
                _assert.True(File.Exists(GetPath(Path.Combine("Generated", "Generated", "GeneratedActivity.cs"))));
                _assert.True(File.Exists(GetPath(Path.Combine("Generated", "Generated", "GeneratedGame.cs"))));
                _assert.True(File.Exists(GetPath(Path.Combine("Generated", "Generated", "GeneratedWorld.cs"))));

                var worldFile = ReadFile(Path.Combine("Generated", "Generated", "GeneratedWorld.cs"));

                _assert.Contains("public class GeneratedWorld", worldFile);
                _assert.Contains("Hello Generated!", worldFile);
            }
            finally
            {
                PathUtils.AggressiveDirectoryDelete(templateFolder);
            }
        }
        public void GenerationIsCorrect()
        {
            this.SetupTest("PackageLocationParentAndSubmoduleSamePackage");

            var src = this.SetupSrcPackage();

            // Make sure the Package directory is removed so we have a clean test every time.
            if (Directory.Exists(this.GetPath("Package")))
            {
                PathUtils.AggressiveDirectoryDelete(this.GetPath("Package"));
            }

            this.Generate(args: "--redirect http://protobuild.org/hach-que/TestEmptyPackage local-git://" + src);

            Assert.True(File.Exists(this.GetPath("Package\\PackageLibrary\\PackageLibrary.Windows.csproj")));
            Assert.True(File.Exists(this.GetPath("Submodule\\Package\\.redirect")));
            Assert.True(File.Exists(this.GetPath("Submodule\\Library\\Library.Windows.csproj")));
            Assert.True(File.Exists(this.GetPath("Console\\Console.Windows.csproj")));

            var consoleContents = this.ReadFile("Console\\Console.Windows.csproj");
            var libraryContents = this.ReadFile("Submodule\\Library\\Library.Windows.csproj");

            Assert.Contains(
                @"Include=""..\Package\PackageLibrary\PackageLibrary.Windows.csproj""",
                consoleContents);
            Assert.Contains(
                @"Include=""..\..\Package\PackageLibrary\PackageLibrary.Windows.csproj""",
                libraryContents);
        }
示例#5
0
        public void GenerationIsCorrect()
        {
            this.SetupTest("PackageRedirectionToLocalPointer");

            var src = this.SetupSrcPackage();

            try
            {
                // Make sure the Package directory is removed so we have a clean test every time.
                if (Directory.Exists(this.GetPath("Package")))
                {
                    PathUtils.AggressiveDirectoryDelete(this.GetPath("Package"));
                }

                this.Generate(args: "--redirect http://protobuild.org/hach-que/TestEmptyPackage local-pointer://" + src);

                // Pointers should create a .redirect file which Protobuild uses to then link
                // across the folder hierarchy.
                _assert.True(File.Exists(this.GetPath("Package\\.redirect")));
            }
            finally
            {
                PathUtils.AggressiveDirectoryDelete(src);
            }
        }
示例#6
0
        public void GenerationIsCorrect()
        {
            this.SetupTest("PackageResolutionDoesNotOccurWhenPackageManagementDisabled");

            // Make sure the Package directory is removed so we have a clean test every time.
            if (Directory.Exists(this.GetPath("Package")))
            {
                PathUtils.AggressiveDirectoryDelete(this.GetPath("Package"));
            }

            var output = this.Generate(capture: true);

            _assert.DoesNotContain("Starting resolution of packages for", output.Item1);
        }
        public void GenerationIsCorrect()
        {
            this.SetupTest("PackageRedirectionToLocalPath");

            var src = this.SetupSrcPackage();

            // Make sure the Package directory is removed so we have a clean test every time.
            if (Directory.Exists(this.GetPath("Package")))
            {
                PathUtils.AggressiveDirectoryDelete(this.GetPath("Package"));
            }

            this.Generate(args: "--redirect http://protobuild.org/hach-que/TestEmptyPackage local-git://" + src);

            Assert.True(File.Exists(this.GetPath("Package\\PackageLibrary\\PackageLibrary.Windows.csproj")));
        }
示例#8
0
        public void GenerationIsCorrect()
        {
            this.SetupTest("PackageResolutionDoesNotOccurInSubmodulesTwice");

            var src = this.SetupSrcPackage();

            try
            {
                // Make sure the Package directory is removed so we have a clean test every time.
                if (Directory.Exists(this.GetPath("Package")))
                {
                    PathUtils.AggressiveDirectoryDelete(this.GetPath("Package"));
                }

                var platform = "Windows";
                if (Path.DirectorySeparatorChar == '/')
                {
                    platform = "Linux";

                    if (Directory.Exists("/Library"))
                    {
                        platform = "MacOS";
                    }
                }

                var stdout = this.Generate(
                    platform: platform,
                    args: "--redirect http://protobuild.org/hach-que/TestEmptyPackage local-git://" + src,
                    capture: true).Item1;

                var idxSubmoduleGeneration = stdout.IndexOf("Invoking submodule generation for Submodule",
                                                            System.StringComparison.InvariantCulture);
                _assert.NotEqual(-1, idxSubmoduleGeneration);

                var substrStdout         = stdout.Substring(idxSubmoduleGeneration);
                var idxPackageResolution =
                    substrStdout.IndexOf("Starting resolution of packages for " + platform + "...",
                                         System.StringComparison.InvariantCulture);

                // We should not see any package resolution we invoke submodule generation.
                _assert.Equal(-1, idxPackageResolution);
            }
            finally
            {
                PathUtils.AggressiveDirectoryDelete(src);
            }
        }
示例#9
0
        public void GenerationIsCorrect()
        {
            this.SetupTest("PackageLocationTwoSubmoduleSamePackage");

            var src = this.SetupSrcPackage();

            try
            {
                // Make sure the Package directory is removed so we have a clean test every time.
                if (Directory.Exists(this.GetPath("SubmoduleA\\Package")))
                {
                    PathUtils.AggressiveDirectoryDelete(this.GetPath("SubmoduleA\\Package"));
                }
                if (Directory.Exists(this.GetPath("SubmoduleB\\Package")))
                {
                    PathUtils.AggressiveDirectoryDelete(this.GetPath("SubmoduleB\\Package"));
                }

                this.Generate(args: "--redirect http://protobuild.org/hach-que/TestEmptyPackage local-git://" + src);

                _assert.False(File.Exists(this.GetPath("Package\\PackageLibrary\\PackageLibrary.Windows.csproj")), "Package\\PackageLibrary\\PackageLibrary.Windows.csproj does not exist");
                _assert.True(
                    File.Exists(this.GetPath("SubmoduleA\\Package\\PackageLibrary\\PackageLibrary.Windows.csproj")), "SubmoduleA\\Package\\PackageLibrary\\PackageLibrary.Windows.csproj exists");
                _assert.False(
                    File.Exists(this.GetPath("SubmoduleB\\Package\\PackageLibrary\\PackageLibrary.Windows.csproj")), "SubmoduleB\\Package\\PackageLibrary\\PackageLibrary.Windows.csproj exists");
                _assert.False(File.Exists(this.GetPath("SubmoduleA\\Package\\.redirect")), "SubmoduleA\\Package\\.redirect exists");
                _assert.True(File.Exists(this.GetPath("SubmoduleB\\Package\\.redirect")), "SubmoduleB\\Package\\.redirect does not exist");
                _assert.True(File.Exists(this.GetPath("SubmoduleA\\LibraryA\\LibraryA.Windows.csproj")), "SubmoduleA\\LibraryA\\LibraryA.Windows.csproj does not exist");
                _assert.True(File.Exists(this.GetPath("SubmoduleB\\LibraryB\\LibraryB.Windows.csproj")), "SubmoduleB\\LibraryB\\LibraryB.Windows.csproj does not exist");

                var libraryAContents = this.ReadFile("SubmoduleA\\LibraryA\\LibraryA.Windows.csproj");
                var libraryBContents = this.ReadFile("SubmoduleB\\LibraryB\\LibraryB.Windows.csproj");

                _assert.Contains(
                    @"Include=""..\Package\PackageLibrary\PackageLibrary.Windows.csproj""",
                    libraryAContents);
                _assert.Contains(
                    @"Include=""..\..\SubmoduleA\Package\PackageLibrary\PackageLibrary.Windows.csproj""",
                    libraryBContents);
            }
            finally
            {
                PathUtils.AggressiveDirectoryDelete(src);
            }
        }
        public void GenerationIsCorrect()
        {
            this.SetupTest("PackageResolutionDoesNotOccurInFolderWithExistingData");

            var src = this.SetupSrcPackage();

            try
            {
                this.Generate(args: "--redirect http://protobuild.org/hach-que/TestEmptyPackage local-git://" + src);

                _assert.True(File.Exists(this.GetPath("Package\\empty.txt")));
                _assert.False(File.Exists(this.GetPath("Package\\.pkg")));
                _assert.False(File.Exists(this.GetPath("Package\\.git")));
                _assert.False(Directory.Exists(this.GetPath("Package\\.git")));
            }
            finally
            {
                PathUtils.AggressiveDirectoryDelete(src);
            }
        }
        public void GeneratedTemplateIsCorrect()
        {
            this.SetupTest("PackageTemplateIgnoresTemplateOnlyFolder", true);

            // Make sure the Generated directory is removed so we have a clean test every time.
            if (Directory.Exists(this.GetPath("Generated")))
            {
                PathUtils.AggressiveDirectoryDelete(this.GetPath("Generated"));
            }

            Directory.CreateDirectory(GetPath("Generated"));

            var templateFolder = this.SetupSrcTemplate();

            this.OtherMode(
                "start", "local-template-git://" + templateFolder, workingSubdirectory: "Generated");

            _assert.False(Directory.Exists(GetPath(Path.Combine("Generated", "_TemplateOnly"))));
            _assert.False(File.Exists(GetPath(Path.Combine("Generated", "_TemplateOnly"))));
        }