forked from fsprojects/Paket
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fsprojects#3127 storage symlink feature
- Loading branch information
cboudereau
committed
Mar 21, 2018
1 parent
cc538c2
commit d7ed41b
Showing
24 changed files
with
215 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
integrationtests/Paket.IntegrationTests/SymbolicLinkSpecs.fs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
module Paket.IntegrationTests.SymbolicLinkSpecs | ||
|
||
open NUnit.Framework | ||
open Fake | ||
open FsUnit | ||
open Paket | ||
|
||
[<Test>] | ||
let ``#3127 symlink enabled on all dependencies and empty paket.lock``() = | ||
clearPackageAtVersion "NUnit" "2.6.3" | ||
let scenario = "i003127-storage-symlink" | ||
let workingDir = scenarioTempPath scenario | ||
paketEx true "update" scenario |> ignore | ||
|
||
workingDir </> "packages" </> "NUnit" | ||
|> SymlinkUtils.isDirectoryLink | ||
|> shouldEqual true | ||
|
||
let paketDependencies workingDir content = | ||
let d = DependenciesFile.FromSource(workingDir, content) | ||
d.Save() | ||
d | ||
|
||
let storageConfig (x:DependenciesFile) = x.Groups.[Domain.GroupName Domain.MainGroup].Options.Settings.StorageConfig | ||
|
||
[<Test>] | ||
let ``#3127 symlink enabled -> disabled on all dependencies on existing paket.lock``() = | ||
clearPackageAtVersion "NUnit" "2.6.3" | ||
|
||
let scenario = "i003127-storage-symlink" | ||
let workingDir = scenarioTempPath scenario | ||
|
||
let packagesDir = workingDir </> "packages" | ||
|
||
paketEx true "install" scenario |> ignore | ||
|
||
workingDir </> "paket.dependencies" |> Paket.DependenciesFile.ReadFromFile | ||
|> storageConfig | ||
|> shouldEqual (Some PackagesFolderGroupConfig.SymbolicLink) | ||
|
||
packagesDir </> "NUnit" | ||
|> SymlinkUtils.isDirectoryLink | ||
|> shouldEqual true | ||
|
||
let paketDependenciesWithoutConfig = """source https://www.nuget.org/api/v2 | ||
nuget NUnit < 3.0.0""" | ||
|
||
paketDependenciesWithoutConfig | ||
|> paketDependencies workingDir | ||
|> storageConfig | ||
|> shouldEqual None | ||
|
||
directPaketEx "update" scenario |> ignore | ||
|
||
packagesDir </> "NUnit" | ||
|> SymlinkUtils.isDirectoryLink | ||
|> shouldEqual false | ||
|
||
[<Test>] | ||
let ``#3127 symlink disabled -> enabled on all dependencies on existing paket.lock``() = | ||
clearPackageAtVersion "NUnit" "2.6.3" | ||
|
||
let scenario = "i003127-storage-symlink" | ||
let workingDir = scenarioTempPath scenario | ||
|
||
let packagesDir = workingDir </> "packages" | ||
|
||
let paketDependenciesPath = workingDir </> "paket.dependencies" | ||
|
||
paketDependenciesPath |> Paket.DependenciesFile.ReadFromFile |> storageConfig |> shouldEqual (Some PackagesFolderGroupConfig.SymbolicLink) | ||
|
||
paketEx true "install" scenario |> ignore | ||
|
||
packagesDir </> "NUnit" | ||
|> SymlinkUtils.isDirectoryLink | ||
|> shouldEqual true | ||
|
||
let paketDependenciesWithoutConfig = """source https://www.nuget.org/api/v2 | ||
nuget NUnit < 3.0.0""" | ||
|
||
paketDependenciesWithoutConfig | ||
|> paketDependencies workingDir | ||
|> storageConfig | ||
|> shouldEqual None | ||
|
||
directPaketEx "update" scenario |> ignore | ||
|
||
packagesDir </> "NUnit" | ||
|> SymlinkUtils.isDirectoryLink | ||
|> shouldEqual false |
Binary file added
BIN
+96.2 KB
integrationtests/scenarios/i003127-storage-symlink/before/local_source/NUnit.2.6.3.nupkg
Binary file not shown.
3 changes: 3 additions & 0 deletions
3
integrationtests/scenarios/i003127-storage-symlink/before/paket.dependencies
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
source https://www.nuget.org/api/v2 | ||
storage: symlink | ||
nuget NUnit < 3.0.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
module SymlinkUtils | ||
|
||
open System | ||
open Paket | ||
open System.Diagnostics | ||
|
||
let isDirectoryLink directory = | ||
let di = IO.DirectoryInfo(directory) | ||
di.Exists && di.Attributes.HasFlag(IO.FileAttributes.ReparsePoint) | ||
|
||
/// delete the symlink only (do not remove files before) | ||
let delete directory = if isDirectoryLink directory then IO.Directory.Delete directory | ||
|
||
let makeDirectoryLink target source = | ||
let mklink (p:ProcessStartInfo) = | ||
p.FileName <- "cmd.exe" | ||
p.Arguments <- sprintf @"/c ""mklink /D ""%s"" ""%s""""" target source | ||
|
||
let ln (p:ProcessStartInfo) = | ||
p.FileName <- "ln" | ||
p.Arguments <- sprintf @"-sT ""%s"" ""%s""" target source | ||
|
||
let xLn = if isUnix then ln else mklink | ||
|
||
let r = ProcessHelper.ExecProcessAndReturnMessages xLn (TimeSpan.FromSeconds(10.)) | ||
|
||
match r.OK, Logging.verbose with | ||
| true, true -> | ||
let m = ProcessHelper.toLines r.Messages | ||
sprintf "symlink used %s -> %s (%s)" source target m |> Logging.traceVerbose | ||
| true, false -> () | ||
| false, _ -> | ||
let m = ProcessHelper.toLines r.Messages | ||
let e = ProcessHelper.toLines r.Errors | ||
failwithf "symlink %s -> %s failed with error : [%i] with output : %s%s and error : %s" source target r.ExitCode m Environment.NewLine e |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
module StorageSpecs | ||
|
||
open Paket | ||
open NUnit.Framework | ||
open FsUnit | ||
|
||
[<Test>] | ||
let ``should configure the symlink option``() = | ||
let dependencies = """framework: >= net40 | ||
storage: symlink | ||
source https://www.nuget.org/api/v2 | ||
nuget NLog framework: net40 | ||
nuget NLog.Contrib""" | ||
|
||
let cfg = DependenciesFile.FromSource(dependencies) | ||
cfg.Groups.[Constants.MainDependencyGroup].Options.Settings.StorageConfig |> shouldEqual (Some PackagesFolderGroupConfig.SymbolicLink) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.