-
Notifications
You must be signed in to change notification settings - Fork 304
Print an error message when trying to load SDF files that don't contain a <world>
#1998
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -1088,6 +1088,41 @@ TEST_P(ServerFixture, AddResourcePaths) | |||||||||||||||
} | ||||||||||||||||
} | ||||||||||||||||
|
||||||||||||||||
///////////////////////////////////////////////// | ||||||||||||||||
TEST_P(ServerFixture, SdfWithoutWorld) | ||||||||||||||||
{ | ||||||||||||||||
// Initialize logging | ||||||||||||||||
std::string logBasePath = common::joinPaths(PROJECT_BINARY_PATH, "tmp"); | ||||||||||||||||
common::setenv(IGN_HOMEDIR, logBasePath); | ||||||||||||||||
std::string path = common::uuid(); | ||||||||||||||||
ignLogInit(path, "test.log"); | ||||||||||||||||
|
||||||||||||||||
// Start server with model SDF file | ||||||||||||||||
ServerConfig serverConfig; | ||||||||||||||||
serverConfig.SetSdfFile(std::string(PROJECT_SOURCE_PATH) + | ||||||||||||||||
"/test/worlds/models/sphere/model.sdf"); | ||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done in 9059a2b. |
||||||||||||||||
|
||||||||||||||||
gz::sim::Server server(serverConfig); | ||||||||||||||||
EXPECT_FALSE(server.Running()); | ||||||||||||||||
EXPECT_FALSE(*server.Running(0)); | ||||||||||||||||
|
||||||||||||||||
// Check error message in log file | ||||||||||||||||
std::ifstream ifs(common::joinPaths(logBasePath, path, "test.log").c_str(), std::ios::in); | ||||||||||||||||
bool errFound = false; | ||||||||||||||||
while ((!errFound) && (!ifs.eof())) | ||||||||||||||||
{ | ||||||||||||||||
std::string line; | ||||||||||||||||
std::getline(ifs, line); | ||||||||||||||||
errFound = (line.find("SDF file doesn't contain a world.") != std::string::npos); | ||||||||||||||||
} | ||||||||||||||||
EXPECT_TRUE(errFound); | ||||||||||||||||
|
||||||||||||||||
// Stop logging | ||||||||||||||||
ignLogClose(); | ||||||||||||||||
common::removeAll(logBasePath); | ||||||||||||||||
} | ||||||||||||||||
|
||||||||||||||||
|
||||||||||||||||
// Run multiple times. We want to make sure that static globals don't cause | ||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done in 9059a2b. |
||||||||||||||||
// problems. | ||||||||||||||||
INSTANTIATE_TEST_SUITE_P(ServerRepeat, ServerFixture, ::testing::Range(1, 2)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be helpful to add that if the user wants to spawn a model, they could use the ResourceSpawner GUI plugin or the
world/<world name/create
service.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in bee3130.