2020-08-20 11:39:44 +02:00
|
|
|
import io = require('@actions/io')
|
|
|
|
import os = require('os')
|
|
|
|
import fs = require('fs')
|
|
|
|
import path = require('path')
|
2019-10-07 17:35:10 +02:00
|
|
|
|
2020-08-20 11:39:44 +02:00
|
|
|
const toolDir = path.join(__dirname, 'runner', 'tools', 'boot')
|
|
|
|
const tempDir = path.join(__dirname, 'runner', 'temp', 'boot')
|
2019-10-07 17:35:10 +02:00
|
|
|
|
2020-08-20 11:39:44 +02:00
|
|
|
process.env['RUNNER_TOOL_CACHE'] = toolDir
|
|
|
|
process.env['RUNNER_TEMP'] = tempDir
|
|
|
|
import * as boot from '../src/boot'
|
2019-10-07 17:35:10 +02:00
|
|
|
|
|
|
|
describe('boot tests', () => {
|
|
|
|
beforeAll(async () => {
|
2020-08-20 11:39:44 +02:00
|
|
|
await io.rmRF(toolDir)
|
|
|
|
await io.rmRF(tempDir)
|
|
|
|
}, 300000)
|
2019-10-07 17:35:10 +02:00
|
|
|
|
|
|
|
afterAll(async () => {
|
|
|
|
try {
|
2020-08-20 11:39:44 +02:00
|
|
|
await io.rmRF(toolDir)
|
|
|
|
await io.rmRF(tempDir)
|
2019-10-07 17:35:10 +02:00
|
|
|
} catch {
|
2020-08-20 11:39:44 +02:00
|
|
|
console.log('Failed to remove test directories')
|
2019-10-07 17:35:10 +02:00
|
|
|
}
|
2020-08-20 11:39:44 +02:00
|
|
|
}, 100000)
|
2019-10-07 17:35:10 +02:00
|
|
|
|
2020-08-20 11:39:44 +02:00
|
|
|
it('Throws if invalid version', async () => {
|
|
|
|
let thrown = false
|
|
|
|
try {
|
|
|
|
await boot.setup('1000')
|
|
|
|
} catch {
|
|
|
|
thrown = true
|
|
|
|
}
|
|
|
|
expect(thrown).toBe(true)
|
|
|
|
})
|
2019-10-07 17:35:10 +02:00
|
|
|
|
2020-08-20 11:39:44 +02:00
|
|
|
it('Install boot with normal version', async () => {
|
|
|
|
await boot.setup('2.8.3')
|
|
|
|
const clojureDir = path.join(toolDir, 'Boot', '2.8.3', os.arch())
|
2019-10-08 12:46:58 +02:00
|
|
|
|
2020-08-20 11:39:44 +02:00
|
|
|
expect(fs.existsSync(`${clojureDir}.complete`)).toBe(true)
|
|
|
|
expect(fs.existsSync(path.join(clojureDir, 'bin', 'boot'))).toBe(true)
|
|
|
|
}, 100000)
|
2019-10-08 12:46:58 +02:00
|
|
|
|
2020-08-20 11:39:44 +02:00
|
|
|
it('Install latest boot', async () => {
|
|
|
|
await boot.setup('latest')
|
|
|
|
const clojureDir = path.join(toolDir, 'Boot', 'latest.0.0', os.arch())
|
2019-10-07 17:35:10 +02:00
|
|
|
|
2020-08-20 11:39:44 +02:00
|
|
|
expect(fs.existsSync(`${clojureDir}.complete`)).toBe(true)
|
|
|
|
expect(fs.existsSync(path.join(clojureDir, 'bin', 'boot'))).toBe(true)
|
|
|
|
}, 100000)
|
2019-10-07 17:35:10 +02:00
|
|
|
|
2020-08-20 11:39:44 +02:00
|
|
|
it('Uses version of boot installed in cache', async () => {
|
|
|
|
const clojureDir: string = path.join(toolDir, 'Boot', '2.8.3', os.arch())
|
|
|
|
await io.mkdirP(clojureDir)
|
|
|
|
fs.writeFileSync(`${clojureDir}.complete`, 'hello')
|
|
|
|
await boot.setup('2.8.3')
|
|
|
|
return
|
|
|
|
})
|
2019-10-07 17:35:10 +02:00
|
|
|
|
2020-08-20 11:39:44 +02:00
|
|
|
it('Doesnt use version of clojure that was only partially installed in cache', async () => {
|
|
|
|
const clojureDir: string = path.join(toolDir, 'Boot', '2.8.3', os.arch())
|
|
|
|
await io.mkdirP(clojureDir)
|
|
|
|
let thrown = false
|
|
|
|
try {
|
|
|
|
await boot.setup('1000')
|
|
|
|
} catch {
|
|
|
|
thrown = true
|
|
|
|
}
|
|
|
|
expect(thrown).toBe(true)
|
|
|
|
return
|
|
|
|
})
|
|
|
|
})
|