Ejemplo n.º 1
0
        public void DnuRestore_UsesProjectAndCommandLineProvidedRuntimes(string flavor, string os, string architecture)
        {
            var runtimeHomeDir = TestUtils.GetRuntimeHomeDir(flavor, os, architecture);

            LockFile lockFile;

            using (var testDir = new DisposableDir())
            {
                var misc = TestUtils.GetMiscProjectsFolder();
                DirTree.CreateFromDirectory(Path.Combine(misc, "RuntimeRestore", "TestProject"))
                .WriteTo(testDir);

                // Clean up the lock file if it ended up there during the copy
                var lockFilePath = Path.Combine(testDir, "project.lock.json");
                if (File.Exists(lockFilePath))
                {
                    File.Delete(lockFilePath);
                }

                // Modify the project
                AddRuntimeToProject(testDir, "win10-x86");

                // Restore the project!
                var source = Path.Combine(misc, "RuntimeRestore", "RuntimeRestoreTestPackage", "feed");
                DnuTestUtils.ExecDnu(runtimeHomeDir, "restore", $"--source {source} --runtime ubuntu.14.04-x64 --runtime osx.10.10-x64", workingDir: testDir);

                // Check the lock file
                lockFile = (new LockFileFormat()).Read(Path.Combine(testDir, "project.lock.json"));
            }

            AssertLockFileTarget(lockFile, "win10-x86", "win8-x86");
            AssertLockFileTarget(lockFile, "osx.10.10-x64", "osx.10.10-x64");
            AssertLockFileTarget(lockFile, "ubuntu.14.04-x64", "ubuntu.14.04-x64");
        }
Ejemplo n.º 2
0
        public void DnuRestore_GeneratesDefaultRuntimeTargets(string flavor, string os, string architecture)
        {
            // TODO(anurse): Maybe this could be a condition? This is the only place we need it right now so it
            // didn't seem worth the refactor.
            if (RuntimeEnvironmentHelper.RuntimeEnvironment.OperatingSystem.Equals("Darwin"))
            {
                var ver = Version.Parse(RuntimeEnvironmentHelper.RuntimeEnvironment.OperatingSystemVersion);
                if (ver < new Version(10, 10))
                {
                    // Not supported on this!
                    return;
                }
            }

            var runtimeHomeDir = TestUtils.GetRuntimeHomeDir(flavor, os, architecture);

            LockFile lockFile;

            using (var testDir = new DisposableDir())
            {
                var misc = TestUtils.GetMiscProjectsFolder();
                DirTree.CreateFromDirectory(Path.Combine(misc, "RuntimeRestore", "TestProject"))
                .WriteTo(testDir);

                // Clean up the lock file if it ended up there during the copy
                var lockFilePath = Path.Combine(testDir, "project.lock.json");
                if (File.Exists(lockFilePath))
                {
                    File.Delete(lockFilePath);
                }

                // Restore the project!
                var source = Path.Combine(misc, "RuntimeRestore", "RuntimeRestoreTestPackage", "feed");
                DnuTestUtils.ExecDnu(runtimeHomeDir, "restore", $"--source {source}", workingDir: testDir);

                // Check the lock file
                lockFile = (new LockFileFormat()).Read(Path.Combine(testDir, "project.lock.json"));
            }

            // We can use the runtime environment to determine the expected RIDs because by default it only uses the current OSes RIDs
            if (RuntimeEnvironmentHelper.IsWindows)
            {
                AssertLockFileTarget(lockFile, "win7-x86", "win7-x86");
                AssertLockFileTarget(lockFile, "win7-x64", "win7-x64");
            }
            else
            {
                var osName = RuntimeEnvironmentHelper.RuntimeEnvironment.GetDefaultRestoreRuntimes().First();
                osName = osName.Substring(0, osName.Length - 4);                    // Remove the -x86 suffix
                AssertLockFileTarget(lockFile, osName + "-x86", assemblyRid: null); // There is no ubuntu/osx-x86 in the test package
                AssertLockFileTarget(lockFile, osName + "-x64", osName + "-x64");
            }
        }
Ejemplo n.º 3
0
        public void DnuRestore_GeneratesDefaultRuntimeTargets(string flavor, string os, string architecture)
        {
            // TODO(anurse): Maybe this could be a condition? This is the only place we need it right now so it
            // didn't seem worth the refactor.
            // Travis has old versions of OSes and our test package doesn't work there
            var isTravisEnvironment = Environment.GetEnvironmentVariable("TRAVIS") ?? "false";

            if (isTravisEnvironment.Equals("true"))
            {
                return;
            }

            var runtimeHomeDir = TestUtils.GetRuntimeHomeDir(flavor, os, architecture);

            LockFile lockFile;

            using (var testDir = new DisposableDir())
            {
                var misc = TestUtils.GetMiscProjectsFolder();
                DirTree.CreateFromDirectory(Path.Combine(misc, "RuntimeRestore", "TestProject"))
                .WriteTo(testDir);

                // Clean up the lock file if it ended up there during the copy
                var lockFilePath = Path.Combine(testDir, "project.lock.json");
                if (File.Exists(lockFilePath))
                {
                    File.Delete(lockFilePath);
                }

                // Restore the project!
                var source = Path.Combine(misc, "RuntimeRestore", "RuntimeRestoreTestPackage", "feed");
                DnuTestUtils.ExecDnu(runtimeHomeDir, "restore", $"--source {source}", workingDir: testDir);

                // Check the lock file
                lockFile = (new LockFileFormat()).Read(Path.Combine(testDir, "project.lock.json"));
            }

            // We can use the runtime environment to determine the expected RIDs
            var osName = RuntimeEnvironmentHelper.RuntimeEnvironment.GetDefaultRestoreRuntimes().First();

            if (osName.StartsWith("win"))
            {
                AssertLockFileTarget(lockFile, "win7-x86", "win7-x86");
                AssertLockFileTarget(lockFile, "win7-x64", "win7-x64");
            }
            else if (osName.StartsWith("ubuntu"))
            {
                // There is only ubuntu 14.04 in the package
                AssertLockFileTarget(lockFile, osName + "-x86", assemblyRid: null); // There is no ubuntu/osx-x86 in the test package
                AssertLockFileTarget(lockFile, osName + "-x64", "ubuntu.14.04-x64");
            }
            else if (osName.StartsWith("osx"))
            {
                // There is only osx 10.10 in the package
                AssertLockFileTarget(lockFile, osName + "-x86", assemblyRid: null); // There is no ubuntu/osx-x86 in the test package
                AssertLockFileTarget(lockFile, osName + "-x64", "osx.10.10-x64");
            }
            else
            {
                Assert.True(false, $"Unknown OS Name: {osName}");
            }
        }