From 6731041daade131e446f5129bad52cc3cf3f0bc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kat=20March=C3=A1n?= Date: Wed, 29 Jan 2020 21:46:12 +0000 Subject: [PATCH] enable PathTooLongException test Fixes: https://github.com/NuGet/Home/issues/8920 --- .../RestoreCommandTests.cs | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/test/NuGet.Core.FuncTests/NuGet.Commands.FuncTest/RestoreCommandTests.cs b/test/NuGet.Core.FuncTests/NuGet.Commands.FuncTest/RestoreCommandTests.cs index ef8c47881b1..e0cf2b064d4 100644 --- a/test/NuGet.Core.FuncTests/NuGet.Commands.FuncTest/RestoreCommandTests.cs +++ b/test/NuGet.Core.FuncTests/NuGet.Commands.FuncTest/RestoreCommandTests.cs @@ -1855,8 +1855,6 @@ public async Task RestoreCommand_LockedLockFileWithOutOfDateProjectAsync() } } -#if IS_DESKTOP - // TODO: To work on coreclr we need to address https://github.com/NuGet/Home/issues/7588 [Fact] public void RestoreCommand_PathTooLongException() { @@ -1866,9 +1864,9 @@ public void RestoreCommand_PathTooLongException() new PackageSource(NuGetConstants.V3FeedUrl) }; - using(var packagesDir = TestDirectory.Create()) - using(var projectDir = TestDirectory.Create()) - using(var cacheContext = new SourceCacheContext()) + using (var packagesDir = TestDirectory.Create()) + using (var projectDir = TestDirectory.Create()) + using (var cacheContext = new SourceCacheContext()) { var configJson = JObject.Parse(@" { @@ -1884,7 +1882,18 @@ public void RestoreCommand_PathTooLongException() var spec = JsonPackageSpecReader.GetPackageSpec(configJson.ToString(), "TestProject", specPath); var logger = new TestLogger(); - var request = new TestRestoreRequest(spec, sources, packagesDir + new string('_', 300), cacheContext, logger) + string longPath = packagesDir + new string('_', 300); + try + { + // This test is pointless if the machine has long paths enabled. + Path.GetFullPath(longPath); + return; + } + catch (PathTooLongException) + { + } + + var request = new TestRestoreRequest(spec, sources, longPath, cacheContext, logger) { LockFilePath = Path.Combine(projectDir, "project.lock.json") }; @@ -1895,7 +1904,6 @@ public void RestoreCommand_PathTooLongException() new Func(async () => await command.ExecuteAsync()).ShouldThrow(); } } -#endif [Fact] public async Task RestoreCommand_RestoreExactVersionWithFailingSourceAsync()