diff --git a/test/handler/test_tslint_handler.vader b/test/handler/test_tslint_handler.vader index 4c551dc..bbaef83 100644 --- a/test/handler/test_tslint_handler.vader +++ b/test/handler/test_tslint_handler.vader @@ -12,6 +12,9 @@ After: Restore unlet! b:ale_typescript_tslint_ignore_empty_files + unlet! b:relative_to_root + unlet! b:tempname_suffix + unlet! b:relative_tempname call ale#test#RestoreDirectory() call ale#linter#Reset() @@ -282,29 +285,31 @@ Execute(The tslint handler should not report no-implicit-dependencies errors): \ }])]) Execute(The tslint handler should set filename keys for temporary files): - if !has('win32') - " The temporay filename below is hacked into being a relative path so we can - " test that we resolve the temporary filename first. - AssertEqual - \ [ - \ {'lnum': 47, 'col': 1, 'code': 'curly', 'end_lnum': 47, 'type': 'E', 'end_col': 26, 'text': 'if statements must be braced'}, - \ ], - \ ale_linters#typescript#tslint#Handle(bufnr(''), [json_encode([ - \ { - \ 'endPosition': { - \ 'character':25, - \ 'line':46, - \ 'position':1383, - \ }, - \ 'failure': 'if statements must be braced', - \ 'name': substitute(substitute(substitute(expand('%:p'), '[^/\\]', '', 'g'), '.', '../', 'g') . tempname(), '\([A-Z]:\\\)[A-Z]:', '\1', ''), - \ 'ruleName': 'curly', - \ 'ruleSeverity':'ERROR', - \ 'startPosition': { - \ 'character':0, - \ 'line':46, - \ 'position':1358, - \ } - \ }, - \ ])]) - endif + " The temporay filename below is hacked into being a relative path so we can + " test that we resolve the temporary filename first. + let b:relative_to_root = substitute(expand('%:p'), '\v[^/\\]*([/\\])[^/\\]*', has('win32') ? '..\' : '../', 'g') + let b:tempname_suffix = substitute(tempname(), '^\v([A-Z]:)?[/\\]', '', '') + let b:relative_tempname = b:relative_to_root . b:tempname_suffix + + AssertEqual + \ [ + \ {'lnum': 47, 'col': 1, 'code': 'curly', 'end_lnum': 47, 'type': 'E', 'end_col': 26, 'text': 'if statements must be braced'}, + \ ], + \ ale_linters#typescript#tslint#Handle(bufnr(''), [json_encode([ + \ { + \ 'endPosition': { + \ 'character':25, + \ 'line':46, + \ 'position':1383, + \ }, + \ 'failure': 'if statements must be braced', + \ 'name': b:relative_tempname, + \ 'ruleName': 'curly', + \ 'ruleSeverity':'ERROR', + \ 'startPosition': { + \ 'character':0, + \ 'line':46, + \ 'position':1358, + \ } + \ }, + \ ])])