Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/ur/dashboard_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
*/
//----------------------------------------------------------------------

#include <filesystem>
#include <iostream>
#include <regex>
#include <thread>
Expand Down Expand Up @@ -246,8 +247,12 @@ bool DashboardClient::commandBrakeRelease()
bool DashboardClient::commandLoadProgram(const std::string& program_file_name)
{
assertVersion("5.0.0", "1.4", "load <program>");
// We load the program, which will fail if the program is not found or the requested file does
// not contain a valid program. Afterwards, we wait until the program state is stopped with a
// program named the same as the requested program. We cannot check the full file path here, but
// the important thing is that the program state is stopped.
return sendRequest("load " + program_file_name + "", "(?:Loading program: ).*(?:" + program_file_name + ").*") &&
waitForReply("programState", "STOPPED " + program_file_name);
waitForReply("programState", "STOPPED " + std::filesystem::path{ program_file_name }.filename().string());
}

bool DashboardClient::commandLoadInstallation(const std::string& installation_file_name)
Expand Down
7 changes: 7 additions & 0 deletions tests/test_dashboard_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,13 @@ TEST_F(DashboardClientTest, connecting_twice_returns_false)
EXPECT_FALSE(dashboard_client_->connect());
}

TEST_F(DashboardClientTest, load_program_in_subdir_works)
{
ASSERT_TRUE(dashboard_client_->connect());

ASSERT_TRUE(dashboard_client_->commandLoadProgram("/ursim/programs/wait_program.urp"));
}

int main(int argc, char* argv[])
{
::testing::InitGoogleTest(&argc, argv);
Expand Down
Loading