我使用expect来运行测试脚本.测试通过退出代码返回成功/失败.但期望返回等效的退出代码.如何让期望返回正确的退出状态?
我的测试是用psql(postgresql命令处理器)运行的sql脚本.由于psql不允许将数据库密码指定为命令行参数,因此期望脚本执行此操作.
所以,我的期望脚本看起来像:
spawn $SPAWN_CMD
expect {
-re "Enter password for new role:" {
send "$PWPROMPT\n"
exp_continue
} -re "Enter it again:" {
send "$PWPROMPT\n"
exp_continue
} -re "Password(.*)" {
send "$PASSWORD\n"
exp_continue
} -re "Password(.*):" {
send "$PASSWORD\n"
exp_continue
} eof
}
Run Code Online (Sandbox Code Playgroud)