Initial commit
Some checks failed
CI-integ-test-full / caching-integ-tests (push) Failing after 32s
CI-integ-test-full / other-integ-tests (push) Failing after 29m15s
Update Wrapper checksums file / Update checksums (push) Failing after 3m7s
CI-codeql / Analyze (javascript-typescript) (push) Failing after 10m7s
Some checks failed
CI-integ-test-full / caching-integ-tests (push) Failing after 32s
CI-integ-test-full / other-integ-tests (push) Failing after 29m15s
Update Wrapper checksums file / Update checksums (push) Failing after 3m7s
CI-codeql / Analyze (javascript-typescript) (push) Failing after 10m7s
This commit is contained in:
1
sources/test/jest/.gitignore
vendored
Normal file
1
sources/test/jest/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
tmp
|
||||
109
sources/test/jest/cache-cleanup.test.ts
Normal file
109
sources/test/jest/cache-cleanup.test.ts
Normal file
@@ -0,0 +1,109 @@
|
||||
import * as exec from '@actions/exec'
|
||||
import * as core from '@actions/core'
|
||||
import * as glob from '@actions/glob'
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
import {CacheCleaner} from '../../src/caching/cache-cleaner'
|
||||
|
||||
jest.setTimeout(120000)
|
||||
|
||||
test('will cleanup unused dependency jars and build-cache entries', async () => {
|
||||
const projectRoot = prepareTestProject()
|
||||
const gradleUserHome = path.resolve(projectRoot, 'HOME')
|
||||
const tmpDir = path.resolve(projectRoot, 'tmp')
|
||||
const cacheCleaner = new CacheCleaner(gradleUserHome, tmpDir)
|
||||
|
||||
await runGradleBuild(projectRoot, 'build', '3.1')
|
||||
|
||||
const timestamp = await cacheCleaner.prepare()
|
||||
|
||||
await runGradleBuild(projectRoot, 'build', '3.1.1')
|
||||
|
||||
const commonsMath31 = path.resolve(gradleUserHome, "caches/modules-2/files-2.1/org.apache.commons/commons-math3/3.1")
|
||||
const commonsMath311 = path.resolve(gradleUserHome, "caches/modules-2/files-2.1/org.apache.commons/commons-math3/3.1.1")
|
||||
const buildCacheDir = path.resolve(gradleUserHome, "caches/build-cache-1")
|
||||
|
||||
expect(fs.existsSync(commonsMath31)).toBe(true)
|
||||
expect(fs.existsSync(commonsMath311)).toBe(true)
|
||||
expect(fs.readdirSync(buildCacheDir).length).toBe(4) // gc.properties, build-cache-1.lock, and 2 task entries
|
||||
|
||||
await cacheCleaner.forceCleanupFilesOlderThan(timestamp)
|
||||
|
||||
expect(fs.existsSync(commonsMath31)).toBe(false)
|
||||
expect(fs.existsSync(commonsMath311)).toBe(true)
|
||||
expect(fs.readdirSync(buildCacheDir).length).toBe(3) // 1 task entry has been cleaned up
|
||||
})
|
||||
|
||||
test('will cleanup unused gradle versions', async () => {
|
||||
const projectRoot = prepareTestProject()
|
||||
const gradleUserHome = path.resolve(projectRoot, 'HOME')
|
||||
const tmpDir = path.resolve(projectRoot, 'tmp')
|
||||
const cacheCleaner = new CacheCleaner(gradleUserHome, tmpDir)
|
||||
|
||||
// Initialize HOME with 2 different Gradle versions
|
||||
await runGradleWrapperBuild(projectRoot, 'build')
|
||||
await runGradleBuild(projectRoot, 'build')
|
||||
|
||||
const timestamp = await cacheCleaner.prepare()
|
||||
|
||||
// Run with only one of these versions
|
||||
await runGradleBuild(projectRoot, 'build')
|
||||
|
||||
const gradle802 = path.resolve(gradleUserHome, "caches/8.0.2")
|
||||
const transforms3 = path.resolve(gradleUserHome, "caches/transforms-3")
|
||||
const metadata100 = path.resolve(gradleUserHome, "caches/modules-2/metadata-2.100")
|
||||
const wrapper802 = path.resolve(gradleUserHome, "wrapper/dists/gradle-8.0.2-bin")
|
||||
const gradleCurrent = path.resolve(gradleUserHome, "caches/8.10")
|
||||
const metadataCurrent = path.resolve(gradleUserHome, "caches/modules-2/metadata-2.106")
|
||||
|
||||
expect(fs.existsSync(gradle802)).toBe(true)
|
||||
expect(fs.existsSync(transforms3)).toBe(true)
|
||||
expect(fs.existsSync(metadata100)).toBe(true)
|
||||
expect(fs.existsSync(wrapper802)).toBe(true)
|
||||
|
||||
expect(fs.existsSync(gradleCurrent)).toBe(true)
|
||||
expect(fs.existsSync(metadataCurrent)).toBe(true)
|
||||
|
||||
// The wrapper won't be removed if it was recently downloaded. Age it.
|
||||
setUtimes(wrapper802, new Date(Date.now() - 48 * 60 * 60 * 1000))
|
||||
|
||||
await cacheCleaner.forceCleanupFilesOlderThan(timestamp)
|
||||
|
||||
expect(fs.existsSync(gradle802)).toBe(false)
|
||||
expect(fs.existsSync(transforms3)).toBe(false)
|
||||
expect(fs.existsSync(metadata100)).toBe(false)
|
||||
expect(fs.existsSync(wrapper802)).toBe(false)
|
||||
|
||||
expect(fs.existsSync(gradleCurrent)).toBe(true)
|
||||
expect(fs.existsSync(metadataCurrent)).toBe(true)
|
||||
})
|
||||
|
||||
async function runGradleBuild(projectRoot: string, args: string, version: string = '3.1'): Promise<void> {
|
||||
const status31 = await exec.exec(`gradle -g HOME --no-daemon --build-cache -Dcommons_math3_version="${version}" ${args}`, [], {
|
||||
cwd: projectRoot
|
||||
})
|
||||
console.log(`Gradle User Home initialized with commons_math3_version=${version} ${args}`)
|
||||
}
|
||||
|
||||
async function runGradleWrapperBuild(projectRoot: string, args: string, version: string = '3.1'): Promise<void> {
|
||||
const status31 = await exec.exec(`./gradlew -g HOME --no-daemon --build-cache -Dcommons_math3_version="${version}" ${args}`, [], {
|
||||
cwd: projectRoot
|
||||
})
|
||||
console.log(`Gradle User Home initialized with commons_math3_version="${version}" ${args}`)
|
||||
}
|
||||
|
||||
function prepareTestProject(): string {
|
||||
const projectRoot = 'test/jest/resources/cache-cleanup'
|
||||
fs.rmSync(path.resolve(projectRoot, 'HOME'), { recursive: true, force: true })
|
||||
fs.rmSync(path.resolve(projectRoot, 'tmp'), { recursive: true, force: true })
|
||||
fs.rmSync(path.resolve(projectRoot, 'build'), { recursive: true, force: true })
|
||||
fs.rmSync(path.resolve(projectRoot, '.gradle'), { recursive: true, force: true })
|
||||
return projectRoot
|
||||
}
|
||||
|
||||
async function setUtimes(pattern: string, timestamp: Date): Promise<void> {
|
||||
const globber = await glob.create(pattern)
|
||||
for await (const file of globber.globGenerator()) {
|
||||
fs.utimesSync(file, timestamp, timestamp)
|
||||
}
|
||||
}
|
||||
35
sources/test/jest/cache-debug.test.ts
Normal file
35
sources/test/jest/cache-debug.test.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import * as path from 'path'
|
||||
import * as fs from 'fs'
|
||||
import {GradleUserHomeCache} from "../../src/caching/gradle-user-home-cache"
|
||||
import {CacheConfig} from "../../src/configuration"
|
||||
|
||||
const testTmp = 'test/jest/tmp'
|
||||
fs.rmSync(testTmp, {recursive: true, force: true})
|
||||
|
||||
describe("--info and --stacktrace", () => {
|
||||
describe("will be created", () => {
|
||||
it("when gradle.properties does not exists", async () => {
|
||||
const emptyGradleHome = `${testTmp}/empty-gradle-home`
|
||||
fs.mkdirSync(emptyGradleHome, {recursive: true})
|
||||
|
||||
const stateCache = new GradleUserHomeCache("ignored", emptyGradleHome, new CacheConfig())
|
||||
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 () => {
|
||||
const existingGradleHome = `${testTmp}/existing-gradle-home`
|
||||
fs.mkdirSync(existingGradleHome, {recursive: true})
|
||||
fs.writeFileSync(path.resolve(existingGradleHome, "gradle.properties"), "org.gradle.logging.level=debug\n")
|
||||
|
||||
const stateCache = new GradleUserHomeCache("ignored", existingGradleHome, new CacheConfig())
|
||||
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")
|
||||
})
|
||||
})
|
||||
})
|
||||
98
sources/test/jest/cache-reporting.test.ts
Normal file
98
sources/test/jest/cache-reporting.test.ts
Normal file
@@ -0,0 +1,98 @@
|
||||
import exp from 'constants'
|
||||
import {CacheEntryListener, CacheListener} from '../../src/caching/cache-reporting'
|
||||
|
||||
describe('caching report', () => {
|
||||
describe('reports not fully restored', () => {
|
||||
it('with one requested entry report', async () => {
|
||||
const report = new CacheListener()
|
||||
report.entry('foo').markRequested('1', ['2'])
|
||||
report.entry('bar').markRequested('3').markRestored('4', 500, 1000)
|
||||
expect(report.fullyRestored).toBe(false)
|
||||
})
|
||||
})
|
||||
describe('reports fully restored', () => {
|
||||
it('when empty', async () => {
|
||||
const report = new CacheListener()
|
||||
expect(report.fullyRestored).toBe(true)
|
||||
})
|
||||
it('with empty entry reports', async () => {
|
||||
const report = new CacheListener()
|
||||
report.entry('foo')
|
||||
report.entry('bar')
|
||||
expect(report.fullyRestored).toBe(true)
|
||||
})
|
||||
it('with restored entry report', async () => {
|
||||
const report = new CacheListener()
|
||||
report.entry('bar').markRequested('3').markRestored('4', 300, 1000)
|
||||
expect(report.fullyRestored).toBe(true)
|
||||
})
|
||||
it('with multiple restored entry reportss', async () => {
|
||||
const report = new CacheListener()
|
||||
report.entry('foo').markRestored('4', 3300, 111)
|
||||
report.entry('bar').markRequested('3').markRestored('4', 333, 1000)
|
||||
expect(report.fullyRestored).toBe(true)
|
||||
})
|
||||
})
|
||||
describe('can be stringified and rehydrated', () => {
|
||||
it('when empty', async () => {
|
||||
const report = new CacheListener()
|
||||
|
||||
const stringRep = report.stringify()
|
||||
const reportClone: CacheListener = CacheListener.rehydrate(stringRep)
|
||||
|
||||
expect(reportClone.cacheEntries).toEqual([])
|
||||
|
||||
// Can call methods on rehydrated
|
||||
expect(reportClone.entry('foo')).toBeInstanceOf(CacheEntryListener)
|
||||
})
|
||||
it('with entry reports', async () => {
|
||||
const report = new CacheListener()
|
||||
report.entry('foo')
|
||||
report.entry('bar')
|
||||
report.entry('baz')
|
||||
|
||||
const stringRep = report.stringify()
|
||||
const reportClone: CacheListener = CacheListener.rehydrate(stringRep)
|
||||
|
||||
expect(reportClone.cacheEntries.length).toBe(3)
|
||||
expect(reportClone.cacheEntries[0].entryName).toBe('foo')
|
||||
expect(reportClone.cacheEntries[1].entryName).toBe('bar')
|
||||
expect(reportClone.cacheEntries[2].entryName).toBe('baz')
|
||||
|
||||
expect(reportClone.entry('foo')).toBe(reportClone.cacheEntries[0])
|
||||
})
|
||||
it('with rehydrated entry report', async () => {
|
||||
const report = new CacheListener()
|
||||
const entryReport = report.entry('foo')
|
||||
entryReport.markRequested('1', ['2', '3'])
|
||||
entryReport.markSaved('4', 100, 1000)
|
||||
|
||||
const stringRep = report.stringify()
|
||||
const reportClone: CacheListener = CacheListener.rehydrate(stringRep)
|
||||
const entryClone = reportClone.entry('foo')
|
||||
|
||||
expect(entryClone.requestedKey).toBe('1')
|
||||
expect(entryClone.requestedRestoreKeys).toEqual(['2', '3'])
|
||||
expect(entryClone.savedKey).toBe('4')
|
||||
expect(entryClone.savedSize).toBe(100)
|
||||
expect(entryClone.savedTime).toBe(1000)
|
||||
})
|
||||
it('with live entry report', async () => {
|
||||
const report = new CacheListener()
|
||||
const entryReport = report.entry('foo')
|
||||
entryReport.markRequested('1', ['2', '3'])
|
||||
|
||||
const stringRep = report.stringify()
|
||||
const reportClone: CacheListener = CacheListener.rehydrate(stringRep)
|
||||
const entryClone = reportClone.entry('foo')
|
||||
|
||||
// Check type and call method on rehydrated entry report
|
||||
expect(entryClone).toBeInstanceOf(CacheEntryListener)
|
||||
entryClone.markSaved('4', 100, 1000)
|
||||
|
||||
expect(entryClone.requestedKey).toBe('1')
|
||||
expect(entryClone.requestedRestoreKeys).toEqual(['2', '3'])
|
||||
expect(entryClone.savedKey).toBe('4')
|
||||
})
|
||||
})
|
||||
})
|
||||
20
sources/test/jest/cache-utils.test.ts
Normal file
20
sources/test/jest/cache-utils.test.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import * as cacheUtils from '../../src/caching/cache-utils'
|
||||
|
||||
describe('cacheUtils-utils', () => {
|
||||
describe('can hash', () => {
|
||||
it('a string', async () => {
|
||||
const hash = cacheUtils.hashStrings(['foo'])
|
||||
expect(hash).toBe('acbd18db4cc2f85cedef654fccc4a4d8')
|
||||
})
|
||||
it('multiple strings', async () => {
|
||||
const hash = cacheUtils.hashStrings(['foo', 'bar', 'baz'])
|
||||
expect(hash).toBe('6df23dc03f9b54cc38a0fc1483df6e21')
|
||||
})
|
||||
it('normalized filenames', async () => {
|
||||
const fileNames = ['/foo/bar/baz.zip', '../boo.html']
|
||||
const posixHash = cacheUtils.hashFileNames(fileNames)
|
||||
const windowsHash = cacheUtils.hashFileNames(fileNames)
|
||||
expect(posixHash).toBe(windowsHash)
|
||||
})
|
||||
})
|
||||
})
|
||||
22
sources/test/jest/configuration.test.ts
Normal file
22
sources/test/jest/configuration.test.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import * as inputParams from '../../src/configuration'
|
||||
|
||||
describe('input params', () => {
|
||||
describe('parses numeric input', () => {
|
||||
it('uses default value', () => {
|
||||
const val = inputParams.parseNumericInput('param-name', '', 88)
|
||||
expect(val).toBe(88)
|
||||
})
|
||||
it('parses numeric input', () => {
|
||||
const val = inputParams.parseNumericInput('param-name', '34', 88)
|
||||
expect(val).toBe(34)
|
||||
})
|
||||
it('fails on non-numeric input', () => {
|
||||
const t = () => {
|
||||
inputParams.parseNumericInput('param-name', 'xyz', 88)
|
||||
};
|
||||
|
||||
expect(t).toThrow(TypeError)
|
||||
expect(t).toThrow("The value 'xyz' is not a valid numeric value for 'param-name'.")
|
||||
})
|
||||
})
|
||||
})
|
||||
34
sources/test/jest/dependency-graph.test.ts
Normal file
34
sources/test/jest/dependency-graph.test.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import { DependencyGraphConfig } from "../../src/configuration"
|
||||
|
||||
describe('dependency-graph', () => {
|
||||
describe('constructs job correlator', () => {
|
||||
it('removes commas from workflow name', () => {
|
||||
const id = DependencyGraphConfig.constructJobCorrelator('Workflow, with,commas', 'jobid', '{}')
|
||||
expect(id).toBe('workflow_withcommas-jobid')
|
||||
})
|
||||
it('removes non word characters', () => {
|
||||
const id = DependencyGraphConfig.constructJobCorrelator('Workflow!_with()characters', 'job-*id', '{"foo": "bar!@#$%^&*("}')
|
||||
expect(id).toBe('workflow_withcharacters-job-id-bar')
|
||||
})
|
||||
it('replaces spaces', () => {
|
||||
const id = DependencyGraphConfig.constructJobCorrelator('Workflow !_ with () characters, and spaces', 'job-*id', '{"foo": "bar!@#$%^&*("}')
|
||||
expect(id).toBe('workflow___with_characters_and_spaces-job-id-bar')
|
||||
})
|
||||
it('without matrix', () => {
|
||||
const id = DependencyGraphConfig.constructJobCorrelator('workflow', 'jobid', 'null')
|
||||
expect(id).toBe('workflow-jobid')
|
||||
})
|
||||
it('with dashes in values', () => {
|
||||
const id = DependencyGraphConfig.constructJobCorrelator('workflow-name', 'job-id', '{"os": "ubuntu-latest"}')
|
||||
expect(id).toBe('workflow-name-job-id-ubuntu-latest')
|
||||
})
|
||||
it('with single matrix value', () => {
|
||||
const id = DependencyGraphConfig.constructJobCorrelator('workflow', 'jobid', '{"os": "windows"}')
|
||||
expect(id).toBe('workflow-jobid-windows')
|
||||
})
|
||||
it('with composite matrix value', () => {
|
||||
const id = DependencyGraphConfig.constructJobCorrelator('workflow', 'jobid', '{"os": "windows", "java-version": "21.1", "other": "Value, with COMMA"}')
|
||||
expect(id).toBe('workflow-jobid-windows-211-value_with_comma')
|
||||
})
|
||||
})
|
||||
})
|
||||
104
sources/test/jest/gradle-version.test.ts
Normal file
104
sources/test/jest/gradle-version.test.ts
Normal file
@@ -0,0 +1,104 @@
|
||||
import { describe } from 'node:test'
|
||||
import { versionIsAtLeast, parseGradleVersionFromOutput } from '../../src/execution/gradle'
|
||||
|
||||
describe('gradle', () => {
|
||||
describe('can compare version with', () => {
|
||||
it('same version', async () => {
|
||||
expect(versionIsAtLeast('6.7.1', '6.7.1')).toBe(true)
|
||||
expect(versionIsAtLeast('7.0', '7.0')).toBe(true)
|
||||
expect(versionIsAtLeast('7.0', '7.0.0')).toBe(true)
|
||||
})
|
||||
it('newer version', async () => {
|
||||
expect(versionIsAtLeast('6.7.1', '6.7.2')).toBe(false)
|
||||
expect(versionIsAtLeast('7.0', '8.0')).toBe(false)
|
||||
expect(versionIsAtLeast('7.0', '7.0.1')).toBe(false)
|
||||
})
|
||||
it('older version', async () => {
|
||||
expect(versionIsAtLeast('6.7.2', '6.7.1')).toBe(true)
|
||||
expect(versionIsAtLeast('8.0', '7.0')).toBe(true)
|
||||
expect(versionIsAtLeast('7.0.1', '7.0')).toBe(true)
|
||||
})
|
||||
it('rc version', async () => {
|
||||
expect(versionIsAtLeast('8.0.2-rc-1', '8.0.1')).toBe(true)
|
||||
expect(versionIsAtLeast('8.0.2-rc-1', '8.0.2')).toBe(false)
|
||||
expect(versionIsAtLeast('8.1-rc-1', '8.0')).toBe(true)
|
||||
expect(versionIsAtLeast('8.0-rc-1', '8.0')).toBe(false)
|
||||
})
|
||||
it('snapshot version', async () => {
|
||||
expect(versionIsAtLeast('8.11-20240829002031+0000', '8.10')).toBe(true)
|
||||
expect(versionIsAtLeast('8.11-20240829002031+0000', '8.10.1')).toBe(true)
|
||||
expect(versionIsAtLeast('8.11-20240829002031+0000', '8.11')).toBe(false)
|
||||
|
||||
expect(versionIsAtLeast('8.10.2-20240828012138+0000', '8.10')).toBe(true)
|
||||
expect(versionIsAtLeast('8.10.2-20240828012138+0000', '8.10.1')).toBe(true)
|
||||
expect(versionIsAtLeast('8.10.2-20240828012138+0000', '8.10.2')).toBe(false)
|
||||
expect(versionIsAtLeast('8.10.2-20240828012138+0000', '8.11')).toBe(false)
|
||||
|
||||
expect(versionIsAtLeast('9.1-branch-provider_api_migration_public_api_changes-20240826121451+0000', '9.0')).toBe(true)
|
||||
expect(versionIsAtLeast('9.1-branch-provider_api_migration_public_api_changes-20240826121451+0000', '9.0.1')).toBe(true)
|
||||
expect(versionIsAtLeast('9.1-branch-provider_api_migration_public_api_changes-20240826121451+0000', '9.1')).toBe(false)
|
||||
})
|
||||
})
|
||||
describe('can parse version from output', () => {
|
||||
it('major version', async () => {
|
||||
const output = `
|
||||
------------------------------------------------------------
|
||||
Gradle 8.9
|
||||
------------------------------------------------------------
|
||||
`
|
||||
const version = await parseGradleVersionFromOutput(output)!
|
||||
expect(version).toBe('8.9')
|
||||
})
|
||||
|
||||
it('patch version', async () => {
|
||||
const output = `
|
||||
------------------------------------------------------------
|
||||
Gradle 8.9.1
|
||||
------------------------------------------------------------
|
||||
`
|
||||
const version = await parseGradleVersionFromOutput(output)!
|
||||
expect(version).toBe('8.9.1')
|
||||
})
|
||||
|
||||
it('rc version', async () => {
|
||||
const output = `
|
||||
------------------------------------------------------------
|
||||
Gradle 8.9-rc-1
|
||||
------------------------------------------------------------
|
||||
`
|
||||
const version = await parseGradleVersionFromOutput(output)!
|
||||
expect(version).toBe('8.9-rc-1')
|
||||
})
|
||||
|
||||
it('milestone version', async () => {
|
||||
const output = `
|
||||
------------------------------------------------------------
|
||||
Gradle 8.0-milestone-6
|
||||
------------------------------------------------------------
|
||||
`
|
||||
const version = await parseGradleVersionFromOutput(output)!
|
||||
expect(version).toBe('8.0-milestone-6')
|
||||
})
|
||||
|
||||
it('snapshot version', async () => {
|
||||
const output = `
|
||||
------------------------------------------------------------
|
||||
Gradle 8.10.2-20240828012138+0000
|
||||
------------------------------------------------------------
|
||||
`
|
||||
const version = await parseGradleVersionFromOutput(output)!
|
||||
expect(version).toBe('8.10.2-20240828012138+0000')
|
||||
})
|
||||
|
||||
it('branch version', async () => {
|
||||
const output = `
|
||||
------------------------------------------------------------
|
||||
Gradle 9.0-branch-provider_api_migration_public_api_changes-20240830060514+0000
|
||||
------------------------------------------------------------
|
||||
`
|
||||
const version = await parseGradleVersionFromOutput(output)!
|
||||
expect(version).toBe('9.0-branch-provider_api_migration_public_api_changes-20240830060514+0000')
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
178
sources/test/jest/job-summary.test.ts
Normal file
178
sources/test/jest/job-summary.test.ts
Normal file
@@ -0,0 +1,178 @@
|
||||
import { BuildResult } from '../../src/build-results'
|
||||
import { renderSummaryTable } from '../../src/job-summary'
|
||||
import dedent from 'dedent'
|
||||
|
||||
|
||||
const successfulHelpBuild: BuildResult = {
|
||||
rootProjectName: 'root',
|
||||
rootProjectDir: '/',
|
||||
requestedTasks: 'help',
|
||||
gradleVersion: '8.0',
|
||||
gradleHomeDir: '/opt/gradle',
|
||||
buildFailed: false,
|
||||
configCacheHit: false,
|
||||
buildScanUri: 'https://scans.gradle.com/s/abc123',
|
||||
buildScanFailed: false
|
||||
}
|
||||
|
||||
const failedHelpBuild: BuildResult = {
|
||||
...successfulHelpBuild,
|
||||
buildFailed: true
|
||||
}
|
||||
|
||||
const longArgsBuild: BuildResult = {
|
||||
...successfulHelpBuild,
|
||||
requestedTasks: 'check publishMyLongNamePluginPublicationToMavenCentral publishMyLongNamePluginPublicationToPluginPortal',
|
||||
}
|
||||
|
||||
const scanPublishDisabledBuild: BuildResult = {
|
||||
...successfulHelpBuild,
|
||||
buildScanUri: '',
|
||||
buildScanFailed: false,
|
||||
}
|
||||
|
||||
const scanPublishFailedBuild: BuildResult = {
|
||||
...successfulHelpBuild,
|
||||
buildScanUri: '',
|
||||
buildScanFailed: true,
|
||||
}
|
||||
|
||||
describe('renderSummaryTable', () => {
|
||||
describe('renders', () => {
|
||||
it('successful build', () => {
|
||||
const table = renderSummaryTable([successfulHelpBuild])
|
||||
expect(table.trim()).toBe(dedent`
|
||||
<table>
|
||||
<tr>
|
||||
<th>Gradle Root Project</th>
|
||||
<th>Requested Tasks</th>
|
||||
<th>Gradle Version</th>
|
||||
<th>Build Outcome</th>
|
||||
<th>Build Scan®</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>root</td>
|
||||
<td>help</td>
|
||||
<td align='center'>8.0</td>
|
||||
<td align='center'>:white_check_mark:</td>
|
||||
<td><a href="https://scans.gradle.com/s/abc123" rel="nofollow" target="_blank"><img src="https://img.shields.io/badge/Build%20Scan%C2%AE-06A0CE?logo=Gradle" alt="Build Scan published" /></a></td>
|
||||
</tr>
|
||||
</table>
|
||||
`);
|
||||
})
|
||||
it('failed build', () => {
|
||||
const table = renderSummaryTable([failedHelpBuild])
|
||||
expect(table.trim()).toBe(dedent`
|
||||
<table>
|
||||
<tr>
|
||||
<th>Gradle Root Project</th>
|
||||
<th>Requested Tasks</th>
|
||||
<th>Gradle Version</th>
|
||||
<th>Build Outcome</th>
|
||||
<th>Build Scan®</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>root</td>
|
||||
<td>help</td>
|
||||
<td align='center'>8.0</td>
|
||||
<td align='center'>:x:</td>
|
||||
<td><a href="https://scans.gradle.com/s/abc123" rel="nofollow" target="_blank"><img src="https://img.shields.io/badge/Build%20Scan%C2%AE-06A0CE?logo=Gradle" alt="Build Scan published" /></a></td>
|
||||
</tr>
|
||||
</table>
|
||||
`);
|
||||
})
|
||||
describe('when build scan', () => {
|
||||
it('publishing disabled', () => {
|
||||
const table = renderSummaryTable([scanPublishDisabledBuild])
|
||||
expect(table.trim()).toBe(dedent`
|
||||
<table>
|
||||
<tr>
|
||||
<th>Gradle Root Project</th>
|
||||
<th>Requested Tasks</th>
|
||||
<th>Gradle Version</th>
|
||||
<th>Build Outcome</th>
|
||||
<th>Build Scan®</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>root</td>
|
||||
<td>help</td>
|
||||
<td align='center'>8.0</td>
|
||||
<td align='center'>:white_check_mark:</td>
|
||||
<td><a href="https://scans.gradle.com" rel="nofollow" target="_blank"><img src="https://img.shields.io/badge/Not%20published-lightgrey" alt="Build Scan not published" /></a></td>
|
||||
</tr>
|
||||
</table>
|
||||
`);
|
||||
})
|
||||
it('publishing failed', () => {
|
||||
const table = renderSummaryTable([scanPublishFailedBuild])
|
||||
expect(table.trim()).toBe(dedent`
|
||||
<table>
|
||||
<tr>
|
||||
<th>Gradle Root Project</th>
|
||||
<th>Requested Tasks</th>
|
||||
<th>Gradle Version</th>
|
||||
<th>Build Outcome</th>
|
||||
<th>Build Scan®</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>root</td>
|
||||
<td>help</td>
|
||||
<td align='center'>8.0</td>
|
||||
<td align='center'>:white_check_mark:</td>
|
||||
<td><a href="https://docs.gradle.com/develocity/gradle-plugin/#troubleshooting" rel="nofollow" target="_blank"><img src="https://img.shields.io/badge/Publish%20failed-orange" alt="Build Scan publish failed" /></a></td>
|
||||
</tr>
|
||||
</table>
|
||||
`);
|
||||
})
|
||||
})
|
||||
it('multiple builds', () => {
|
||||
const table = renderSummaryTable([successfulHelpBuild, failedHelpBuild])
|
||||
expect(table.trim()).toBe(dedent`
|
||||
<table>
|
||||
<tr>
|
||||
<th>Gradle Root Project</th>
|
||||
<th>Requested Tasks</th>
|
||||
<th>Gradle Version</th>
|
||||
<th>Build Outcome</th>
|
||||
<th>Build Scan®</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>root</td>
|
||||
<td>help</td>
|
||||
<td align='center'>8.0</td>
|
||||
<td align='center'>:white_check_mark:</td>
|
||||
<td><a href="https://scans.gradle.com/s/abc123" rel="nofollow" target="_blank"><img src="https://img.shields.io/badge/Build%20Scan%C2%AE-06A0CE?logo=Gradle" alt="Build Scan published" /></a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>root</td>
|
||||
<td>help</td>
|
||||
<td align='center'>8.0</td>
|
||||
<td align='center'>:x:</td>
|
||||
<td><a href="https://scans.gradle.com/s/abc123" rel="nofollow" target="_blank"><img src="https://img.shields.io/badge/Build%20Scan%C2%AE-06A0CE?logo=Gradle" alt="Build Scan published" /></a></td>
|
||||
</tr>
|
||||
</table>
|
||||
`);
|
||||
})
|
||||
it('truncating long requested tasks', () => {
|
||||
const table = renderSummaryTable([longArgsBuild])
|
||||
expect(table.trim()).toBe(dedent`
|
||||
<table>
|
||||
<tr>
|
||||
<th>Gradle Root Project</th>
|
||||
<th>Requested Tasks</th>
|
||||
<th>Gradle Version</th>
|
||||
<th>Build Outcome</th>
|
||||
<th>Build Scan®</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>root</td>
|
||||
<td><div title='check publishMyLongNamePluginPublicationToMavenCentral publishMyLongNamePluginPublicationToPluginPortal'>check publishMyLongNamePluginPublicationToMavenCentral publ…</div></td>
|
||||
<td align='center'>8.0</td>
|
||||
<td align='center'>:white_check_mark:</td>
|
||||
<td><a href="https://scans.gradle.com/s/abc123" rel="nofollow" target="_blank"><img src="https://img.shields.io/badge/Build%20Scan%C2%AE-06A0CE?logo=Gradle" alt="Build Scan published" /></a></td>
|
||||
</tr>
|
||||
</table>
|
||||
`);
|
||||
})
|
||||
})
|
||||
})
|
||||
117
sources/test/jest/predefined-toolchains.test.ts
Normal file
117
sources/test/jest/predefined-toolchains.test.ts
Normal file
@@ -0,0 +1,117 @@
|
||||
import {getPredefinedToolchains, mergeToolchainContent} from "../../src/caching/gradle-user-home-utils";
|
||||
|
||||
describe('predefined-toolchains', () => {
|
||||
const OLD_ENV = process.env
|
||||
afterAll(() => {
|
||||
process.env = OLD_ENV
|
||||
});
|
||||
|
||||
describe('returns', () => {
|
||||
it('null if no JAVA_HOME_ envs are set', async () => {
|
||||
jest.resetModules()
|
||||
process.env = {
|
||||
"JAVA_HOME": "/jdks/foo_8"
|
||||
}
|
||||
|
||||
const predefinedToolchains = getPredefinedToolchains()
|
||||
expect(predefinedToolchains).toBe(null)
|
||||
})
|
||||
it('valid toolchains.xml if JAVA_HOME_ envs are set', async () => {
|
||||
jest.resetModules()
|
||||
process.env = {
|
||||
"JAVA_HOME": "/jdks/foo_8",
|
||||
"JAVA_HOME_8_X64": "/jdks/foo_8",
|
||||
"JAVA_HOME_11_X64": "/jdks/foo_11",
|
||||
"JAVA_HOME_21_ARM64": "/jdks/foo_21",
|
||||
}
|
||||
|
||||
const predefinedToolchains = getPredefinedToolchains()
|
||||
expect(predefinedToolchains).toBe(
|
||||
// language=XML
|
||||
`<?xml version="1.0" encoding="UTF-8"?>
|
||||
<toolchains>
|
||||
<!-- JDK Toolchains installed by default on GitHub-hosted runners -->
|
||||
<toolchain>
|
||||
<type>jdk</type>
|
||||
<provides>
|
||||
<version>8</version>
|
||||
</provides>
|
||||
<configuration>
|
||||
<jdkHome>\${env.JAVA_HOME_8_X64}</jdkHome>
|
||||
</configuration>
|
||||
</toolchain>
|
||||
<toolchain>
|
||||
<type>jdk</type>
|
||||
<provides>
|
||||
<version>11</version>
|
||||
</provides>
|
||||
<configuration>
|
||||
<jdkHome>\${env.JAVA_HOME_11_X64}</jdkHome>
|
||||
</configuration>
|
||||
</toolchain>
|
||||
<toolchain>
|
||||
<type>jdk</type>
|
||||
<provides>
|
||||
<version>21</version>
|
||||
</provides>
|
||||
<configuration>
|
||||
<jdkHome>\${env.JAVA_HOME_21_ARM64}</jdkHome>
|
||||
</configuration>
|
||||
</toolchain>
|
||||
</toolchains>
|
||||
`)
|
||||
})
|
||||
})
|
||||
|
||||
it("merges with existing toolchains", async () => {
|
||||
jest.resetModules()
|
||||
process.env = {
|
||||
"JAVA_HOME_11_X64": "/jdks/foo_11",
|
||||
}
|
||||
|
||||
// language=XML
|
||||
const existingToolchains =
|
||||
`<?xml version="1.0" encoding="UTF-8"?>
|
||||
<toolchains>
|
||||
<toolchain>
|
||||
<type>jdk</type>
|
||||
<provides>
|
||||
<version>8</version>
|
||||
</provides>
|
||||
<configuration>
|
||||
<jdkHome>\${env.JAVA_HOME_8_X64}</jdkHome>
|
||||
</configuration>
|
||||
</toolchain>
|
||||
</toolchains>
|
||||
`
|
||||
|
||||
const mergedContent = mergeToolchainContent(existingToolchains, getPredefinedToolchains()!)
|
||||
expect(mergedContent).toBe(
|
||||
// language=XML
|
||||
`<?xml version="1.0" encoding="UTF-8"?>
|
||||
<toolchains>
|
||||
<toolchain>
|
||||
<type>jdk</type>
|
||||
<provides>
|
||||
<version>8</version>
|
||||
</provides>
|
||||
<configuration>
|
||||
<jdkHome>\${env.JAVA_HOME_8_X64}</jdkHome>
|
||||
</configuration>
|
||||
</toolchain>
|
||||
|
||||
<!-- JDK Toolchains installed by default on GitHub-hosted runners -->
|
||||
<toolchain>
|
||||
<type>jdk</type>
|
||||
<provides>
|
||||
<version>11</version>
|
||||
</provides>
|
||||
<configuration>
|
||||
<jdkHome>\${env.JAVA_HOME_11_X64}</jdkHome>
|
||||
</configuration>
|
||||
</toolchain>
|
||||
</toolchains>
|
||||
|
||||
`)
|
||||
})
|
||||
})
|
||||
6
sources/test/jest/resources/cache-cleanup/.gitattributes
vendored
Normal file
6
sources/test/jest/resources/cache-cleanup/.gitattributes
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
#
|
||||
# https://help.github.com/articles/dealing-with-line-endings/
|
||||
#
|
||||
# These are explicitly windows files and should use crlf
|
||||
*.bat text eol=crlf
|
||||
|
||||
8
sources/test/jest/resources/cache-cleanup/.gitignore
vendored
Normal file
8
sources/test/jest/resources/cache-cleanup/.gitignore
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
# Ignore Gradle project-specific cache directory
|
||||
.gradle
|
||||
|
||||
# Ignore Gradle build output directory
|
||||
build
|
||||
|
||||
HOME
|
||||
tmp
|
||||
11
sources/test/jest/resources/cache-cleanup/build.gradle
Normal file
11
sources/test/jest/resources/cache-cleanup/build.gradle
Normal file
@@ -0,0 +1,11 @@
|
||||
plugins {
|
||||
id 'java-library'
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
api "org.apache.commons:commons-math3:${System.properties['commons_math3_version']}"
|
||||
}
|
||||
BIN
sources/test/jest/resources/cache-cleanup/gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
BIN
sources/test/jest/resources/cache-cleanup/gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
Binary file not shown.
6
sources/test/jest/resources/cache-cleanup/gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
6
sources/test/jest/resources/cache-cleanup/gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
# Deliberately not using the latest Gradle version for cache cleanup testing
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
245
sources/test/jest/resources/cache-cleanup/gradlew
vendored
Executable file
245
sources/test/jest/resources/cache-cleanup/gradlew
vendored
Executable file
@@ -0,0 +1,245 @@
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright © 2015-2021 the original authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# https://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
# Gradle start up script for POSIX generated by Gradle.
|
||||
#
|
||||
# Important for running:
|
||||
#
|
||||
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
||||
# noncompliant, but you have some other compliant shell such as ksh or
|
||||
# bash, then to run this script, type that shell name before the whole
|
||||
# command line, like:
|
||||
#
|
||||
# ksh Gradle
|
||||
#
|
||||
# Busybox and similar reduced shells will NOT work, because this script
|
||||
# requires all of these POSIX shell features:
|
||||
# * functions;
|
||||
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||
# * compound commands having a testable exit status, especially «case»;
|
||||
# * various built-in commands including «command», «set», and «ulimit».
|
||||
#
|
||||
# Important for patching:
|
||||
#
|
||||
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
||||
# by Bash, Ksh, etc; in particular arrays are avoided.
|
||||
#
|
||||
# The "traditional" practice of packing multiple parameters into a
|
||||
# space-separated string is a well documented source of bugs and security
|
||||
# problems, so this is (mostly) avoided, by progressively accumulating
|
||||
# options in "$@", and eventually passing that to Java.
|
||||
#
|
||||
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
||||
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
||||
# see the in-line comments for details.
|
||||
#
|
||||
# There are tweaks for specific operating systems such as AIX, CygWin,
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
|
||||
# Resolve links: $0 may be a link
|
||||
app_path=$0
|
||||
|
||||
# Need this for daisy-chained symlinks.
|
||||
while
|
||||
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
||||
[ -h "$app_path" ]
|
||||
do
|
||||
ls=$( ls -ld "$app_path" )
|
||||
link=${ls#*' -> '}
|
||||
case $link in #(
|
||||
/*) app_path=$link ;; #(
|
||||
*) app_path=$APP_HOME$link ;;
|
||||
esac
|
||||
done
|
||||
|
||||
# This is normally unused
|
||||
# shellcheck disable=SC2034
|
||||
APP_BASE_NAME=${0##*/}
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD=maximum
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
} >&2
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
} >&2
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
nonstop=false
|
||||
case "$( uname )" in #(
|
||||
CYGWIN* ) cygwin=true ;; #(
|
||||
Darwin* ) darwin=true ;; #(
|
||||
MSYS* | MINGW* ) msys=true ;; #(
|
||||
NONSTOP* ) nonstop=true ;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD=$JAVA_HOME/jre/sh/java
|
||||
else
|
||||
JAVACMD=$JAVA_HOME/bin/java
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD=java
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
case $MAX_FD in #(
|
||||
max*)
|
||||
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC3045
|
||||
MAX_FD=$( ulimit -H -n ) ||
|
||||
warn "Could not query maximum file descriptor limit"
|
||||
esac
|
||||
case $MAX_FD in #(
|
||||
'' | soft) :;; #(
|
||||
*)
|
||||
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC3045
|
||||
ulimit -n "$MAX_FD" ||
|
||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||
esac
|
||||
fi
|
||||
|
||||
# Collect all arguments for the java command, stacking in reverse order:
|
||||
# * args from the command line
|
||||
# * the main class name
|
||||
# * -classpath
|
||||
# * -D...appname settings
|
||||
# * --module-path (only if needed)
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
||||
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if "$cygwin" || "$msys" ; then
|
||||
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
||||
|
||||
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
for arg do
|
||||
if
|
||||
case $arg in #(
|
||||
-*) false ;; # don't mess with options #(
|
||||
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
||||
[ -e "$t" ] ;; #(
|
||||
*) false ;;
|
||||
esac
|
||||
then
|
||||
arg=$( cygpath --path --ignore --mixed "$arg" )
|
||||
fi
|
||||
# Roll the args list around exactly as many times as the number of
|
||||
# args, so each arg winds up back in the position where it started, but
|
||||
# possibly modified.
|
||||
#
|
||||
# NB: a `for` loop captures its iteration list before it begins, so
|
||||
# changing the positional parameters here affects neither the number of
|
||||
# iterations, nor the values presented in `arg`.
|
||||
shift # remove old arg
|
||||
set -- "$@" "$arg" # push replacement arg
|
||||
done
|
||||
fi
|
||||
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Collect all arguments for the java command;
|
||||
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
||||
# shell script including quotes and variable substitutions, so put them in
|
||||
# double quotes to make sure that they get re-expanded; and
|
||||
# * put everything else in single quotes, so that it's not re-expanded.
|
||||
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
-classpath "$CLASSPATH" \
|
||||
org.gradle.wrapper.GradleWrapperMain \
|
||||
"$@"
|
||||
|
||||
# Stop when "xargs" is not available.
|
||||
if ! command -v xargs >/dev/null 2>&1
|
||||
then
|
||||
die "xargs is not available"
|
||||
fi
|
||||
|
||||
# Use "xargs" to parse quoted args.
|
||||
#
|
||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||
#
|
||||
# In Bash we could simply go:
|
||||
#
|
||||
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
||||
# set -- "${ARGS[@]}" "$@"
|
||||
#
|
||||
# but POSIX shell has neither arrays nor command substitution, so instead we
|
||||
# post-process each arg (as a line of input to sed) to backslash-escape any
|
||||
# character that might be a shell metacharacter, then use eval to reverse
|
||||
# that process (while maintaining the separation between arguments), and wrap
|
||||
# the whole thing up as a single "set" statement.
|
||||
#
|
||||
# This will of course break if any of these variables contains a newline or
|
||||
# an unmatched quote.
|
||||
#
|
||||
|
||||
eval "set -- $(
|
||||
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
||||
xargs -n1 |
|
||||
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
||||
tr '\n' ' '
|
||||
)" '"$@"'
|
||||
|
||||
exec "$JAVACMD" "$@"
|
||||
92
sources/test/jest/resources/cache-cleanup/gradlew.bat
vendored
Normal file
92
sources/test/jest/resources/cache-cleanup/gradlew.bat
vendored
Normal file
@@ -0,0 +1,92 @@
|
||||
@rem
|
||||
@rem Copyright 2015 the original author or authors.
|
||||
@rem
|
||||
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@rem you may not use this file except in compliance with the License.
|
||||
@rem You may obtain a copy of the License at
|
||||
@rem
|
||||
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||
@rem
|
||||
@rem Unless required by applicable law or agreed to in writing, software
|
||||
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@rem See the License for the specific language governing permissions and
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%"=="" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%"=="" set DIRNAME=.
|
||||
@rem This is normally unused
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if %ERRORLEVEL% equ 0 goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
set EXIT_CODE=%ERRORLEVEL%
|
||||
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||
exit /b %EXIT_CODE%
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
||||
@@ -0,0 +1 @@
|
||||
rootProject.name = 'unused-dependencies'
|
||||
@@ -0,0 +1,10 @@
|
||||
/*
|
||||
* This Java source file was generated by the Gradle 'init' task.
|
||||
*/
|
||||
package unused.dependencies;
|
||||
|
||||
public class Library {
|
||||
public boolean someLibraryMethod() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
127
sources/test/jest/short-lived-token.test.ts
Normal file
127
sources/test/jest/short-lived-token.test.ts
Normal file
@@ -0,0 +1,127 @@
|
||||
import {DevelocityAccessCredentials, getToken} from "../../src/develocity/short-lived-token";
|
||||
import nock from "nock";
|
||||
|
||||
describe('short lived tokens', () => {
|
||||
it('parse valid access key should return an object', async () => {
|
||||
let develocityAccessCredentials = DevelocityAccessCredentials.parse('some-host.local=key1;host2=key2');
|
||||
|
||||
expect(develocityAccessCredentials).toStrictEqual(DevelocityAccessCredentials.of([
|
||||
{hostname: 'some-host.local', key: 'key1'},
|
||||
{hostname: 'host2', key: 'key2'}])
|
||||
)
|
||||
})
|
||||
|
||||
it('parse wrong access key should return null', async () => {
|
||||
let develocityAccessCredentials = DevelocityAccessCredentials.parse('random;foo');
|
||||
|
||||
expect(develocityAccessCredentials).toBeNull()
|
||||
})
|
||||
|
||||
it('parse empty access key should return null', async () => {
|
||||
let develocityAccessCredentials = DevelocityAccessCredentials.parse('');
|
||||
|
||||
expect(develocityAccessCredentials).toBeNull()
|
||||
})
|
||||
|
||||
it('access key as raw string', async () => {
|
||||
let develocityAccessCredentials = DevelocityAccessCredentials.parse('host1=key1;host2=key2');
|
||||
|
||||
expect(develocityAccessCredentials?.raw()).toBe('host1=key1;host2=key2')
|
||||
})
|
||||
|
||||
it('get short lived token fails when cannot connect', async () => {
|
||||
nock('http://localhost:3333')
|
||||
.post('/api/auth/token')
|
||||
.times(3)
|
||||
.replyWithError({
|
||||
message: 'connect ECONNREFUSED 127.0.0.1:3333',
|
||||
code: 'ECONNREFUSED'
|
||||
})
|
||||
await expect(getToken('localhost=key0', ''))
|
||||
.resolves
|
||||
.toBeNull()
|
||||
})
|
||||
|
||||
it('get short lived token is null when request fails', async () => {
|
||||
nock('http://dev:3333')
|
||||
.post('/api/auth/token')
|
||||
.times(3)
|
||||
.reply(500, 'Internal error')
|
||||
expect.assertions(1)
|
||||
await expect(getToken('dev=xyz', ''))
|
||||
.resolves
|
||||
.toBeNull()
|
||||
})
|
||||
|
||||
it('get short lived token returns null when access key is empty', async () => {
|
||||
expect.assertions(1)
|
||||
await expect(getToken('', ''))
|
||||
.resolves
|
||||
.toBeNull()
|
||||
})
|
||||
|
||||
it('get short lived token succeeds when single key is set', async () => {
|
||||
nock('https://dev')
|
||||
.post('/api/auth/token')
|
||||
.reply(200, 'token')
|
||||
expect.assertions(1)
|
||||
await expect(getToken('dev=key1', ''))
|
||||
.resolves
|
||||
.toEqual({"keys": [{"hostname": "dev", "key": "token"}]})
|
||||
})
|
||||
|
||||
it('get short lived token succeeds when multiple keys are set', async () => {
|
||||
nock('https://dev')
|
||||
.post('/api/auth/token')
|
||||
.reply(200, 'token1')
|
||||
nock('https://prod')
|
||||
.post('/api/auth/token')
|
||||
.reply(200, 'token2')
|
||||
expect.assertions(1)
|
||||
await expect(getToken('dev=key1;prod=key2', ''))
|
||||
.resolves
|
||||
.toEqual({"keys": [{"hostname": "dev", "key": "token1"}, {"hostname": "prod", "key": "token2"}]})
|
||||
})
|
||||
|
||||
it('get short lived token succeeds when multiple keys are set and one is failing', async () => {
|
||||
nock('https://dev')
|
||||
.post('/api/auth/token')
|
||||
.reply(200, 'token1')
|
||||
nock('https://bogus')
|
||||
.post('/api/auth/token')
|
||||
.times(3)
|
||||
.reply(500, 'Internal Error')
|
||||
nock('https://prod')
|
||||
.post('/api/auth/token')
|
||||
.reply(200, 'token2')
|
||||
expect.assertions(1)
|
||||
await expect(getToken('dev=key1;bogus=key0;prod=key2', ''))
|
||||
.resolves
|
||||
.toEqual({"keys": [{"hostname": "dev", "key": "token1"}, {"hostname": "prod", "key": "token2"}]})
|
||||
})
|
||||
|
||||
it('get short lived token is null when multiple keys are set and all are failing', async () => {
|
||||
nock('https://dev')
|
||||
.post('/api/auth/token')
|
||||
.times(3)
|
||||
.reply(500, 'Internal Error')
|
||||
nock('https://bogus')
|
||||
.post('/api/auth/token')
|
||||
.times(3)
|
||||
.reply(500, 'Internal Error')
|
||||
expect.assertions(1)
|
||||
await expect(getToken('dev=key1;bogus=key0', ''))
|
||||
.resolves
|
||||
.toBeNull()
|
||||
})
|
||||
|
||||
it('get short lived token with custom expiry', async () => {
|
||||
nock('https://dev')
|
||||
.post('/api/auth/token?expiresInHours=4')
|
||||
.reply(200, 'token')
|
||||
expect.assertions(1)
|
||||
await expect(getToken('dev=key1', '4'))
|
||||
.resolves
|
||||
.toEqual({"keys": [{"hostname": "dev", "key": "token"}]})
|
||||
})
|
||||
})
|
||||
71
sources/test/jest/wrapper-validation/checksums.test.ts
Normal file
71
sources/test/jest/wrapper-validation/checksums.test.ts
Normal file
@@ -0,0 +1,71 @@
|
||||
import * as checksums from '../../../src/wrapper-validation/checksums'
|
||||
import nock from 'nock'
|
||||
import {afterEach, describe, expect, test, jest} from '@jest/globals'
|
||||
|
||||
jest.setTimeout(30000)
|
||||
|
||||
test('has loaded hardcoded wrapper jars checksums', async () => {
|
||||
// Sanity check that generated checksums file is not empty and was properly imported
|
||||
expect(checksums.KNOWN_CHECKSUMS.checksums.size).toBeGreaterThan(10)
|
||||
// Verify that checksums of arbitrary versions are contained
|
||||
expect(
|
||||
checksums.KNOWN_CHECKSUMS.checksums.get(
|
||||
'660ab018b8e319e9ae779fdb1b7ac47d0321bde953bf0eb4545f14952cfdcaa3'
|
||||
)
|
||||
).toEqual(new Set(['4.10.3']))
|
||||
expect(
|
||||
checksums.KNOWN_CHECKSUMS.checksums.get(
|
||||
'28b330c20a9a73881dfe9702df78d4d78bf72368e8906c70080ab6932462fe9e'
|
||||
)
|
||||
).toEqual(new Set(['6.0-rc-1', '6.0-rc-2', '6.0-rc-3', '6.0', '6.0.1']))
|
||||
})
|
||||
|
||||
test('fetches wrapper jars checksums', async () => {
|
||||
const validChecksums = await checksums.fetchUnknownChecksums(false, new checksums.WrapperChecksums)
|
||||
expect(validChecksums.size).toBeGreaterThan(10)
|
||||
// Verify that checksum of arbitrary version is contained
|
||||
expect(
|
||||
validChecksums.has(
|
||||
// Checksum for version 6.0
|
||||
'28b330c20a9a73881dfe9702df78d4d78bf72368e8906c70080ab6932462fe9e'
|
||||
)
|
||||
).toBe(true)
|
||||
})
|
||||
|
||||
test('fetches wrapper jar checksums for snapshots', async () => {
|
||||
const nonSnapshotChecksums = await checksums.fetchUnknownChecksums(false, new checksums.WrapperChecksums)
|
||||
const validChecksums = await checksums.fetchUnknownChecksums(true, new checksums.WrapperChecksums)
|
||||
|
||||
// Expect that at least one snapshot checksum is different from the non-snapshot checksums
|
||||
expect(validChecksums.size).toBeGreaterThan(nonSnapshotChecksums.size)
|
||||
})
|
||||
|
||||
test('fetches all wrapper checksum URLS for snapshots', async () => {
|
||||
const checksumUrls: string[] = []
|
||||
await checksums.addDistributionSnapshotChecksums(checksumUrls)
|
||||
|
||||
expect(checksumUrls.length).toBeGreaterThan(100) // May only be a few unique checksums
|
||||
console.log(checksumUrls)
|
||||
})
|
||||
|
||||
describe('retry', () => {
|
||||
afterEach(() => {
|
||||
nock.cleanAll()
|
||||
})
|
||||
|
||||
describe('for /versions/all API', () => {
|
||||
test('retry three times', async () => {
|
||||
nock('https://services.gradle.org', {allowUnmocked: true})
|
||||
.get('/versions/all')
|
||||
.times(3)
|
||||
.replyWithError({
|
||||
message: 'connect ECONNREFUSED 104.18.191.9:443',
|
||||
code: 'ECONNREFUSED'
|
||||
})
|
||||
|
||||
const validChecksums = await checksums.fetchUnknownChecksums(false, new checksums.WrapperChecksums)
|
||||
expect(validChecksums.size).toBeGreaterThan(10)
|
||||
nock.isDone()
|
||||
})
|
||||
})
|
||||
})
|
||||
Binary file not shown.
12
sources/test/jest/wrapper-validation/find.test.ts
Normal file
12
sources/test/jest/wrapper-validation/find.test.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import * as path from 'path'
|
||||
import * as find from '../../../src/wrapper-validation/find'
|
||||
import {expect, test} from '@jest/globals'
|
||||
|
||||
test('finds test data wrapper jars', async () => {
|
||||
const repoRoot = path.resolve('./test/jest/wrapper-validation')
|
||||
const wrapperJars = await find.findWrapperJars(repoRoot)
|
||||
expect(wrapperJars.length).toBe(3)
|
||||
expect(wrapperJars).toContain('data/valid/gradle-wrapper.jar')
|
||||
expect(wrapperJars).toContain('data/invalid/gradle-wrapper.jar')
|
||||
expect(wrapperJars).toContain('data/invalid/gradlе-wrapper.jar') // homoglyph
|
||||
})
|
||||
12
sources/test/jest/wrapper-validation/hash.test.ts
Normal file
12
sources/test/jest/wrapper-validation/hash.test.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import * as path from 'path'
|
||||
import * as hash from '../../../src/wrapper-validation/hash'
|
||||
import {expect, test} from '@jest/globals'
|
||||
|
||||
test('can sha256 files', async () => {
|
||||
const sha = await hash.sha256File(
|
||||
path.resolve('test/jest/wrapper-validation/data/invalid/gradle-wrapper.jar')
|
||||
)
|
||||
expect(sha).toEqual(
|
||||
'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'
|
||||
)
|
||||
})
|
||||
116
sources/test/jest/wrapper-validation/validate.test.ts
Normal file
116
sources/test/jest/wrapper-validation/validate.test.ts
Normal file
@@ -0,0 +1,116 @@
|
||||
import * as path from 'path'
|
||||
import * as fs from 'fs'
|
||||
import * as validate from '../../../src/wrapper-validation/validate'
|
||||
import {expect, test, jest} from '@jest/globals'
|
||||
import { WrapperChecksums } from '../../../src/wrapper-validation/checksums'
|
||||
import { ChecksumCache } from '../../../src/wrapper-validation/cache'
|
||||
import exp from 'constants'
|
||||
|
||||
jest.setTimeout(30000)
|
||||
|
||||
const baseDir = path.resolve('./test/jest/wrapper-validation')
|
||||
const tmpDir = path.resolve('./test/jest/tmp')
|
||||
|
||||
test('succeeds if all found wrapper jars are valid', async () => {
|
||||
const result = await validate.findInvalidWrapperJars(baseDir, false, [
|
||||
'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'
|
||||
])
|
||||
|
||||
expect(result.isValid()).toBe(true)
|
||||
// Only hardcoded and explicitly allowed checksums should have been used
|
||||
expect(result.fetchedChecksums).toBe(false)
|
||||
|
||||
expect(result.toDisplayString()).toBe(
|
||||
'✓ Found known Gradle Wrapper JAR files:\n' +
|
||||
' e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 data/invalid/gradle-wrapper.jar\n' +
|
||||
' e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 data/invalid/gradlе-wrapper.jar\n' + // homoglyph
|
||||
' 3888c76faa032ea8394b8a54e04ce2227ab1f4be64f65d450f8509fe112d38ce data/valid/gradle-wrapper.jar'
|
||||
)
|
||||
})
|
||||
|
||||
test('succeeds if all found wrapper jars are previously valid', async () => {
|
||||
const result = await validate.findInvalidWrapperJars(baseDir, false, [], [
|
||||
'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855',
|
||||
'3888c76faa032ea8394b8a54e04ce2227ab1f4be64f65d450f8509fe112d38ce'
|
||||
])
|
||||
|
||||
expect(result.isValid()).toBe(true)
|
||||
// Only hardcoded and explicitly allowed checksums should have been used
|
||||
expect(result.fetchedChecksums).toBe(false)
|
||||
|
||||
expect(result.toDisplayString()).toBe(
|
||||
'✓ Found known Gradle Wrapper JAR files:\n' +
|
||||
' e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 data/invalid/gradle-wrapper.jar\n' +
|
||||
' e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 data/invalid/gradlе-wrapper.jar\n' + // homoglyph
|
||||
' 3888c76faa032ea8394b8a54e04ce2227ab1f4be64f65d450f8509fe112d38ce data/valid/gradle-wrapper.jar'
|
||||
)
|
||||
})
|
||||
|
||||
test('succeeds if all found wrapper jars are valid (and checksums are fetched from Gradle API)', async () => {
|
||||
const knownValidChecksums = new WrapperChecksums()
|
||||
const result = await validate.findInvalidWrapperJars(
|
||||
baseDir,
|
||||
false,
|
||||
['e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'],
|
||||
[],
|
||||
knownValidChecksums
|
||||
)
|
||||
console.log(`fetchedChecksums = ${result.fetchedChecksums}`)
|
||||
|
||||
expect(result.isValid()).toBe(true)
|
||||
// Should have fetched checksums because no known checksums were provided
|
||||
expect(result.fetchedChecksums).toBe(true)
|
||||
|
||||
expect(result.toDisplayString()).toBe(
|
||||
'✓ Found known Gradle Wrapper JAR files:\n' +
|
||||
' e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 data/invalid/gradle-wrapper.jar\n' +
|
||||
' e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 data/invalid/gradlе-wrapper.jar\n' + // homoglyph
|
||||
' 3888c76faa032ea8394b8a54e04ce2227ab1f4be64f65d450f8509fe112d38ce data/valid/gradle-wrapper.jar'
|
||||
)
|
||||
})
|
||||
|
||||
test('fails if invalid wrapper jars are found', async () => {
|
||||
const result = await validate.findInvalidWrapperJars(baseDir, false, [])
|
||||
|
||||
expect(result.isValid()).toBe(false)
|
||||
|
||||
expect(result.valid).toEqual([
|
||||
new validate.WrapperJar(
|
||||
'data/valid/gradle-wrapper.jar',
|
||||
'3888c76faa032ea8394b8a54e04ce2227ab1f4be64f65d450f8509fe112d38ce'
|
||||
)
|
||||
])
|
||||
|
||||
expect(result.invalid).toEqual([
|
||||
new validate.WrapperJar(
|
||||
'data/invalid/gradle-wrapper.jar',
|
||||
'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'
|
||||
),
|
||||
new validate.WrapperJar(
|
||||
'data/invalid/gradlе-wrapper.jar', // homoglyph
|
||||
'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'
|
||||
)
|
||||
])
|
||||
|
||||
expect(result.toDisplayString()).toBe(
|
||||
'✗ Found unknown Gradle Wrapper JAR files:\n' +
|
||||
' e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 data/invalid/gradle-wrapper.jar\n' +
|
||||
' e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 data/invalid/gradlе-wrapper.jar\n' + // homoglyph
|
||||
'✓ Found known Gradle Wrapper JAR files:\n' +
|
||||
' 3888c76faa032ea8394b8a54e04ce2227ab1f4be64f65d450f8509fe112d38ce data/valid/gradle-wrapper.jar'
|
||||
)
|
||||
})
|
||||
|
||||
test('can save and load checksums', async () => {
|
||||
const cacheDir = path.join(tmpDir, 'wrapper-validation-cache')
|
||||
fs.rmSync(cacheDir, {recursive: true, force: true})
|
||||
|
||||
const checksumCache = new ChecksumCache(cacheDir)
|
||||
|
||||
expect(checksumCache.load()).toEqual([])
|
||||
|
||||
checksumCache.save(['123', '456'])
|
||||
|
||||
expect(checksumCache.load()).toEqual(['123', '456'])
|
||||
expect(fs.existsSync(cacheDir)).toBe(true)
|
||||
})
|
||||
Reference in New Issue
Block a user