This commit is contained in:
Kirill Chernyshov 2019-10-07 14:52:22 +02:00
parent 8bb494502e
commit 3ad33f1c8c
No known key found for this signature in database
GPG Key ID: 425B3AB78FBCFBDB
3 changed files with 69 additions and 62 deletions

View File

@ -16,6 +16,11 @@ jobs:
with:
version: 12.x
- name: Setup java
uses: actions/setup-java@v1
with:
java-version: 12.0.2
- name: npm install
run: npm install

View File

@ -48,6 +48,7 @@ describe('leiningen tests', () => {
expect(fs.existsSync(`${clojureDir}.complete`)).toBe(true);
expect(fs.existsSync(path.join(clojureDir, 'bin', 'lein'))).toBe(true);
await exec.exec('lein version');
}, 100000);
it('Uses version of leiningen installed in cache', async () => {

View File

@ -1,82 +1,83 @@
import io = require('@actions/io');
import exec = require('@actions/exec');
import os = require('os');
import fs = require('fs');
import path = require('path');
const toolDir = path.join(__dirname, 'runner', 'tools', 'tdeps');
const tempDir = path.join(__dirname, 'runner', 'temp', 'tdeps');
const IS_WINDOWS = process.platform === 'win32';
process.env['RUNNER_TOOL_CACHE'] = toolDir;
process.env['RUNNER_TEMP'] = tempDir;
import * as tdeps from '../src/tdeps';
describe('tdeps tests', () => {
beforeAll(async () => {
await io.rmRF(toolDir);
await io.rmRF(tempDir);
}, 300000);
beforeAll(async () => {
await io.rmRF(toolDir);
await io.rmRF(tempDir);
}, 300000);
afterAll(async () => {
try {
await io.rmRF(toolDir);
await io.rmRF(tempDir);
} catch {
console.log('Failed to remove test directories');
}
}, 100000);
afterAll(async () => {
try {
await io.rmRF(toolDir);
await io.rmRF(tempDir);
} catch {
console.log('Failed to remove test directories');
}
}, 100000);
it('Throws if invalid version', async () => {
let thrown = false;
try {
await tdeps.setup('1000');
} catch {
thrown = true;
}
expect(thrown).toBe(true);
});
it('Throws if invalid version', async () => {
let thrown = false;
try {
await tdeps.setup('1000');
} catch {
thrown = true;
}
expect(thrown).toBe(true);
});
it('Install clojure tools deps with normal version', async () => {
await tdeps.setup('1.10.1.469');
const clojureDir = path.join(
toolDir,
'ClojureToolsDeps',
'1.10.1-469',
os.arch()
);
it('Install clojure tools deps with normal version', async () => {
await tdeps.setup('1.10.1.469');
const clojureDir = path.join(
toolDir,
'ClojureToolsDeps',
'1.10.1-469',
os.arch()
);
expect(fs.existsSync(`${clojureDir}.complete`)).toBe(true);
expect(fs.existsSync(path.join(clojureDir, 'bin', 'clojure'))).toBe(true);
}, 100000);
expect(fs.existsSync(`${clojureDir}.complete`)).toBe(true);
expect(fs.existsSync(path.join(clojureDir, 'bin', 'clojure'))).toBe(true);
exec.exec('clj -Sdescribe');
}, 100000);
it('Uses version of clojure tools-deps installed in cache', async () => {
const clojureDir: string = path.join(
toolDir,
'ClojureToolsDeps',
'1.10.1-469',
os.arch()
);
await io.mkdirP(clojureDir);
fs.writeFileSync(`${clojureDir}.complete`, 'hello');
await tdeps.setup('1.10.1.469');
return;
});
it('Uses version of clojure tools-deps installed in cache', async () => {
const clojureDir: string = path.join(
toolDir,
'ClojureToolsDeps',
'1.10.1-469',
os.arch()
);
await io.mkdirP(clojureDir);
fs.writeFileSync(`${clojureDir}.complete`, 'hello');
await tdeps.setup('1.10.1.469');
return;
});
it('Doesnt use version of clojure that was only partially installed in cache', async () => {
const clojureDir: string = path.join(
toolDir,
'ClojureToolsDeps',
'1.10.1-469',
os.arch()
);
await io.mkdirP(clojureDir);
let thrown = false;
try {
await tdeps.setup('1000');
} catch {
thrown = true;
}
expect(thrown).toBe(true);
return;
});
it('Doesnt use version of clojure that was only partially installed in cache', async () => {
const clojureDir: string = path.join(
toolDir,
'ClojureToolsDeps',
'1.10.1-469',
os.arch()
);
await io.mkdirP(clojureDir);
let thrown = false;
try {
await tdeps.setup('1000');
} catch {
thrown = true;
}
expect(thrown).toBe(true);
return;
});
});