This repository was archived by the owner on Mar 13, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_interactive.tcl
More file actions
executable file
·87 lines (76 loc) · 2.29 KB
/
test_interactive.tcl
File metadata and controls
executable file
·87 lines (76 loc) · 2.29 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/usr/bin/env expect
# Expect script for interactively running the installation script, exercising
# input validation for interactive prompts and testing that the modifications
# to the shell config are what we expect.
set timeout 10
# Dune will be installed to this temporary directory.
set tmp [exec mktemp -d]
# Run the install script, forcing it to assume bash is the current shell for
# portability.
spawn ./install.sh 3.19.1 --shell bash
# The prompt for where dune will be installed. Try entering an invalid choice
# to exercise input validation:
expect "> "
send "foo\r"
expect {
timeout { exit 1 }
"Unrecognized choice: foo"
}
# Now we're back at the prompt for where dune will be installed. This time
# enter the path to the temporary directory:
expect "> "
send "$tmp\r"
expect {
timeout { exit 1 }
"Dune successfully installed to $tmp!"
}
# Now we're at the prompt for which shell config file to use.
expect {
timeout { exit 1 }
"Enter the absolute path of your shell config file or leave blank for default"
}
expect "> "
# Try sending an invalid value first to exercise input validation:
send "foo\r"
expect {
timeout { exit 1 }
"Not an absolute path: foo"
}
# Now we're back at the prompt for which shell config file to use. This time
# enter a bashrc file in our temporary directory.
expect {
timeout { exit 1 }
"Enter the absolute path of your shell config file or leave blank for default"
}
expect "> "
send "$tmp/bashrc\r"
# Now we're at the prompt for whether or not to update the shell config. Try
# entering something invalid first to exercise input validation:
expect {
timeout { exit 1 }
"Would you like these lines to be appended to $tmp/bashrc?"
}
send "foo\r"
expect {
timeout { exit 1 }
"Please enter y or n."
}
# Now we're back at the prompt for whether or not to update the shell config.
# This time enter "y".
expect {
timeout { exit 1 }
"Would you like these lines to be appended to $tmp/bashrc?"
}
send "y\r"
expect "This installer will now exit."
# Now test that the generated bashrc contains what we expect:
spawn cat $tmp/bashrc
expect {
eof {
"Unexpected contents of shell config!"
exit 1
}
timeout { exit 1 }
"# BEGIN configuration from Dune installer"
"# END configuration from Dune installer"
}