From f4e5cdd0842b2e0f9bc48c6dd17750828c9a8f42 Mon Sep 17 00:00:00 2001 From: Marcos Wagner Date: Tue, 29 Jun 2021 15:55:41 -0300 Subject: [PATCH] Adding some testing Signed-off-by: Marcos Wagner --- model/src/ModelCommandAPI_TEST.cc | 62 ++++++++++++++++++++++++++----- model/src/cmd/cmdmodel.rb.in | 10 +++-- 2 files changed, 59 insertions(+), 13 deletions(-) diff --git a/model/src/ModelCommandAPI_TEST.cc b/model/src/ModelCommandAPI_TEST.cc index eb702825f3b..a9f8471852d 100644 --- a/model/src/ModelCommandAPI_TEST.cc +++ b/model/src/ModelCommandAPI_TEST.cc @@ -67,7 +67,7 @@ TEST(ModelCommandAPI, Commands) { ignition::gazebo::ServerConfig serverConfig; serverConfig.SetSdfFile(std::string(PROJECT_SOURCE_PATH) + - "/test/worlds/shapes.sdf"); + "/examples/worlds/shapes.sdf"); ignition::gazebo::Server server(serverConfig); // Run at least one iteration before continuing to guarantee correctly set up. @@ -81,6 +81,7 @@ TEST(ModelCommandAPI, Commands) const std::string output = customExecStr(cmd); const std::string expectedOutput = "Available models:\n" + " - ground_plane\n" " - box\n" " - cylinder\n" " - sphere\n"; @@ -89,23 +90,64 @@ TEST(ModelCommandAPI, Commands) // Tested command: ign model -m cylinder { - // const std::string cmd = kIgnModelCommand + "-m cylinder"; - // const std::string output = customExecStr(cmd); + const std::string cmd = kIgnModelCommand + "-m box"; + const std::string output = customExecStr(cmd); + const std::string expectedOutput = + +"\nRequesting state for world [shapes] on service [/world/shapes/state]...\n\n" +"Name: box\n" +" - Pose: \n" +" [0.000000 | -0.000000 | 0.500000]\n" +" [0.000000 | 0.000000 | 0.000000]\n\n" +" - Link [9]\n" +" - Name: box_link\n" +" - Parent: box [8]\n" +" - Mass: [1.000000]\n" +" - Inertial Matrix: \n" +" [1.000000 | 0.000000 | 0.000000]\n" +" [0.000000 | 1.000000 | 0.000000]\n" +" [0.000000 | 0.000000 | 1.000000]\n" +" - Pose: \n" +" [0.000000 | 0.000000 | 0.000000]\n" +" [0.000000 | -0.000000 | 0.000000]\n"; + // TODO(@wagnermarcos): Implement test. + EXPECT_EQ(expectedOutput, output); } - // Tested command: ign model -m cylinder --pose + // Tested command: ign model -m vehicle_blue --pose { - // const std::string cmd = kIgnModelCommand + "-m cylinder --pose "; - // const std::string output = customExecStr(cmd); + const std::string cmd = kIgnModelCommand + "-m box --pose "; + const std::string output = customExecStr(cmd); + const std::string expectedOutput = + "\nRequesting state for world [shapes] on service [/world/shapes/state]...\n\n" + "Name: box\n" + " - Pose: \n" + " [0.000000 | -0.000000 | 0.500000]\n" + " [0.000000 | 0.000000 | 0.000000]\n\n"; + EXPECT_EQ(expectedOutput, output); // TODO(@wagnermarcos): Implement test. } - // Tested command: ign model -m cylinder --link cylinder_link + // Tested command: ign model -m box --link box_link { - // const std::string cmd = kIgnModelCommand + - // "-m cylinder --link cylinder_link"; - // const std::string output = customExecStr(cmd); + const std::string cmd = kIgnModelCommand + + "-m box --link box_link"; + const std::string output = customExecStr(cmd); + const std::string expectedOutput = + "\nRequesting state for world [shapes] on service [/world/shapes/state]...\n\n" + " - Link [9]\n" + " - Name: box_link\n" + " - Parent: box [8]\n" + " - Mass: [1.000000]\n" + " - Inertial Matrix: \n" + " [1.000000 | 0.000000 | 0.000000]\n" + " [0.000000 | 1.000000 | 0.000000]\n" + " [0.000000 | 0.000000 | 1.000000]\n" + " - Pose: \n" + " [0.000000 | 0.000000 | 0.000000]\n" + " [0.000000 | -0.000000 | 0.000000]\n"; + EXPECT_EQ(expectedOutput, output); // TODO(@wagnermarcos): Implement test. } } diff --git a/model/src/cmd/cmdmodel.rb.in b/model/src/cmd/cmdmodel.rb.in index 372b637b796..ae9d8530c0e 100644 --- a/model/src/cmd/cmdmodel.rb.in +++ b/model/src/cmd/cmdmodel.rb.in @@ -37,8 +37,13 @@ COMMON_OPTIONS = COMMANDS = { 'model' => "Print information about models.\n\n"+ - " --list Get a list of the available models. \n"\ - " -m [--model] [model_name] Select the model to shown. \n\n"+ + " --list Get a list of the available models. \n"\ + " -m [--model] [model_name] Select the model to be shown. \n"\ + " -l [--link] [link_name] Select a link to show it's properties. \n"\ + " -j [--joint] [joint_name] Select a joint to show it's properties. \n\n"\ + " E.g. to get information about the \n"\ + " box_link in the shapes world, run: \n"\ + " ign model -m box -l box_link \n\n"+ COMMON_OPTIONS } @@ -95,7 +100,6 @@ class Cmd end options['command'] = args[0] - # options['subcommand'] = args[1] options end # parse()