Skip to content

Commit

Permalink
Auto-completion #75 : expect-based test for auto-completion
Browse files Browse the repository at this point in the history
  • Loading branch information
xonixx committed Feb 11, 2022
1 parent 2745721 commit 4f1ee2d
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 17 deletions.
17 changes: 0 additions & 17 deletions tests/test_autocomplete/test1.expect.txt

This file was deleted.

2 changes: 2 additions & 0 deletions tests/test_completion/Makesurefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

@goal goalAaa
2 changes: 2 additions & 0 deletions tests/test_completion/Makesurefile with spaces.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

@goal goalCcc
2 changes: 2 additions & 0 deletions tests/test_completion/Makesurefile.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

@goal goalBbb
1 change: 1 addition & 0 deletions tests/test_completion/makesure
26 changes: 26 additions & 0 deletions tests/test_completion/test1.expect.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

set timeout 1

proc checkCompletion { flagPrefix expectedFlag } {
spawn env PS1=bash#\ bash --norc
sleep 0.1
send " . ../../completion.bash\r"
send " ./makesure $flagPrefix\t"

expect {
"$expectedFlag" { puts "\nSUCCESS" }
timeout { puts "\nERROR"; exit 1 }
}
}

checkCompletion "--sel" "selfupdate"
checkCompletion "--res" "resolved"
checkCompletion "goal" "goalAaa"
checkCompletion "-f Makesurefile.txt goal" "goalBbb"
checkCompletion "--file 'Makesurefile with spaces.txt' goal" "goalCcc"
checkCompletion "--file Makesurefile\\ with\\ spaces.txt goal" "goalCcc"

checkCompletion "-f Makesurefile.t" "Makesurefile.txt"
checkCompletion "--file Makesurefile.t" "Makesurefile.txt"

checkCompletion "--file Makesurefile\\ w" "spaces.txt"

0 comments on commit 4f1ee2d

Please sign in to comment.