-
Notifications
You must be signed in to change notification settings - Fork 39
/
coverage.ts
33 lines (25 loc) · 967 Bytes
/
coverage.ts
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
import { Command, flags } from '@oclif/command';
import { execSync } from 'child_process';
import * as path from 'path';
import * as fs from 'fs';
export default class Test extends Command {
static description = 'Runs unit tests for a contract directory.';
static examples = [
'$ terrain test:coverage',
'$ terrain test:coverage counter',
];
static flags = { };
static args = [{ name: 'contract-name' }];
async run() {
const { args, flags } = this.parse(Test);
const contractName = args['contract-name'];
if (contractName) {
process.chdir(path.join('contracts', contractName));
}
const exists = fs.existsSync('./Cargo.toml');
if (!exists) {
throw Error(`Folder '${process.cwd()}' does not contain a smart contract.\nTip: Use another path or contract name`);
}
execSync(`docker run --security-opt seccomp=unconfined -v "${process.cwd()}:/volume" xd009642/tarpaulin`, { stdio: 'inherit' });
}
}