-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update paket restore UP-TO-DATE handling and clean pattern
Description =========== We defined the `UP-TO-DATE` spec as always false for testing reasons in the past. This pull requests adds tests and `upToDateWhen` specs to mimic `paket restore`'s own update check. This pull request brings also a change in the paket base plugin. Paket base will apply the `LifecycleBase` plugin to be able to adjust the `clean` task. The `clean` task will delete all paket generated directories: `.paket`, `packages` and `paket-files`. Changes ======= ![IMPROVE] `paketRestore` *UP-TO-DATE* check ![ADD] clean task and configure deletion of paket directories
- Loading branch information
Showing
5 changed files
with
173 additions
and
12 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
116 changes: 116 additions & 0 deletions
116
src/integrationTest/groovy/wooga/gradle/paket/get/PaketRestoreIntegrationSpec.groovy
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,116 @@ | ||
package wooga.gradle.paket.get | ||
|
||
import spock.lang.Shared | ||
import spock.lang.Unroll | ||
import wooga.gradle.paket.PaketIntegrationBaseSpec | ||
|
||
class PaketRestoreIntegrationSpec extends PaketIntegrationBaseSpec { | ||
|
||
def setup() { | ||
buildFile << """ | ||
group = 'test' | ||
${applyPlugin(PaketGetPlugin)} | ||
""".stripIndent() | ||
} | ||
|
||
@Override | ||
Object getBootstrapTestCases() { | ||
return [ | ||
PaketGetPlugin.RESTORE_TASK_NAME | ||
] | ||
} | ||
|
||
@Unroll | ||
def "task :#taskToRun fails when paket.lock is missing"() { | ||
given: "a paket dependency file" | ||
createFile("paket.dependencies") << """ | ||
source https://nuget.org/api/v2 | ||
nuget Mini | ||
""".stripIndent() | ||
|
||
when: | ||
def result = runTasksWithFailure(taskToRun) | ||
|
||
then: | ||
result.standardError.contains("specified for property 'paketLock' does not exist") | ||
|
||
where: | ||
taskToRun << [PaketGetPlugin.RESTORE_TASK_NAME] | ||
} | ||
|
||
@Shared | ||
private List<String> paketDirectories = ["packages", ".paket", "paket-files"] | ||
|
||
@Unroll | ||
def "task :#taskToRun restores when deleting paket dir: #dirToDelete"() { | ||
given: "a paket dependency file" | ||
createFile("paket.dependencies") << """ | ||
source https://nuget.org/api/v2 | ||
nuget Mini | ||
""".stripIndent() | ||
|
||
and: "the future paket files" | ||
def paketDirectories = paketDirectories.collect {new File(projectDir, it)} | ||
def restoreCacheFile = new File(projectDir, "paket-files/paket.restore.cached") | ||
|
||
and: "a paket install run to create the lock file and packages directory" | ||
runTasksSuccessfully("paketInstall") | ||
|
||
assert paketDirectories.every {it.exists()} | ||
assert !restoreCacheFile.exists() | ||
|
||
when: "deleting packages directory" | ||
new File(projectDir, dirToDelete).delete() | ||
|
||
and: "running paket restore" | ||
runTasksSuccessfully(taskToRun) | ||
|
||
then: | ||
paketDirectories.every {it.exists()} | ||
restoreCacheFile.exists() | ||
|
||
where: | ||
taskToRun = PaketGetPlugin.RESTORE_TASK_NAME | ||
dirToDelete << paketDirectories | ||
} | ||
|
||
@Unroll | ||
def "task :#taskToRun caches last restore state"() { | ||
given: "a paket dependency file" | ||
createFile("paket.dependencies") << """ | ||
source https://nuget.org/api/v2 | ||
nuget Mini | ||
""".stripIndent() | ||
|
||
and: "the future paket files" | ||
def restoreCacheFile = new File(projectDir, "paket-files/paket.restore.cached") | ||
|
||
and: "a paket install run to create the lock file and packages directory" | ||
runTasksSuccessfully("paketInstall") | ||
|
||
and: "deleting packages directory" | ||
new File(projectDir, "packages").delete() | ||
|
||
and: "running paket restore" | ||
runTasksSuccessfully(taskToRun) | ||
|
||
when: "running restore again" | ||
def result = runTasksSuccessfully(taskToRun) | ||
|
||
then: | ||
result.wasUpToDate(taskToRun) | ||
|
||
when: "deleting the cache file" | ||
restoreCacheFile.delete() | ||
result = runTasksSuccessfully(taskToRun) | ||
|
||
then: | ||
!result.wasUpToDate(taskToRun) | ||
|
||
where: | ||
taskToRun = PaketGetPlugin.RESTORE_TASK_NAME | ||
} | ||
} |
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