@@ -8,6 +8,8 @@ const { lint } = require('../lib/main.js').provideLinter();
8
8
9
9
const cleanPath = path . join ( __dirname , 'fixtures' , 'clean.sh' ) ;
10
10
const badPath = path . join ( __dirname , 'fixtures' , 'bad.sh' ) ;
11
+ const sourceFileRelativePath = path . join ( __dirname , 'fixtures' , 'source_directive' , 'file_relative.sh' ) ;
12
+ const sourceProjectRelativePath = path . join ( __dirname , 'fixtures' , 'source_directive' , 'project_relative.sh' ) ;
11
13
12
14
describe ( 'The ShellCheck provider for Linter' , ( ) => {
13
15
beforeEach ( async ( ) => {
@@ -44,4 +46,41 @@ describe('The ShellCheck provider for Linter', () => {
44
46
expect ( messages [ 0 ] . filePath ) . toBe ( badPath ) ;
45
47
expect ( messages [ 0 ] . range ) . toEqual ( [ [ 0 , 0 ] , [ 0 , 4 ] ] ) ;
46
48
} ) ;
49
+
50
+ describe ( 'implements useProjectCwd and' , ( ) => {
51
+ beforeEach ( async ( ) => {
52
+ atom . config . set ( 'linter-shellcheck.userParameters' , '-x' ) ;
53
+ atom . config . set ( 'linter-shellcheck.enableNotice' , true ) ;
54
+ } ) ;
55
+
56
+ it ( 'uses file-relative source= directives by default' , async ( ) => {
57
+ atom . config . set ( 'linter-shellcheck.useProjectCwd' , false ) ;
58
+ const editor = await atom . workspace . open ( sourceFileRelativePath ) ;
59
+ const messages = await lint ( editor ) ;
60
+ expect ( messages . length ) . toBe ( 0 ) ;
61
+ } ) ;
62
+
63
+ it ( 'errors for file-relative source= path with useProjectCwd = true' , async ( ) => {
64
+ atom . config . set ( 'linter-shellcheck.useProjectCwd' , true ) ;
65
+ const editor = await atom . workspace . open ( sourceFileRelativePath ) ;
66
+ const messages = await lint ( editor ) ;
67
+ expect ( messages . length ) . toBe ( 1 ) ;
68
+ expect ( messages [ 0 ] . html ) . toMatch ( / o p e n B i n a r y F i l e : d o e s n o t e x i s t / ) ;
69
+ } ) ;
70
+
71
+ it ( 'uses project-relative source= directives via setting (based at fixtures/)' , async ( ) => {
72
+ atom . config . set ( 'linter-shellcheck.useProjectCwd' , true ) ;
73
+ const editor = await atom . workspace . open ( sourceProjectRelativePath ) ;
74
+ const messages = await lint ( editor ) ;
75
+ expect ( messages . length ) . toBe ( 0 ) ;
76
+ } ) ;
77
+
78
+ it ( 'errors for project-relative source= path with useProjectCwd = false (based at fixtures/)' , async ( ) => {
79
+ atom . config . set ( 'linter-shellcheck.useProjectCwd' , false ) ;
80
+ const editor = await atom . workspace . open ( sourceProjectRelativePath ) ;
81
+ const messages = await lint ( editor ) ;
82
+ expect ( messages . length ) . toBe ( 1 ) ;
83
+ expect ( messages [ 0 ] . html ) . toMatch ( / o p e n B i n a r y F i l e : d o e s n o t e x i s t / ) ;
84
+ } ) ;
85
+ } ) ;
47
86
} ) ;
0 commit comments