summaryrefslogtreecommitdiff
path: root/test/handler/test_elmmake_handler.vader
blob: 8abe3295424681a4615de4545a7321b2fc19fa73 (plain)
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
Before:
  let b:tmp = has('win32') ? substitute($TMP, '\\', '\\\\', 'g') : $TMPDIR

  runtime ale_linters/elm/make.vim

After:
  unlet! b:tmp
  unlet! g:config_error_lines

  call ale#linter#Reset()

Execute(The elm make handler should parse general problems correctly):
  AssertEqual
  \ [
  \   {
  \     'lnum': 1,
  \     'type': 'E',
  \     'text': "error details\n\nstyled details"
  \   }
  \ ],
  \ ale_linters#elm#make#Handle(347, [
  \   '{
  \      "type": "error",
  \      "path": "' . b:tmp . '/Module.elm",
  \      "title": "UNKNOWN IMPORT",
  \      "message": ["error details\n\n", { "string": "styled details" }]
  \    }'
  \ ])

Execute(The elm make handler should parse compilation errors correctly):
  AssertEqual
  \ [
  \   {
  \     'lnum': 404,
  \     'col': 1,
  \     'end_lnum': 408,
  \     'end_col': 18,
  \     'type': 'E',
  \     'text': "error details 1\n\nstyled details"
  \   },
  \   {
  \     'lnum': 406,
  \     'col': 5,
  \     'end_lnum': 407,
  \     'end_col': 17,
  \     'type': 'E',
  \     'text': "error details 2",
  \   },
  \   {
  \     'lnum': 406,
  \     'col': 5,
  \     'end_lnum': 406,
  \     'end_col': 93,
  \     'type': 'E',
  \     'text': "error details 3",
  \   },
  \ ],
  \ ale_linters#elm#make#Handle(347, [
  \   '{
  \      "type": "compile-errors",
  \      "errors": [
  \        {
  \          "path": "' . b:tmp . '/Module.elm",
  \          "problems": [
  \            {
  \              "title": "TYPE MISMATCH",
  \              "message": ["error details 1\n\n", { "string": "styled details" }],
  \              "region": { "start": { "line": 404, "column": 1 }, "end": { "line": 408, "column": 18 } }
  \            },
  \            {
  \              "title": "TYPE MISMATCH",
  \              "message": ["error details 2"],
  \              "region": { "start": {"line": 406, "column": 5}, "end": {"line": 407, "column": 17 } }
  \            },
  \            {
  \              "title": "TYPE MISMATCH",
  \              "message": ["error details 3"],
  \              "region": { "start": { "line": 406, "column": 5}, "end": {"line": 406, "column": 93 } }
  \            }
  \          ]
  \        }
  \      ]
  \    }'
  \ ])

Execute(The elm make handler should handle errors in imported modules):
  AssertEqual
  \ [
  \   {
  \     'lnum': 1,
  \     'type': 'E',
  \     'text': "src/Module.elm - error details\n\nstyled details",
  \     'detail': "src/Module.elm ----------\n\nerror details\n\nstyled details"
  \   },
  \   {
  \     'lnum': 1,
  \     'type': 'E',
  \     'text': "Elm.Kernel - error details\n\nstyled details",
  \     'detail': "Elm.Kernel ----------\n\nerror details\n\nstyled details"
  \   },
  \   {
  \     'lnum': 1,
  \     'type': 'E',
  \     'text': "src/Module.elm:404 - error details\n\nstyled details",
  \     'detail': "src/Module.elm:404 ----------\n\nerror details\n\nstyled details"
  \   },
  \ ],
  \ ale_linters#elm#make#Handle(347, [
  \   '{
  \      "type": "error",
  \      "path": "src/Module.elm",
  \      "title": "UNKNOWN IMPORT",
  \      "message": ["error details\n\n", { "string": "styled details" }]
  \    }',
  \   '{
  \      "type": "error",
  \      "path": null,
  \      "title": "UNKNOWN IMPORT",
  \      "message": ["error details\n\n", { "string": "styled details" }]
  \    }',
  \   '{
  \      "type": "compile-errors",
  \      "errors": [
  \        {
  \          "path": "src/Module.elm",
  \          "problems": [
  \            {
  \              "title": "TYPE MISMATCH",
  \              "message": ["error details\n\n", { "string": "styled details" }],
  \              "region": { "start": { "line": 404, "column": 1 }, "end": { "line": 408, "column": 18 } }
  \            }
  \          ]
  \        }
  \      ]
  \    }'
  \ ])

Execute(The elm make handler should put an error on the first line if a line cannot be parsed):
  AssertEqual
  \ [
  \   {
  \     'lnum': 404,
  \     'col': 1,
  \     'end_lnum': 408,
  \     'end_col': 18,
  \     'type': 'E',
  \     'text': "error details 1\n\nstyled details"
  \   },
  \   {
  \     'lnum': 1,
  \     'type': 'E',
  \     'text': 'Not JSON',
  \     'detail': "Not JSON\nAlso not JSON",
  \   },
  \ ],
  \ ale_linters#elm#make#Handle(347, [
  \   '{
  \      "type": "compile-errors",
  \      "errors": [
  \        {
  \          "path": "' . b:tmp . '/Module.elm",
  \          "problems": [
  \            {
  \              "title": "TYPE MISMATCH",
  \              "message": ["error details 1\n\n", { "string": "styled details" }],
  \              "region": { "start": { "line": 404, "column": 1 }, "end": { "line": 408, "column": 18 } }
  \            }
  \          ]
  \        }
  \      ]
  \    }',
  \    'Not JSON',
  \    'Also not JSON',
  \ ])