diff --git a/src/ur/dashboard_client.cpp b/src/ur/dashboard_client.cpp index 41a43c94a..ff1d5180e 100644 --- a/src/ur/dashboard_client.cpp +++ b/src/ur/dashboard_client.cpp @@ -26,6 +26,7 @@ */ //---------------------------------------------------------------------- +#include #include #include #include @@ -246,8 +247,12 @@ bool DashboardClient::commandBrakeRelease() bool DashboardClient::commandLoadProgram(const std::string& program_file_name) { assertVersion("5.0.0", "1.4", "load "); + // 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) diff --git a/tests/test_dashboard_client.cpp b/tests/test_dashboard_client.cpp index 50e9e192d..43da19567 100644 --- a/tests/test_dashboard_client.cpp +++ b/tests/test_dashboard_client.cpp @@ -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);