Skip to content

Commit

Permalink
Reverted tests and updated executable options to work without args
Browse files Browse the repository at this point in the history
Signed-off-by: Saurabh Kamat <[email protected]>
  • Loading branch information
sauk2 committed Jan 11, 2025
1 parent 50991f3 commit e5b5f3d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 19 deletions.
10 changes: 6 additions & 4 deletions src/cmd/sdf_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,12 @@ void addSdfFlags(CLI::App &_app)
auto filepathOpt =
_app.add_option("filepath", opt->filepath,
"Path to an SDFormat file.");
_app.add_option("-i,--preserve-includes", opt->preserveIncludes,
_app.add_flag("-i,--preserve-includes", opt->preserveIncludes,
"Preserve included tags when printing converted arg (does "
"not preserve merge-includes).");
_app.add_option("--degrees", opt->degrees,
_app.add_flag("--degrees", opt->degrees,
"Printed pose rotations are will be in degrees.");
_app.add_option("--expand-auto-inertials", opt->expandAutoInertials,
_app.add_flag("--expand-auto-inertials", opt->expandAutoInertials,
"Auto-computed inertial values will be printed.");
_app.add_option("--precision", opt->precision,
"Set the output stream precision for floating point "
Expand All @@ -146,7 +146,9 @@ void addSdfFlags(CLI::App &_app)
opt->version = _version;
},
"Print the aggregated SDFormat spec description. Latest version ("
SDF_PROTOCOL_VERSION ")");
SDF_PROTOCOL_VERSION ")")
->expected(0, 1)
->default_val(SDF_PROTOCOL_VERSION);

command->add_option_function<std::string>("-g,--graph",
[opt](const std::string &_graphType){
Expand Down
29 changes: 14 additions & 15 deletions src/gz_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1066,8 +1066,7 @@ TEST(describe, SDF)
{
// Get the description
std::string output =
custom_exec_str(GzCommand() + " sdf -d " +
SDF_PROTOCOL_VERSION + SdfVersion());
custom_exec_str(GzCommand() + " sdf -d " + SdfVersion());
EXPECT_FALSE(output.empty());

// The first line should start with the following text.
Expand Down Expand Up @@ -1119,7 +1118,7 @@ TEST(print_rotations_in_degrees, SDF)

// Printing with in_degrees
output = custom_exec_str(
GzCommand() + " sdf -p --precision 6 " + path + " --degrees 1"
GzCommand() + " sdf -p --precision 6 " + path + " --degrees "
+ SdfVersion());
ASSERT_FALSE(output.empty());
EXPECT_PRED2(sdf::testing::contains, output,
Expand Down Expand Up @@ -1187,7 +1186,7 @@ TEST(print_rotations_in_radians, SDF)

// Printing with in_degrees
output = custom_exec_str(
GzCommand() + " sdf -p --precision 6 " + path + " --degrees 1"
GzCommand() + " sdf -p --precision 6 " + path + " --degrees "
+ SdfVersion());
ASSERT_FALSE(output.empty());
EXPECT_PRED2(sdf::testing::contains, output,
Expand Down Expand Up @@ -1256,7 +1255,7 @@ TEST(print_rotations_in_quaternions, SDF)

// Printing with in_degrees
output = custom_exec_str(
GzCommand() + " sdf -p --precision 6 " + path + " --degrees 1"
GzCommand() + " sdf -p --precision 6 " + path + " --degrees "
+ SdfVersion());
ASSERT_FALSE(output.empty());
EXPECT_PRED2(sdf::testing::contains, output,
Expand Down Expand Up @@ -1327,7 +1326,7 @@ TEST(print_includes_rotations_in_degrees, SDF)

// Printing with in_degrees
output = custom_exec_str(
GzCommand() + " sdf -p --precision 6 " + path + " --degrees 1"
GzCommand() + " sdf -p --precision 6 " + path + " --degrees "
+ SdfVersion());
ASSERT_FALSE(output.empty());
EXPECT_PRED2(sdf::testing::contains, output,
Expand Down Expand Up @@ -1398,7 +1397,7 @@ TEST(print_includes_rotations_in_radians, SDF)

// Printing with in_degrees
output = custom_exec_str(
GzCommand() + " sdf -p --precision 6 " + path + " --degrees 1"
GzCommand() + " sdf -p --precision 6 " + path + " --degrees "
+ SdfVersion());
ASSERT_FALSE(output.empty());
EXPECT_PRED2(sdf::testing::contains, output,
Expand Down Expand Up @@ -1470,7 +1469,7 @@ TEST(print_includes_rotations_in_quaternions, SDF)

// Printing with in_degrees
output = custom_exec_str(
GzCommand() + " sdf -p --precision 6 " + path + " --degrees 1"
GzCommand() + " sdf -p --precision 6 " + path + " --degrees "
+ SdfVersion());
ASSERT_FALSE(output.empty());
EXPECT_PRED2(sdf::testing::contains, output,
Expand Down Expand Up @@ -1541,7 +1540,7 @@ TEST(print_rotations_in_unnormalized_degrees, SDF)

// Printing with in_degrees
output = custom_exec_str(
GzCommand() + " sdf -p --precision 6 " + path + " --degrees 1"
GzCommand() + " sdf -p --precision 6 " + path + " --degrees "
+ SdfVersion());
ASSERT_FALSE(output.empty());
EXPECT_PRED2(sdf::testing::contains, output,
Expand Down Expand Up @@ -1609,7 +1608,7 @@ TEST(print_rotations_in_unnormalized_radians, SDF)

// Printing with in_degrees
output = custom_exec_str(
GzCommand() + " sdf -p --precision 6 " + path + " --degrees 1"
GzCommand() + " sdf -p --precision 6 " + path + " --degrees "
+ SdfVersion());
ASSERT_FALSE(output.empty());
EXPECT_PRED2(sdf::testing::contains, output,
Expand Down Expand Up @@ -1668,18 +1667,18 @@ TEST(shuffled_cmd_flags, SDF)
const std::string path =
sdf::testing::TestFile("sdf", "rotations_in_unnormalized_radians.sdf");

// -p PATH --degrees ARG
// -p PATH --degrees
std::string output = custom_exec_str(
GzCommand() + " sdf -p --precision 6 " + path + " --degrees 1"
GzCommand() + " sdf -p --precision 6 " + path + " --degrees "
+ SdfVersion());
ASSERT_FALSE(output.empty());
EXPECT_PRED2(sdf::testing::contains, output,
"<pose degrees='true' rotation_format='euler_rpy'>"
"1 2 3 30.009 44.9915 -60.009</pose>");

// --degrees ARG -p PATH
// --degrees -p PATH
output = custom_exec_str(
GzCommand() + " sdf --degrees 1 -p --precision 6 " + path + SdfVersion());
GzCommand() + " sdf --degrees -p --precision 6 " + path + SdfVersion());
ASSERT_FALSE(output.empty());
EXPECT_PRED2(sdf::testing::contains, output,
"<pose degrees='true' rotation_format='euler_rpy'>"
Expand Down Expand Up @@ -1749,7 +1748,7 @@ TEST(print_auto_inertial, SDF)
// expect <mass> and <inertia> elements
std::string output = custom_exec_str(
GzCommand() + " sdf -p " + path +
" --expand-auto-inertials 1 " +
" --expand-auto-inertials " +
SdfVersion());
ASSERT_FALSE(output.empty());
EXPECT_PRED2(sdf::testing::contains, output, "<mass>");
Expand Down

0 comments on commit e5b5f3d

Please sign in to comment.