• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
<lambda>null2  * Copyright 2016-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
3  */
4 
5 package kotlinx.atomicfu.gradle.plugin.test.cases.smoke
6 
7 import kotlinx.atomicfu.gradle.plugin.test.framework.runner.BuildResult
8 import java.io.File
9 import kotlin.test.*
10 
11 class DependencyParserSmokeTest {
12     private val tempFile = File.createTempFile("sample", null)
13 
14     private val dependencies = "> Task :dependencies\n" +
15             "\n" +
16             "------------------------------------------------------------\n" +
17             "Root project 'jvm-sample'\n" +
18             "------------------------------------------------------------\n" +
19             "compileClasspath - Compile classpath for null/main.\n" +
20             "+--- org.jetbrains.kotlinx:atomicfu-jvm:0.23.1-SNAPSHOT\n" +
21             "+--- org.jetbrains.kotlin:kotlin-stdlib:1.9.0\n" +
22             "|    +--- org.jetbrains.kotlin:kotlin-stdlib-common:1.9.0\n" +
23             "|    \\--- org.jetbrains:annotations:13.0\n" +
24             "\\--- org.jetbrains.kotlin:kotlin-test-junit:1.9.0\n" +
25             "     +--- org.jetbrains.kotlin:kotlin-test:1.9.0\n" +
26             "     |    \\--- org.jetbrains.kotlin:kotlin-stdlib:1.9.0 (*)\n" +
27             "     \\--- junit:junit:4.13.2\n" +
28             "          \\--- org.hamcrest:hamcrest-core:1.3\n" +
29             "\n" +
30             "compileOnly - Compile only dependencies for null/main. (n)\n" +
31             "\\--- org.jetbrains.kotlinx:atomicfu-jvm:0.23.1-SNAPSHOT (n)\n" +
32             "\n" +
33             "compileOnlyDependenciesMetadata\n" +
34             "\\--- org.jetbrains.kotlinx:atomicfu-jvm:0.23.1-SNAPSHOT\n" +
35             "\n" +
36             "default - Configuration for default artifacts. (n)\n" +
37             "No dependencies\n" +
38             "\n" +
39             "implementation - Implementation only dependencies for null/main. (n)\n" +
40             "+--- org.jetbrains.kotlin:kotlin-stdlib (n)\n" +
41             "\\--- org.jetbrains.kotlin:kotlin-test-junit (n)\n" +
42             "\n" +
43             "implementationDependenciesMetadata\n" +
44             "+--- org.jetbrains.kotlin:kotlin-stdlib:1.9.0\n" +
45             "|    +--- org.jetbrains.kotlin:kotlin-stdlib-common:1.9.0\n" +
46             "|    \\--- org.jetbrains:annotations:13.0\n" +
47             "\\--- org.jetbrains.kotlin:kotlin-test-junit:1.9.0\n" +
48             "     +--- org.jetbrains.kotlin:kotlin-test:1.9.0\n" +
49             "     |    +--- org.jetbrains.kotlin:kotlin-test-common:1.9.0\n" +
50             "     |    |    \\--- org.jetbrains.kotlin:kotlin-stdlib-common:1.9.0\n" +
51             "     |    \\--- org.jetbrains.kotlin:kotlin-test-annotations-common:1.9.0\n" +
52             "     |         \\--- org.jetbrains.kotlin:kotlin-stdlib-common:1.9.0\n" +
53             "     \\--- junit:junit:4.13.2\n" +
54             "          \\--- org.hamcrest:hamcrest-core:1.3\n" +
55             "\n"
56 
57     @Test
58     fun testGetDependenciesForConfig() {
59         tempFile.bufferedWriter().use { out ->
60             out.write(dependencies)
61         }
62         val buildResult = BuildResult(0, tempFile)
63         assertEquals(
64             listOf(
65                 "org.jetbrains.kotlin:kotlin-stdlib",
66                 "org.jetbrains.kotlin:kotlin-test-junit"
67             ),
68             buildResult.getDependenciesForConfig("implementation")
69         )
70         assertEquals(
71             emptyList(),
72             buildResult.getDependenciesForConfig("default")
73         )
74         assertEquals(
75             listOf(
76                 "org.jetbrains.kotlinx:atomicfu-jvm:0.23.1-SNAPSHOT",
77                 "org.jetbrains.kotlin:kotlin-stdlib:1.9.0",
78                 "org.jetbrains.kotlin:kotlin-stdlib-common:1.9.0",
79                 "org.jetbrains:annotations:13.0",
80                 "org.jetbrains.kotlin:kotlin-test-junit:1.9.0",
81                 "org.jetbrains.kotlin:kotlin-test:1.9.0",
82                 "org.jetbrains.kotlin:kotlin-stdlib:1.9.0",
83                 "junit:junit:4.13.2",
84                 "org.hamcrest:hamcrest-core:1.3"
85             ),
86             buildResult.getDependenciesForConfig("compileClasspath")
87         )
88     }
89 }
90