forked from elixir-lsp/vscode-elixir-ls
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrunTestFromCodeLens.ts
More file actions
39 lines (30 loc) · 972 Bytes
/
runTestFromCodeLens.ts
File metadata and controls
39 lines (30 loc) · 972 Bytes
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
34
35
36
37
38
39
import { window } from "vscode";
type RunArgs = {
filePath: string,
describe: string | null,
testName?: string,
module?: string
}
export default function runFromCodeLens(args: RunArgs): void {
const elixirLsTerminal =
window.terminals.find(terminal => terminal.name == "ElixirLS") || window.createTerminal("ElixirLS");
elixirLsTerminal.show()
elixirLsTerminal.sendText('clear')
elixirLsTerminal.sendText(buildTestCommand(args));
}
function buildTestCommand(args: RunArgs): string {
const testFilter = buildTestInclude(args.describe, args.testName, args.module)
return `mix test --exclude test --include "${testFilter}" ${args.filePath}`
}
function buildTestInclude(describe: string | null, testName?: string, module?: string) {
if (module) {
return `module:${module}`
}
if (!testName) {
return `describe:${describe}`
}
if (describe) {
return `test:test ${describe} ${testName}`
}
return `test:test ${testName}`
}