Skip to content
This repository was archived by the owner on Aug 7, 2023. It is now read-only.

Commit 1980593

Browse files
Merge pull request #95 from mauricerkelly/improve-unit-testing
Improve unit testing
2 parents 6c01835 + d14e02a commit 1980593

File tree

11 files changed

+187
-47
lines changed

11 files changed

+187
-47
lines changed

lib/init.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,9 +257,12 @@ const handleResult = async (compileResult, filePath) => {
257257
const errorStack = await parseError(resultString, filePath);
258258
const warningStack = await parseWarning(resultString, filePath);
259259
const legacyWarningStack = await parseLegacyWarning(resultString, filePath);
260-
return errorStack.concat(warningStack).concat(legacyWarningStack)
260+
261+
const results = errorStack.concat(warningStack).concat(legacyWarningStack)
261262
.filter(error => error !== null)
262263
.map(error => error);
264+
265+
return results;
263266
} catch (Error) {
264267
// eslint-disable-next-line no-console
265268
console.error('linter-elixirc:', Error);
@@ -310,7 +313,9 @@ const lintElixirc = async (textEditor) => {
310313

311314
const fileText = textEditor.getText();
312315
const execOpts = await getOpts(filePath);
316+
313317
const result = await exec(elixircPath, elixircArgs, execOpts);
318+
314319
// Cleanup the temp dir
315320
tempDir.removeCallback();
316321
if (textEditor.getText() !== fileText) {
@@ -324,6 +329,7 @@ const lintMix = async (textEditor) => {
324329
const filePath = textEditor.getPath();
325330
const fileText = textEditor.getText();
326331
const execOpts = await getOpts(filePath);
332+
327333
const result = await exec(mixPath, ['compile'], execOpts);
328334
if (textEditor.getText() !== fileText) {
329335
// File contents have changed since the run was triggered, don't update messages

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@
5252
"devDependencies": {
5353
"eslint": "^3.13.0",
5454
"eslint-config-airbnb-base": "^11.0.1",
55-
"eslint-plugin-import": "^2.2.0"
55+
"eslint-plugin-import": "^2.2.0",
56+
"fs-extra": "^3.0.1"
5657
},
5758
"eslintConfig": {
5859
"extends": "airbnb-base",
File renamed without changes.
File renamed without changes.

spec/fixtures/elixirc/script.exs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
defmodule Script do
2+
defp simple_function do
3+
:ok
4+
end
5+
end
File renamed without changes.

spec/fixtures/proj/lib/proj.ex renamed to spec/fixtures/elixirc/warning.ex

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,16 @@ defmodule Proj do
1818
end
1919

2020
def handle_call({:get, key}, _caller, state) do
21+
prepare_for_call
2122
{:reply, Map.get(state, key), state}
2223
end
2324

2425
def handle_cast({:put, key, val}, state) do
2526
{:noreply, Map.put(state, key, val), state}
2627
end
2728

29+
def prepare_for_call() do
30+
:ok
31+
end
32+
2833
end
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Single line error, still mode 2
2+
defmodule Identicon do
3+
def main(input) do
4+
input
5+
|> hash_input
6+
end
7+
8+
def has_input(input) do
9+
hex = :crypto.has(:md5, input)
10+
|> :binary.bin_to_list
11+
12+
%Identicon.Image{hex: hex}
13+
end
14+
end

spec/fixtures/mix-proj/lib/script.exs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
defmodule Script do
2+
defp simple_function do
3+
:ok
4+
end
5+
end

spec/fixtures/proj/mix.exs renamed to spec/fixtures/mix-proj/mix.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ defmodule Proj.Mixfile do
77
elixir: "~> 1.4",
88
build_embedded: Mix.env == :prod,
99
start_permanent: Mix.env == :prod,
10-
deps: deps]
10+
deps: deps()]
1111
end
1212

1313
# Configuration for the OTP application

0 commit comments

Comments
 (0)