-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_as_maven_package.py
56 lines (43 loc) · 1.71 KB
/
test_as_maven_package.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
import json
import os.path
import subprocess
from tempground import TempGround
def test_package(maven_url: str, ver: str):
with TempGround(
files={
# minimalistic build script to use the library
"build.gradle.kts": """
plugins {
id("application")
kotlin("jvm") version "1.6.20"
}
repositories {
maven { url = uri("__TEMP_REPO__") }
mavenCentral()
}
application { mainClass.set("MainKt") }
dependencies {
implementation("io.github.rtmigo:precise:__VERSION__")
}
""".replace("__VERSION__", ver)
.replace("__TEMP_REPO__", maven_url),
# kotlin code that imports and uses the library
"src/main/kotlin/Main.kt": """
import io.github.rtmigo.precise.*
fun main() {
println(listOf(1.0, 2.0).preciseSumOf {it})
}
"""}
) 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!")
def build_test_release():
outp = json.loads(subprocess.check_output(
["java", "-jar", os.path.expanduser("~/mavence.jar"), "local"]))
test_package(outp["mavenRepo"], outp["version"])
if __name__ == "__main__":
build_test_release()