-
Notifications
You must be signed in to change notification settings - Fork 202
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add basic autocompletion tests for project autocompletion. The current tests are basic and will be expanded in the future (contributions are welcome). Fixes #426
- Loading branch information
Showing
3 changed files
with
79 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package bloop | ||
|
||
import bloop.cli.{CliOptions, Commands, completion} | ||
import bloop.engine.Run | ||
import bloop.logging.RecordingLogger | ||
import bloop.util.TestUtil | ||
import org.junit.Test | ||
|
||
class AutoCompleteSpec { | ||
@Test | ||
def testAutoCompletionForProjects: Unit = { | ||
val structure = Map("A" -> Map[String, String](), "B" -> Map[String, String]()) | ||
val deps = Map("B" -> Set("A")) | ||
val logger = new RecordingLogger(ansiCodesSupported = false) | ||
|
||
TestUtil.testState(structure, deps, userLogger = Some(logger)) { state0 => | ||
val cliOptions = CliOptions.default.copy(common = state0.commonOptions) | ||
val test1 = Commands.Autocomplete( | ||
cliOptions, | ||
completion.Mode.Commands, | ||
completion.ZshFormat, | ||
None, | ||
None | ||
) | ||
|
||
val test2 = Commands.Autocomplete( | ||
cliOptions, | ||
completion.Mode.ProjectBoundCommands, | ||
completion.ZshFormat, | ||
None, | ||
None | ||
) | ||
|
||
// Simulate basic 'bloop compile <autocomplete>' | ||
val test3 = Commands.Autocomplete( | ||
cliOptions, | ||
completion.Mode.Projects, | ||
completion.ZshFormat, | ||
Some("compile"), | ||
None | ||
) | ||
|
||
// Simulate 'bloop compile A <autocomplete>', happens when we want to add multiple projects | ||
val test4 = Commands.Autocomplete( | ||
cliOptions, | ||
completion.Mode.Projects, | ||
completion.ZshFormat, | ||
Some("compile"), | ||
Some("A") | ||
) | ||
|
||
val action = Run(test1, Run(test2, Run(test3, Run(test4)))) | ||
val state1 = TestUtil.blockingExecute(action, state0) | ||
TestUtil.assertNoDiff( | ||
""" | ||
|about | ||
|autocomplete | ||
|bsp | ||
|clean | ||
|compile | ||
|configure | ||
|console | ||
|help | ||
|link | ||
|projects | ||
|run | ||
|test | ||
|clean compile console link run test | ||
|A | ||
|B | ||
|A | ||
|B | ||
""".stripMargin, | ||
logger.infos.mkString(System.lineSeparator) | ||
) | ||
} | ||
} | ||
} |