-
Notifications
You must be signed in to change notification settings - Fork 170
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🧹 Add expect-based tests for interactive scripts (#389)
- Loading branch information
1 parent
bdbe8ab
commit 3ca8eb9
Showing
7 changed files
with
292 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
.turbo | ||
dist | ||
node_modules | ||
*.exp | ||
*.md | ||
*.sol | ||
*.toml | ||
|
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
*.exp | ||
*.log | ||
.eslintignore | ||
.prettierignore | ||
|
49 changes: 49 additions & 0 deletions
49
...s/devtools-evm-hardhat-test/test/task/deploy.test.expectations/deploy-all-missing-tag.exp
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,49 @@ | ||
#!/usr/bin/expect -f | ||
# | ||
# This Expect script was generated by autoexpect on Mon Feb 12 16:57:18 2024 | ||
# Expect and autoexpect were both written by Don Libes, NIST. | ||
# | ||
# Note that autoexpect does not guarantee a working script. It | ||
# necessarily has to guess about certain things. Two reasons a script | ||
# might fail are: | ||
# | ||
# 1) timing - A surprising number of programs (rn, ksh, zsh, telnet, | ||
# etc.) and devices discard or ignore keystrokes that arrive "too | ||
# quickly" after prompts. If you find your new script hanging up at | ||
# one spot, try adding a short sleep just before the previous send. | ||
# Setting "force_conservative" to 1 (see below) makes Expect do this | ||
# automatically - pausing briefly before sending each character. This | ||
# pacifies every program I know of. The -c flag makes the script do | ||
# this in the first place. The -C flag allows you to define a | ||
# character to toggle this mode off and on. | ||
|
||
set force_conservative 0 | ||
if {$force_conservative} { | ||
set send_slow {1 .1} | ||
proc send {ignore arg} { | ||
sleep .1 | ||
exp_send -s -- $arg | ||
} | ||
} | ||
|
||
|
||
set timeout 60 | ||
spawn npx hardhat lz:deploy | ||
match_max 100000 | ||
|
||
expect "Which networks would you like to deploy?" | ||
send -- "\r" | ||
|
||
expect "Which deploy script tags would you like to use?" | ||
send -- "MeNoExist" | ||
send -- "\r" | ||
|
||
expect "Will deploy 3 networks: britney, tango, vengaboys" | ||
expect "Will use deploy scripts tagged with MeNoExist" | ||
expect "Do you want to continue?" | ||
send -- "\r" | ||
|
||
expect "Deploying..." | ||
expect "Your contracts are now deployed" | ||
|
||
expect eof |
48 changes: 48 additions & 0 deletions
48
tests/devtools-evm-hardhat-test/test/task/deploy.test.expectations/deploy-all.exp
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,48 @@ | ||
#!/usr/bin/expect -f | ||
# | ||
# This Expect script was generated by autoexpect on Mon Feb 12 16:57:18 2024 | ||
# Expect and autoexpect were both written by Don Libes, NIST. | ||
# | ||
# Note that autoexpect does not guarantee a working script. It | ||
# necessarily has to guess about certain things. Two reasons a script | ||
# might fail are: | ||
# | ||
# 1) timing - A surprising number of programs (rn, ksh, zsh, telnet, | ||
# etc.) and devices discard or ignore keystrokes that arrive "too | ||
# quickly" after prompts. If you find your new script hanging up at | ||
# one spot, try adding a short sleep just before the previous send. | ||
# Setting "force_conservative" to 1 (see below) makes Expect do this | ||
# automatically - pausing briefly before sending each character. This | ||
# pacifies every program I know of. The -c flag makes the script do | ||
# this in the first place. The -C flag allows you to define a | ||
# character to toggle this mode off and on. | ||
|
||
set force_conservative 0 | ||
if {$force_conservative} { | ||
set send_slow {1 .1} | ||
proc send {ignore arg} { | ||
sleep .1 | ||
exp_send -s -- $arg | ||
} | ||
} | ||
|
||
|
||
set timeout 60 | ||
spawn npx hardhat lz:deploy | ||
match_max 100000 | ||
|
||
expect "Which networks would you like to deploy?" | ||
send -- "\r" | ||
|
||
expect "Which deploy script tags would you like to use?" | ||
send -- "\r" | ||
|
||
expect "Will deploy 3 networks: britney, tango, vengaboys" | ||
expect "Will use all deployment scripts" | ||
expect "Do you want to continue?" | ||
send -- "\r" | ||
|
||
expect "Deploying..." | ||
expect "Your contracts are now deployed" | ||
|
||
expect eof |
57 changes: 57 additions & 0 deletions
57
...devtools-evm-hardhat-test/test/task/deploy.test.expectations/deploy-vengaboys-thrower.exp
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,57 @@ | ||
#!/usr/bin/expect -f | ||
# | ||
# This Expect script was generated by autoexpect on Mon Feb 12 16:57:18 2024 | ||
# Expect and autoexpect were both written by Don Libes, NIST. | ||
# | ||
# Note that autoexpect does not guarantee a working script. It | ||
# necessarily has to guess about certain things. Two reasons a script | ||
# might fail are: | ||
# | ||
# 1) timing - A surprising number of programs (rn, ksh, zsh, telnet, | ||
# etc.) and devices discard or ignore keystrokes that arrive "too | ||
# quickly" after prompts. If you find your new script hanging up at | ||
# one spot, try adding a short sleep just before the previous send. | ||
# Setting "force_conservative" to 1 (see below) makes Expect do this | ||
# automatically - pausing briefly before sending each character. This | ||
# pacifies every program I know of. The -c flag makes the script do | ||
# this in the first place. The -C flag allows you to define a | ||
# character to toggle this mode off and on. | ||
|
||
set force_conservative 0 | ||
if {$force_conservative} { | ||
set send_slow {1 .1} | ||
proc send {ignore arg} { | ||
sleep .1 | ||
exp_send -s -- $arg | ||
} | ||
} | ||
|
||
|
||
set timeout 60 | ||
spawn npx hardhat lz:deploy | ||
match_max 100000 | ||
|
||
expect "Which networks would you like to deploy?" | ||
|
||
# First we deselect britney | ||
send -- " " | ||
# We move down by pressing down array | ||
send -- "\[B" | ||
# Then we deselect tango | ||
send -- " " | ||
# Finally we confirm | ||
send -- "\r" | ||
|
||
expect "Which deploy script tags would you like to use?" | ||
send -- "Thrower" | ||
send -- "\r" | ||
|
||
expect "Will deploy 1 network: vengaboys" | ||
expect "Will use deploy scripts tagged with Thrower" | ||
expect "Do you want to continue?" | ||
send -- "\r" | ||
|
||
expect "Deploying..." | ||
expect "Your contracts are now deployed" | ||
|
||
expect eof |
56 changes: 56 additions & 0 deletions
56
tests/devtools-evm-hardhat-test/test/task/deploy.test.expectations/deploy-vengaboys.exp
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,56 @@ | ||
#!/usr/bin/expect -f | ||
# | ||
# This Expect script was generated by autoexpect on Mon Feb 12 16:57:18 2024 | ||
# Expect and autoexpect were both written by Don Libes, NIST. | ||
# | ||
# Note that autoexpect does not guarantee a working script. It | ||
# necessarily has to guess about certain things. Two reasons a script | ||
# might fail are: | ||
# | ||
# 1) timing - A surprising number of programs (rn, ksh, zsh, telnet, | ||
# etc.) and devices discard or ignore keystrokes that arrive "too | ||
# quickly" after prompts. If you find your new script hanging up at | ||
# one spot, try adding a short sleep just before the previous send. | ||
# Setting "force_conservative" to 1 (see below) makes Expect do this | ||
# automatically - pausing briefly before sending each character. This | ||
# pacifies every program I know of. The -c flag makes the script do | ||
# this in the first place. The -C flag allows you to define a | ||
# character to toggle this mode off and on. | ||
|
||
set force_conservative 0 | ||
if {$force_conservative} { | ||
set send_slow {1 .1} | ||
proc send {ignore arg} { | ||
sleep .1 | ||
exp_send -s -- $arg | ||
} | ||
} | ||
|
||
|
||
set timeout 60 | ||
spawn npx hardhat lz:deploy | ||
match_max 100000 | ||
|
||
expect "Which networks would you like to deploy?" | ||
|
||
# First we deselect britney | ||
send -- " " | ||
# We move down by pressing down array | ||
send -- "\[B" | ||
# Then we deselect tango | ||
send -- " " | ||
# Finally we confirm | ||
send -- "\r" | ||
|
||
expect "Which deploy script tags would you like to use?" | ||
send -- "\r" | ||
|
||
expect "Will deploy 1 network: vengaboys" | ||
expect "Will use all deployment scripts" | ||
expect "Do you want to continue?" | ||
send -- "\r" | ||
|
||
expect "Deploying..." | ||
expect "Your contracts are now deployed" | ||
|
||
expect eof |
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