Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSybren A. Stüvel <sybren@blender.org>2019-12-13 20:56:55 +0300
committerSybren A. Stüvel <sybren@blender.org>2019-12-13 20:59:23 +0300
commite6c40bc9e1f11e306977e5a5090501b8c922fb98 (patch)
treefca762646a3559077fe74ef197148a8d13718c5f
parent38ad1c4d339da67bd494cb9a26b9dc315fbfad26 (diff)
USD: Simplified unit test and made it work on Windows as well
-rw-r--r--tests/gtests/usd/CMakeLists.txt15
-rw-r--r--tests/gtests/usd/usd_stage_creation_test.cc29
2 files changed, 18 insertions, 26 deletions
diff --git a/tests/gtests/usd/CMakeLists.txt b/tests/gtests/usd/CMakeLists.txt
index e2768509ec4..8dbfb93f0f1 100644
--- a/tests/gtests/usd/CMakeLists.txt
+++ b/tests/gtests/usd/CMakeLists.txt
@@ -64,7 +64,7 @@ set(SRC
hierarchy_context_order_test.cc
)
-if(UNIX AND NOT APPLE)
+if(NOT APPLE)
# TODO(Sybren): This unit test has only been tested on Linux, and should possibly be
# restructured to support other platforms as well.
list(APPEND SRC usd_stage_creation_test.cc)
@@ -75,13 +75,24 @@ if(WITH_BUILDINFO)
list(APPEND SRC "$<TARGET_OBJECTS:buildinfoobj>")
endif()
+# get_cmake_property(_variableNames VARIABLES)
+# list (SORT _variableNames)
+# foreach (_variableName ${_variableNames})
+# message(STATUS "${_variableName}=${${_variableName}}")
+# endforeach()
+
+# Works on Linux, not on Windows:
+# set(_usd_DATAFILES_DIR "${CMAKE_INSTALL_PREFIX}/${BLENDER_VERSION}/datafiles/usd")
+set(_usd_DATAFILES_DIR "$<TARGET_FILE_DIR:blender>/${BLENDER_VERSION}/datafiles/usd")
+
BLENDER_SRC_GTEST_EX(
NAME usd
SRC "${SRC}"
EXTRA_LIBS "${LIB}"
COMMAND_ARGS
--test-assets-dir "${CMAKE_SOURCE_DIR}/../lib/tests"
- --test-blender-executable-dir "${EXECUTABLE_OUTPUT_PATH}"
+ --test-usd-datafiles-dir "${_usd_DATAFILES_DIR}"
)
+unset(_usd_DATAFILES_DIR)
setup_liblinks(usd_test)
diff --git a/tests/gtests/usd/usd_stage_creation_test.cc b/tests/gtests/usd/usd_stage_creation_test.cc
index 9d76b42371d..b262e21f053 100644
--- a/tests/gtests/usd/usd_stage_creation_test.cc
+++ b/tests/gtests/usd/usd_stage_creation_test.cc
@@ -31,43 +31,24 @@ extern "C" {
void usd_initialise_plugin_path(const char *datafiles_usd_path);
}
-DEFINE_string(test_blender_executable_dir, "", "Blender's installation directory.");
+DEFINE_string(test_usd_datafiles_dir, "", "The bin/{BLENDER_VERSION}/datafiles/usd directory.");
class USDStageCreationTest : public testing::Test {
};
TEST_F(USDStageCreationTest, JSONFileLoadingTest)
{
- std::string filename = "usd-stage-creation-test.usdc";
-
- if (FLAGS_test_blender_executable_dir.empty()) {
- FAIL() << "Pass the --test-blender-executable-dir flag";
- }
-
- /* Required on Linux to make BKE_appdir_folder_id() find the datafiles.
- * Without going to this directory, Blender looks for the datafiles in
- * .../bin/tests instead of .../bin */
- const char *blender_executable_dir = FLAGS_test_blender_executable_dir.c_str();
- if (chdir(blender_executable_dir) < 0) {
- FAIL() << "unable to change directory to " << FLAGS_test_blender_executable_dir;
+ if (FLAGS_test_usd_datafiles_dir.empty()) {
+ FAIL() << "Pass the --test-usd-datafiles-dir flag";
}
- const char *usd_datafiles_relpath = BKE_appdir_folder_id(BLENDER_DATAFILES, "usd");
- EXPECT_NE(usd_datafiles_relpath, nullptr) << "Unable to find datafiles/usd";
-
- char usd_datafiles_abspath[FILE_MAX];
- BLI_path_join(usd_datafiles_abspath,
- sizeof(usd_datafiles_abspath),
- blender_executable_dir,
- usd_datafiles_relpath,
- NULL);
-
- usd_initialise_plugin_path(usd_datafiles_abspath);
+ usd_initialise_plugin_path(FLAGS_test_usd_datafiles_dir.c_str());
/* Simply the ability to create a USD Stage for a specific filename means that the extension
* has been recognised by the USD library, and that a USD plugin has been loaded to write such
* files. Practically, this is a test to see whether the USD JSON files can be found and
* loaded. */
+ std::string filename = "usd-stage-creation-test.usdc";
pxr::UsdStageRefPtr usd_stage = pxr::UsdStage::CreateNew(filename);
if (usd_stage != nullptr) {
/* Even though we don't call usd_stage->SaveFile(), a file is still created on the filesystem