Skip to content

Commit

Permalink
picocli fish completion: run fish dejagnu tests from java
Browse files Browse the repository at this point in the history
  • Loading branch information
serg-v committed Feb 25, 2023
1 parent 2f75728 commit 3caf4d7
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 8 deletions.
3 changes: 1 addition & 2 deletions src/test/dejagnu.fishtests/completion/basicExample.exp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,5 @@ run_completion_test $cmd $test $candidates

set cmd "basicExample --timeUnit="
set test "Tab should show time unit enum values for '$cmd'"
#set candidates "1 2 3"
set candidates "\u2026timeUnit=DAYS \u2026timeUnit=MICROSECONDS \u2026timeUnit=MINUTES \u2026timeUnit=SECONDS\r\n\u2026timeUnit=HOURS \u2026timeUnit=MILLISECONDS \u2026timeUnit=NANOSECONDS "
set candidates ".*timeUnit=DAYS.*timeUnit=MICROSECONDS.*timeUnit=MINUTES.*timeUnit=SECONDS.*timeUnit=HOURS.*timeUnit=MILLISECONDS.*timeUnit=NANOSECONDS.*"
run_completion_test $cmd $test $candidates
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ run_completion_test $cmd $test $candidates
# set cmd "picocompletion-demo sub1 "
# set test "Tab should not show completions for '${cmd}'"

# there is completion from root level
set cmd "picocompletion-demo sub1 -"
set test "Tab should show sub1 options for '${cmd}'"
set candidates "--candidates.*--candidates=.*--num.*--str.*"
Expand Down
4 changes: 4 additions & 0 deletions src/test/dejagnu.fishtests/lib/completion.exp
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
exp_spawn fish --no-config
expect -re "(.+>)"

# Set terminal size to my notebook's resolution
send "stty rows 53 cols 190\r"
expect -re "(.+>)"

source $::srcdir/lib/library.exp
4 changes: 2 additions & 2 deletions src/test/dejagnu.fishtests/lib/library.exp
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
proc run_completion_test {cmd test candidates} {
exp_internal 1
send "${cmd}\t"
expect {
-re "(\n${candidates}\u001b)" { pass $test }
timeout { fail $test }
}
puts "###Output"
puts "$expect_out(1,string)"
exp_internal 0
send "\x03"
expect ">"
}
2 changes: 2 additions & 0 deletions src/test/dejagnu.fishtests/runCompletion
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
runtest --outdir log --tool completion
14 changes: 11 additions & 3 deletions src/test/java/picocli/AutoCompleteDejaGnuTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,19 @@ public void tryRunDejaGnuCompletionTests() throws Exception {

// ignores test if dejagnu not installed
org.junit.Assume.assumeTrue("dejagnu must be installed to run this test", isDejaGnuInstalled());
runDejaGnuCompletionTests();
runDejaGnuCompletionTests("src/test/dejagnu.tests");
}

private void runDejaGnuCompletionTests() throws Exception {
final File testDir = new File("src/test/dejagnu.tests");
@Test
public void tryRunFishDejaGnuCompletionTests() throws Exception {
// ignores test if dejagnu not installed
org.junit.Assume.assumeTrue("dejagnu must be installed to run this test", isDejaGnuInstalled());
runDejaGnuCompletionTests("src/test/dejagnu.fishtests");
}


private void runDejaGnuCompletionTests(String pathname) throws Exception {
final File testDir = new File(pathname);
assertTrue(testDir.getAbsolutePath() + " should exist", testDir.exists());
File runCompletionScript = new File(testDir, "runCompletion");
assertTrue(runCompletionScript.getAbsolutePath() + " should exist", runCompletionScript.exists());
Expand Down

0 comments on commit 3caf4d7

Please sign in to comment.