[Bf-blender-cvs] [9439ac41eb5] master: I/O tests: change all_geometry scene to not have subd surface, and always print obj failure output diff details

Aras Pranckevicius noreply at git.blender.org
Fri Apr 8 14:09:50 CEST 2022


Commit: 9439ac41eb5dd11397cd9ff4d0379dd49b2c2194
Author: Aras Pranckevicius
Date:   Fri Apr 8 15:08:50 2022 +0300
Branches: master
https://developer.blender.org/rB9439ac41eb5dd11397cd9ff4d0379dd49b2c2194

I/O tests: change all_geometry scene to not have subd surface, and always print obj failure output diff details

The all_objects.blend test scene (in subversion tests repo) contained an
object with a subdivision surface. Which changes vertex positions
slightly, depending on used OpenSubDiv version and the compile flags. It
seems that the intent of the test was "test export of meshes that use
modifiers", so I changed that object to be a cube with a simple "taper"
modifier instead.

While at it, changed OBJ exporter test code to always print the
"expected and what we got" text difference details, when a test fails.
Much easier to see than just "the files are different" output. The code
to print that was behind an off by default flag for some reason.

This diff should get comitted together with updated all_objects templates
in subversion tests repo.

Reviewed By: Sebastian Parborg
Differential Revision: https://developer.blender.org/D14597

===================================================================

M	source/blender/io/wavefront_obj/tests/obj_exporter_tests.cc
M	source/blender/io/wavefront_obj/tests/obj_importer_tests.cc

===================================================================

diff --git a/source/blender/io/wavefront_obj/tests/obj_exporter_tests.cc b/source/blender/io/wavefront_obj/tests/obj_exporter_tests.cc
index a3512595fa7..8599b38d55b 100644
--- a/source/blender/io/wavefront_obj/tests/obj_exporter_tests.cc
+++ b/source/blender/io/wavefront_obj/tests/obj_exporter_tests.cc
@@ -273,34 +273,26 @@ parm u 0.0
 /* Return true if string #a and string #b are equal after their first newline. */
 static bool strings_equal_after_first_lines(const std::string &a, const std::string &b)
 {
-  /* If `dbg_level` is true then a failing test will print context around the first mismatch. */
-  const bool dbg_level = false;
   const size_t a_len = a.size();
   const size_t b_len = b.size();
   const size_t a_next = a.find_first_of('\n');
   const size_t b_next = b.find_first_of('\n');
   if (a_next == std::string::npos || b_next == std::string::npos) {
-    if (dbg_level) {
-      std::cout << "Couldn't find newline in one of args\n";
-    }
+    std::cout << "Couldn't find newline in one of args\n";
     return false;
   }
-  if (dbg_level) {
-    if (a.compare(a_next, a_len - a_next, b, b_next, b_len - b_next) != 0) {
-      for (int i = 0; i < a_len - a_next && i < b_len - b_next; ++i) {
-        if (a[a_next + i] != b[b_next + i]) {
-          std::cout << "Difference found at pos " << a_next + i << " of a\n";
-          std::cout << "a: " << a.substr(a_next + i, 100) << " ...\n";
-          std::cout << "b: " << b.substr(b_next + i, 100) << " ... \n";
-          return false;
-        }
+  if (a.compare(a_next, a_len - a_next, b, b_next, b_len - b_next) != 0) {
+    for (int i = 0; i < a_len - a_next && i < b_len - b_next; ++i) {
+      if (a[a_next + i] != b[b_next + i]) {
+        std::cout << "Difference found at pos " << a_next + i << " of a\n";
+        std::cout << "a: " << a.substr(a_next + i, 100) << " ...\n";
+        std::cout << "b: " << b.substr(b_next + i, 100) << " ... \n";
+        return false;
       }
     }
-    else {
-      return true;
-    }
+    return false;
   }
-  return a.compare(a_next, a_len - a_next, b, b_next, b_len - b_next) == 0;
+  return true;
 }
 
 /* From here on, tests are whole file tests, testing for golden output. */
diff --git a/source/blender/io/wavefront_obj/tests/obj_importer_tests.cc b/source/blender/io/wavefront_obj/tests/obj_importer_tests.cc
index 0a70a03dc65..9dd9e7c1a37 100644
--- a/source/blender/io/wavefront_obj/tests/obj_importer_tests.cc
+++ b/source/blender/io/wavefront_obj/tests/obj_importer_tests.cc
@@ -387,15 +387,15 @@ TEST_F(obj_importer_test, import_all_objects)
        float3(28, 1, -1),
        float3(26, 1, 1),
        float3(-1, 0, 0)},
-      {"OBSubSurfCube",
+      {"OBTaperCube",
        OB_MESH,
        106,
        208,
        104,
        416,
-       float3(24.444445f, 0.444444f, -0.666667f),
-       float3(23.790743f, 0.490725f, -0.816819f),
-       float3(0.1697f, 0.1697f, 0.9708f)},
+       float3(24.444445f, 0.502543f, -0.753814f),
+       float3(23.790743f, 0.460522f, -0.766546f),
+       float3(-0.0546f, 0.1716f, 0.9837f)},
       {"OBParticleCube",
        OB_MESH,
        8,



More information about the Bf-blender-cvs mailing list