summaryrefslogtreecommitdiff
path: root/test/test_gradle_build_classpath_command.vader
blob: 491c2bf0abc5163948cea9c6e4de27eb7d0b5465 (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
Before:
  Save $PATH
  Save $PATHEXT

  let $PATHEXT = '.'

  call ale#test#SetDirectory('/testplugin/test')
  runtime ale_linters/kotlin/kotlinc.vim

  let g:command_tail = ' -I ' . ale#Escape(ale#gradle#GetInitPath())
  \   . ' -q printClasspath'

  let g:gradle_init_path = ale#path#Simplify(g:dir . '../../autoload/ale/gradle/init.gradle')

After:
  Restore

  unlet! g:gradle_init_path
  unlet! g:command_tail

  call ale#test#RestoreDirectory()
  call ale#linter#Reset()

Execute(Should return 'gradlew' command if project includes gradle wapper):
  call ale#test#SetFilename('gradle-test-files/wrapped-project/src/main/kotlin/dummy.kt')

  AssertEqual
  \ ale#path#CdString(ale#path#Simplify(g:dir . '/gradle-test-files/wrapped-project'))
  \   . ale#Escape(ale#path#Simplify(g:dir . '/gradle-test-files/wrapped-project/gradlew'))
  \   . g:command_tail,
  \ ale#gradle#BuildClasspathCommand(bufnr(''))

Execute(Should return 'gradle' command if project does not include gradle wapper):
  call ale#test#SetFilename('gradle-test-files/unwrapped-project/src/main/kotlin/dummy.kt')
  let $PATH .= (has('win32') ? ';' : ':')
  \ . ale#path#Simplify(g:dir . '/gradle-test-files')

  AssertEqual
  \ ale#path#CdString(ale#path#Simplify(g:dir . '/gradle-test-files/unwrapped-project'))
  \   . ale#Escape('gradle')
  \   . g:command_tail,
  \ ale#gradle#BuildClasspathCommand(bufnr(''))

Execute(Should return empty string if gradle cannot be executed):
  call ale#test#SetFilename('gradle-test-files/non-gradle-project/src/main/kotlin/dummy.kt')

  AssertEqual
  \ '',
  \ ale#gradle#BuildClasspathCommand(bufnr(''))