-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_as_git_module.py
58 lines (44 loc) · 1.59 KB
/
test_as_git_module.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import sys
from tempground import *
module="io.github.rtmigo:precise"
url="https://github.com/rtmigo/precise_kt"
code="""
import io.github.rtmigo.precise.*
fun main() {
println(listOf(1.0, 2.0).preciseSumOf {it})
}
"""
try:
imp_details = """{ version { branch = "__BRANCH__" } }""".replace("__BRANCH__", sys.argv[1])
except IndexError:
imp_details = ""
with TempGround(
files={
# minimalistic build script to use the library
"build.gradle.kts": """
plugins {
id("application")
kotlin("jvm") version "1.6.20"
}
repositories { mavenCentral() }
application { mainClass.set("MainKt") }
dependencies {
implementation("__MODULE__") __IMP_DETAILS__
}
""".replace("__MODULE__", module).replace("__IMP_DETAILS__", imp_details),
# additional settings, if necessary
"settings.gradle.kts": """
sourceControl {
gitRepository(java.net.URI("__URL__.git")) {
producesModule("__MODULE__")
}
}
""".replace("__MODULE__", module).replace("__URL__", url),
# kotlin code that imports and uses the library
"src/main/kotlin/Main.kt": code}) as app:
print(app.files_content())
result = app.run(["gradle", "run", "-q"])
print(result)
assert result.returncode == 0
assert result.stdout == "3.0\n", result.stdout
print("Everything is OK!")