Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion pxr/usd/usdUtils/dependencies.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "pxr/usd/sdf/fileFormat.h"
#include "pxr/usd/sdf/layerUtils.h"

#include "pxr/base/tf/diagnostic.h"
#include "pxr/base/trace/trace.h"

#include <functional>
Expand Down Expand Up @@ -126,7 +127,12 @@ struct UsdUtils_ComputeAllDependenciesClient
}
}
else if (UsdStage::IsSupportedFile(anchoredPath)) {
layers.insert(SdfLayer::FindOrOpen(anchoredPath));
SdfLayerRefPtr dependencyLayer = SdfLayer::FindOrOpen(anchoredPath);
if (dependencyLayer) {
layers.insert(dependencyLayer);
} else {
TF_WARN("Failed to open dependency layer: %s (%s)", dependency.c_str(), anchoredPath.c_str());
}
}
else {
assets.insert(resolvedPath);
Expand Down
27 changes: 26 additions & 1 deletion pxr/usd/usdUtils/testenv/testUsdUtilsDependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# Licensed under the terms set forth in the LICENSE.txt file available at
# https://openusd.org/license.

from pxr import Ar, UsdUtils, Sdf, Usd
from pxr import Ar, Tf, UsdUtils, Sdf, Usd
from pathlib import Path
import os
import unittest
Expand Down Expand Up @@ -294,6 +294,31 @@ def test_ComputeAllDependenciesMissingExternalDep(self):
self.assertEqual(unresolved, ["missing.png",
"missing_in_package.png",
"missing_in_reference.png"])

def test_ComputeAllDependenciesInvalidPayload(self):
"""Tests that invalid payloads are detected and reported"""

def TestDirPath(path):
return os.path.normcase(
os.path.abspath(os.path.join(testDir, path)))

testDir = "computeAllDependenciesInvalidPayload"
stagePath = "root.usda"

delegate = UsdUtils.CoalescingDiagnosticDelegate()

layers, references, unresolved = UsdUtils.ComputeAllDependencies(TestDirPath(stagePath))
self.assertEqual(len(layers), 1)
self.assertEqual(layers[0].identifier, TestDirPath(stagePath))
self.assertEqual(len(references), 0)
self.assertEqual(len(unresolved), 0)

unfiltered = delegate.TakeUncoalescedDiagnostics()
self.assertEqual(len(unfiltered), 1)
self.assertEqual(unfiltered[0].commentary,
"Failed to open dependency layer: ./invalid.usd "
f"({TestDirPath('invalid.usd')})")


if __name__=="__main__":
unittest.main()
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#usda 1.0

def "foo"
{
def "invalid" (
prepend payload = @./invalid.usd@
)
{

}
}
Loading