Parse parameter list
This commit is contained in:
2
tests/expectations/procedure_2_statements.txt
Normal file
2
tests/expectations/procedure_2_statements.txt
Normal file
@ -0,0 +1,2 @@
|
||||
5
|
||||
3
|
1
tests/expectations/procedure_print_argument.txt
Normal file
1
tests/expectations/procedure_print_argument.txt
Normal file
@ -0,0 +1 @@
|
||||
5
|
9
tests/procedure_2_statements.eln
Normal file
9
tests/procedure_2_statements.eln
Normal file
@ -0,0 +1,9 @@
|
||||
proc g()
|
||||
begin
|
||||
writei(5);
|
||||
writei(3)
|
||||
end;
|
||||
|
||||
begin
|
||||
g()
|
||||
end.
|
@ -1,4 +1,4 @@
|
||||
proc f; writei(5);
|
||||
proc f() writei(5);
|
||||
|
||||
begin
|
||||
f()
|
||||
|
5
tests/procedure_print_argument.eln
Normal file
5
tests/procedure_print_argument.eln
Normal file
@ -0,0 +1,5 @@
|
||||
proc f(a: Int) writei(a);
|
||||
|
||||
begin
|
||||
f(5)
|
||||
end.
|
@ -43,17 +43,33 @@ namespace elna
|
||||
return in_build_directory() / path;
|
||||
}
|
||||
|
||||
test_result run_for_output(boost::asio::io_context& context, const std::filesystem::path& binary,
|
||||
std::initializer_list<boost::string_view> arguments)
|
||||
boost::process::v2::process_stdio get_output_streams(const std::uint8_t stream_number,
|
||||
boost::asio::readable_pipe& read_pipe)
|
||||
{
|
||||
if (stream_number == 1)
|
||||
{
|
||||
return boost::process::v2::process_stdio{ nullptr, read_pipe };
|
||||
}
|
||||
if (stream_number == 2)
|
||||
{
|
||||
return boost::process::v2::process_stdio{ nullptr, {}, read_pipe };
|
||||
}
|
||||
return boost::process::v2::process_stdio{ nullptr, read_pipe, read_pipe };
|
||||
}
|
||||
|
||||
test_result run_for_output(boost::asio::io_context& context, const std::uint8_t stream_number,
|
||||
const std::filesystem::path& binary, std::initializer_list<boost::string_view> arguments)
|
||||
{
|
||||
boost::asio::readable_pipe read_pipe{ context };
|
||||
test_result result{};
|
||||
std::string output;
|
||||
boost::asio::dynamic_string_buffer buffer = boost::asio::dynamic_buffer(output);
|
||||
boost::system::error_code ec;
|
||||
|
||||
boost::process::v2::process_stdio process_stdio;
|
||||
boost::process::v2::process elna_child(context,
|
||||
binary, arguments,
|
||||
boost::process::v2::process_stdio{ nullptr, read_pipe, read_pipe });
|
||||
get_output_streams(stream_number, read_pipe));
|
||||
do
|
||||
{
|
||||
std::size_t transferred = read_pipe.read_some(buffer.prepare(512), ec);
|
||||
@ -84,7 +100,7 @@ namespace elna
|
||||
std::filesystem::remove(test_binary);
|
||||
std::filesystem::remove(test_object);
|
||||
|
||||
test_result result = run_for_output(context, "./build/bin/elna",
|
||||
test_result result = run_for_output(context, 2, "./build/bin/elna",
|
||||
{ "-o", test_object.string(), test_entry.path().string() });
|
||||
|
||||
if (result.code != 0)
|
||||
@ -157,7 +173,7 @@ namespace elna
|
||||
std::filesystem::path test_binary = in_build_directory(test_filename);
|
||||
test_binary.replace_extension();
|
||||
|
||||
return run_for_output(context,
|
||||
return run_for_output(context, 1,
|
||||
boost::process::search_path("qemu-riscv32"),
|
||||
{ test_binary.string() });
|
||||
}
|
||||
|
Reference in New Issue
Block a user