|
1 | | -usingDotnet.Script.Shared.Tests; |
| 1 | +usingDotnet.Script.Shared.Tests; |
2 | 2 | usingSystem; |
3 | 3 | usingSystem.IO; |
4 | 4 | usingXunit; |
@@ -133,6 +133,34 @@ public void ShouldCacheScriptsFromSameFolderIndividually() |
133 | 133 | Assert.False(thirdResultOfScriptB.Cached); |
134 | 134 | } |
135 | 135 |
|
| 136 | +[Fact] |
| 137 | +publicvoidShouldUseCachePathWhenProvided() |
| 138 | +{ |
| 139 | +usingvarscriptFolder=newDisposableFolder(); |
| 140 | +varpathToScript=Path.Combine(scriptFolder.Path,"script.csx"); |
| 141 | + |
| 142 | +varexecutionPathA=DependencyModel.ProjectSystem.FileUtils.GetPathToScriptTempFolder(pathToScript,cachePath:null); |
| 143 | +Assert.True(Path.IsPathFullyQualified(executionPathA)); |
| 144 | +Assert.Contains("script.csx",executionPathA); |
| 145 | + |
| 146 | +varfullCachePath=Path.Combine(scriptFolder.Path,"AlternateCachePath"); |
| 147 | +varfullCachePathNoRoot=fullCachePath.Substring(Path.GetPathRoot(fullCachePath).Length); |
| 148 | +Assert.True(Path.IsPathFullyQualified(fullCachePath)); |
| 149 | + |
| 150 | +varexecutionPathB=DependencyModel.ProjectSystem.FileUtils.GetPathToScriptTempFolder(pathToScript,cachePath:fullCachePath); |
| 151 | +Assert.True(Path.IsPathFullyQualified(executionPathB)); |
| 152 | +Assert.Contains("script.csx",executionPathB); |
| 153 | +Assert.Contains(fullCachePathNoRoot,executionPathB); |
| 154 | + |
| 155 | +varrelativeCachePath=Path.Combine("Relative","CachePath"); |
| 156 | +Assert.False(Path.IsPathRooted(relativeCachePath)); |
| 157 | + |
| 158 | +varexecutionPathC=DependencyModel.ProjectSystem.FileUtils.GetPathToScriptTempFolder(pathToScript,cachePath:relativeCachePath); |
| 159 | +Assert.True(Path.IsPathFullyQualified(executionPathC)); |
| 160 | +Assert.Contains("script.csx",executionPathC); |
| 161 | +Assert.Contains(relativeCachePath,executionPathC); |
| 162 | +} |
| 163 | + |
136 | 164 | private(stringoutput,stringhash)Execute(stringpathToScript) |
137 | 165 | { |
138 | 166 | varresult=ScriptTestRunner.Default.Execute(pathToScript); |
|