#!/usr/bin/expect
|
|
|
|
set SUGAR_EXECUTABLE $::env(SUGAR_EXECUTABLE)
|
|
set BUILD_NAME 006.
|
|
|
|
proc abort {reason} {
|
|
puts "test failed $reason"
|
|
exit 1
|
|
}
|
|
|
|
spawn -noecho $SUGAR_EXECUTABLE lex
|
|
expect {
|
|
error { abort "failed to parse" }
|
|
eof { abort "failed silently" }
|
|
expects
|
|
}
|
|
expect eof
|
|
lassign [wait] pid spawnid os_error_flag value
|
|
if {$value == 0} {
|
|
abort "compiler didn't crash"
|
|
}
|
|
|
|
# -------------------------------------------------------------------
|
|
|
|
spawn -noecho $SUGAR_EXECUTABLE "fake_01.006.not_a_file" lex
|
|
expect {
|
|
error { abort "failed to parse" }
|
|
eof { abort "failed silently" }
|
|
"does not exist"
|
|
}
|
|
expect eof
|
|
lassign [wait] pid spawnid os_error_flag value
|
|
if {$value == 0} {
|
|
abort "compiler didn't crash"
|
|
}
|
|
|
|
# -------------------------------------------------------------------
|
|
|
|
spawn -noecho $SUGAR_EXECUTABLE "fake_01.006.not_a_file" lex-all
|
|
expect {
|
|
error { abort "failed to parse" }
|
|
eof { abort "failed silently" }
|
|
"does not exist"
|
|
}
|
|
expect eof
|
|
lassign [wait] pid spawnid os_error_flag value
|
|
if {$value == 0} {
|
|
abort "compiler didn't crash"
|
|
}
|
|
|
|
# -------------------------------------------------------------------
|
|
|
|
spawn -noecho $SUGAR_EXECUTABLE "tests/005/library.mol" lex merge
|
|
expect {
|
|
error { abort "failed to parse" }
|
|
eof { abort "failed silently" }
|
|
expects
|
|
}
|
|
expect eof
|
|
lassign [wait] pid spawnid os_error_flag value
|
|
if {$value == 0} {
|
|
abort "compiler didn't crash"
|
|
}
|
|
|
|
# -------------------------------------------------------------------
|
|
|
|
spawn -noecho $SUGAR_EXECUTABLE merge
|
|
expect {
|
|
error { abort "failed to parse" }
|
|
eof { abort "failed silently" }
|
|
expects
|
|
}
|
|
expect eof
|
|
lassign [wait] pid spawnid os_error_flag value
|
|
if {$value == 0} {
|
|
abort "compiler didn't crash"
|
|
}
|
|
|
|
# -------------------------------------------------------------------
|
|
|
|
spawn -noecho $SUGAR_EXECUTABLE parse
|
|
expect {
|
|
error { abort "failed to parse" }
|
|
eof { abort "failed silently" }
|
|
expects
|
|
}
|
|
expect eof
|
|
lassign [wait] pid spawnid os_error_flag value
|
|
if {$value == 0} {
|
|
abort "compiler didn't crash"
|
|
}
|
|
|
|
spawn -noecho $SUGAR_EXECUTABLE generate
|
|
expect {
|
|
error { abort "failed to parse" }
|
|
eof { abort "failed silently" }
|
|
expects
|
|
}
|
|
expect eof
|
|
lassign [wait] pid spawnid os_error_flag value
|
|
if {$value == 0} {
|
|
abort "compiler didn't crash"
|
|
}
|
|
|
|
file delete "/tmp/006.fake_target"
|
|
spawn -noecho $SUGAR_EXECUTABLE "/tmp/006.fake_target" generate
|
|
expect {
|
|
error { abort "failed to parse" }
|
|
eof { abort "failed silently" }
|
|
"parsed output"
|
|
}
|
|
expect eof
|
|
lassign [wait] pid spawnid os_error_flag value
|
|
if {$value == 0} {
|
|
abort "compiler didn't crash"
|
|
}
|
|
if {[file exists "/tmp/006.fake_target"]} {
|
|
abort "created a file even if it failed to compile anything"
|
|
file delete "/tmp/006.fake_target"
|
|
}
|
|
|
|
# -------------------------------------------------------------------
|
|
|
|
spawn -noecho $SUGAR_EXECUTABLE merge-all
|
|
expect {
|
|
error { abort "failed to parse" }
|
|
eof { abort "failed silently" }
|
|
expects
|
|
}
|
|
expect eof
|
|
lassign [wait] pid spawnid os_error_flag value
|
|
if {$value == 0} {
|
|
abort "compiler didn't crash"
|
|
}
|
|
|
|
spawn -noecho $SUGAR_EXECUTABLE assemble
|
|
expect {
|
|
error { abort "failed to parse" }
|
|
eof { abort "failed silently" }
|
|
expects
|
|
}
|
|
expect eof
|
|
lassign [wait] pid spawnid os_error_flag value
|
|
if {$value == 0} {
|
|
abort "compiler didn't crash"
|
|
}
|
|
|
|
# -------------------------------------------------------------------
|
|
|
|
spawn -noecho $SUGAR_EXECUTABLE help
|
|
expect {
|
|
error { abort "failed to parse" }
|
|
eof { abort "failed silently" }
|
|
Commands
|
|
}
|
|
expect eof
|
|
lassign [wait] pid spawnid os_error_flag value
|
|
if {$value != 0} {
|
|
abort "compiler crashed displaying help"
|
|
}
|
|
|
|
# -------------------------------------------------------------------
|
|
|
|
spawn -noecho $SUGAR_EXECUTABLE --help
|
|
expect {
|
|
error { abort "failed to parse" }
|
|
eof { abort "failed silently" }
|
|
Commands
|
|
}
|
|
expect eof
|
|
lassign [wait] pid spawnid os_error_flag value
|
|
if {$value != 0} {
|
|
abort "compiler crashed displaying help"
|
|
}
|