Skip to content
This repository was archived by the owner on Mar 13, 2026. It is now read-only.

Commit 0e95b1e

Browse files
authored
Stricter interactive test (#19)
Previously an unmatched expect line would not cause an error, but would wait for a timeout before proceeding. This change makes timeouts into errors. Also fixes an outdated expect line that was not causing an error due to this reason. Signed-off-by: Stephen Sherratt <stephen@sherra.tt>
1 parent 7c5dba3 commit 0e95b1e

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

test_interactive.tcl

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,16 @@ expect {
2525
# enter the path to the temporary directory:
2626
expect "> "
2727
send "$tmp\r"
28-
expect "Dune successfully installed to $tmp!"
28+
expect {
29+
timeout { exit 1 }
30+
"Dune successfully installed to $tmp!"
31+
}
2932

3033
# Now we're at the prompt for which shell config file to use.
31-
expect "Enter the absolute path of your bash config file or leave blank for default"
34+
expect {
35+
timeout { exit 1 }
36+
"Enter the absolute path of your shell config file or leave blank for default"
37+
}
3238
expect "> "
3339

3440
# Try sending an invalid value first to exercise input validation:
@@ -39,13 +45,19 @@ expect {
3945
}
4046
# Now we're back at the prompt for which shell config file to use. This time
4147
# enter a bashrc file in our temporary directory.
42-
expect "Enter the absolute path of your bash config file or leave blank for default"
48+
expect {
49+
timeout { exit 1 }
50+
"Enter the absolute path of your shell config file or leave blank for default"
51+
}
4352
expect "> "
4453
send "$tmp/bashrc\r"
4554

4655
# Now we're at the prompt for whether or not to update the shell config. Try
4756
# entering something invalid first to exercise input validation:
48-
expect "Would you like these lines to be appended to $tmp/bashrc?"
57+
expect {
58+
timeout { exit 1 }
59+
"Would you like these lines to be appended to $tmp/bashrc?"
60+
}
4961
send "foo\r"
5062
expect {
5163
timeout { exit 1 }
@@ -54,7 +66,10 @@ expect {
5466

5567
# Now we're back at the prompt for whether or not to update the shell config.
5668
# This time enter "y".
57-
expect "Would you like these lines to be appended to $tmp/bashrc?"
69+
expect {
70+
timeout { exit 1 }
71+
"Would you like these lines to be appended to $tmp/bashrc?"
72+
}
5873
send "y\r"
5974

6075
expect "This installer will now exit."
@@ -66,6 +81,7 @@ expect {
6681
"Unexpected contents of shell config!"
6782
exit 1
6883
}
84+
timeout { exit 1 }
6985
"# BEGIN configuration from Dune installer"
7086
"# END configuration from Dune installer"
7187
}

0 commit comments

Comments
 (0)