2019-08-18 17:21:48 +02:00
|
|
|
import os
|
|
|
|
|
|
|
|
fn test_repl() {
|
|
|
|
test_files := os.walk_ext('.', '.repl')
|
2019-08-22 13:15:11 +02:00
|
|
|
wd := os.getwd() + '/'
|
2019-08-18 17:21:48 +02:00
|
|
|
for file in test_files {
|
|
|
|
content := os.read_file(file) or {
|
|
|
|
assert false
|
|
|
|
break
|
|
|
|
}
|
2019-08-18 21:06:39 +02:00
|
|
|
input_temporary_filename := 'input_temporary_filename.txt'
|
|
|
|
input := content.all_before('===output===\n')
|
2019-08-18 17:21:48 +02:00
|
|
|
output := content.all_after('===output===\n')
|
2019-08-18 21:06:39 +02:00
|
|
|
os.write_file(input_temporary_filename, input)
|
|
|
|
defer {
|
|
|
|
os.rm(input_temporary_filename)
|
|
|
|
}
|
|
|
|
r := os.exec('./v < $input_temporary_filename') or {
|
2019-08-18 17:21:48 +02:00
|
|
|
assert false
|
|
|
|
break
|
|
|
|
}
|
2019-08-22 13:15:11 +02:00
|
|
|
result := r.output.replace('>>> ', '').replace('>>>', '').replace('... ', '').all_after('Use Ctrl-C or `exit` to exit\n').replace( wd, '' )
|
2019-08-18 17:21:48 +02:00
|
|
|
assert result == output
|
|
|
|
if result != output {
|
|
|
|
println(file)
|
|
|
|
println('Got : $result')
|
|
|
|
println('Expected : $output')
|
|
|
|
}
|
|
|
|
}
|
2019-08-22 13:15:11 +02:00
|
|
|
}
|