2024-01-29 23:21:40 +01:00
|
|
|
import * as path from 'path'
|
|
|
|
import * as fs from 'fs'
|
2025-01-14 16:03:32 -05:00
|
|
|
import {describe, expect, it} from '@jest/globals'
|
|
|
|
|
2024-04-08 13:29:58 -06:00
|
|
|
import {GradleUserHomeCache} from "../../src/caching/gradle-user-home-cache"
|
2024-04-09 13:47:18 -06:00
|
|
|
import {CacheConfig} from "../../src/configuration"
|
2024-01-29 23:21:40 +01:00
|
|
|
|
2024-03-12 22:04:01 +13:00
|
|
|
const testTmp = 'test/jest/tmp'
|
|
|
|
fs.rmSync(testTmp, {recursive: true, force: true})
|
|
|
|
|
2024-01-29 23:21:40 +01:00
|
|
|
describe("--info and --stacktrace", () => {
|
|
|
|
describe("will be created", () => {
|
2025-01-23 12:08:44 -07:00
|
|
|
it("when gradle.properties does not exist", async () => {
|
2024-03-12 22:04:01 +13:00
|
|
|
const emptyGradleHome = `${testTmp}/empty-gradle-home`
|
|
|
|
fs.mkdirSync(emptyGradleHome, {recursive: true})
|
2024-01-29 23:21:40 +01:00
|
|
|
|
2024-04-08 13:29:58 -06:00
|
|
|
const stateCache = new GradleUserHomeCache("ignored", emptyGradleHome, new CacheConfig())
|
2024-01-29 23:21:40 +01:00
|
|
|
stateCache.configureInfoLogLevel()
|
|
|
|
|
|
|
|
expect(fs.readFileSync(path.resolve(emptyGradleHome, "gradle.properties"), 'utf-8'))
|
|
|
|
.toBe("org.gradle.logging.level=info\norg.gradle.logging.stacktrace=all\n")
|
|
|
|
})
|
|
|
|
})
|
|
|
|
describe("will be added", () => {
|
|
|
|
it("and gradle.properties does exists", async () => {
|
2024-03-12 22:04:01 +13:00
|
|
|
const existingGradleHome = `${testTmp}/existing-gradle-home`
|
|
|
|
fs.mkdirSync(existingGradleHome, {recursive: true})
|
2024-01-29 23:21:40 +01:00
|
|
|
fs.writeFileSync(path.resolve(existingGradleHome, "gradle.properties"), "org.gradle.logging.level=debug\n")
|
|
|
|
|
2024-04-08 13:29:58 -06:00
|
|
|
const stateCache = new GradleUserHomeCache("ignored", existingGradleHome, new CacheConfig())
|
2024-01-29 23:21:40 +01:00
|
|
|
stateCache.configureInfoLogLevel()
|
|
|
|
|
|
|
|
expect(fs.readFileSync(path.resolve(existingGradleHome, "gradle.properties"), 'utf-8'))
|
|
|
|
.toBe("org.gradle.logging.level=info\norg.gradle.logging.stacktrace=all\n\norg.gradle.logging.level=debug\n")
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|