[LYN-7520] Wildcard Source Dependencies include files in cache/excluded files (#5349)

* Add folder exclusion for wildcard source dependencies

Signed-off-by: amzn-mike <80125227+amzn-mike@users.noreply.github.com>

* Exclude ignored files.  Add unit tests

Signed-off-by: amzn-mike <80125227+amzn-mike@users.noreply.github.com>

* Add handling for ignored folders being added/removed

Add unit tests

Signed-off-by: amzn-mike <80125227+amzn-mike@users.noreply.github.com>

* Add ExcludedFolderCacheInterface to cmake

Signed-off-by: amzn-mike <80125227+amzn-mike@users.noreply.github.com>

* Fix include

Signed-off-by: amzn-mike <80125227+amzn-mike@users.noreply.github.com>

* Add error message

Signed-off-by: amzn-mike <80125227+amzn-mike@users.noreply.github.com>

* Cleanup includes

Signed-off-by: amzn-mike <80125227+amzn-mike@users.noreply.github.com>

* Revert traits include

Signed-off-by: amzn-mike <80125227+amzn-mike@users.noreply.github.com>

* Fix missing include, minor cleanup

Signed-off-by: amzn-mike <80125227+amzn-mike@users.noreply.github.com>

* Add missing includes

Signed-off-by: amzn-mike <80125227+amzn-mike@users.noreply.github.com>
This commit is contained in:
amzn-mike
2021-11-18 13:37:48 -06:00
committed by GitHub
parent 8e02a82866
commit ae50187fba
13 changed files with 506 additions and 14 deletions
@@ -5364,13 +5364,29 @@ AZStd::vector<AZStd::string> WildcardSourceDependencyTest::FileAddedTest(const Q
void WildcardSourceDependencyTest::SetUp()
{
AssetProcessorManagerTest::SetUp();
QDir tempPath(m_tempDir.path());
// Add a non-recursive scan folder. Only files directly inside of this folder should be picked up, subfolders are ignored
m_config->AddScanFolder(ScanFolderInfo(tempPath.filePath("no_recurse"), "no_recurse",
"no_recurse", false, false, m_config->GetEnabledPlatforms(), 1));
{
ExcludeAssetRecognizer excludeFolder;
excludeFolder.m_name = "Exclude ignored Folder";
excludeFolder.m_patternMatcher =
AssetBuilderSDK::FilePatternMatcher(R"REGEX(^(.*\/)?ignored(\/.*)?$)REGEX", AssetBuilderSDK::AssetBuilderPattern::Regex);
m_config->AddExcludeRecognizer(excludeFolder);
}
{
ExcludeAssetRecognizer excludeFile;
excludeFile.m_name = "Exclude z.foo Files";
excludeFile.m_patternMatcher =
AssetBuilderSDK::FilePatternMatcher(R"REGEX(^(.*\/)?z\.foo$)REGEX", AssetBuilderSDK::AssetBuilderPattern::Regex);
m_config->AddExcludeRecognizer(excludeFile);
}
UnitTestUtils::CreateDummyFile(tempPath.absoluteFilePath("subfolder1/1a.foo"));
UnitTestUtils::CreateDummyFile(tempPath.absoluteFilePath("subfolder1/1b.foo"));
UnitTestUtils::CreateDummyFile(tempPath.absoluteFilePath("subfolder2/redirected/a.foo"));
@@ -5384,6 +5400,19 @@ void WildcardSourceDependencyTest::SetUp()
// Add a file in the non-recursive scanfolder. Since its not directly in the scan folder, it should always be ignored
UnitTestUtils::CreateDummyFile(tempPath.absoluteFilePath("no_recurse/one/two/three/f.foo"));
// Add a file to an ignored folder
UnitTestUtils::CreateDummyFile(tempPath.absoluteFilePath("subfolder2/redirected/folder/ignored/g.foo"));
// Add an ignored file
UnitTestUtils::CreateDummyFile(tempPath.absoluteFilePath("subfolder2/redirected/folder/one/z.foo"));
// Add a file in the cache
AZStd::string projectCacheRootValue;
AZ::SettingsRegistry::Get()->Get(projectCacheRootValue, AZ::SettingsRegistryMergeUtils::FilePathKey_CacheProjectRootFolder);
projectCacheRootValue = AssetUtilities::NormalizeFilePath(projectCacheRootValue.c_str()).toUtf8().constData();
auto path = AZ::IO::Path(projectCacheRootValue) / "cache.foo";
UnitTestUtils::CreateDummyFile(path.c_str());
AzToolsFramework::AssetDatabase::SourceFileDependencyEntryContainer dependencies;
// Relative path wildcard dependency
@@ -5518,6 +5547,102 @@ TEST_F(WildcardSourceDependencyTest, Absolute_NoWildcard)
ASSERT_THAT(resolvedPaths, ::testing::UnorderedElementsAre());
}
TEST_F(WildcardSourceDependencyTest, Relative_IgnoredFolder)
{
AZStd::vector<AZStd::string> resolvedPaths;
ASSERT_TRUE(Test("*g.foo", resolvedPaths));
ASSERT_THAT(resolvedPaths, ::testing::UnorderedElementsAre());
}
TEST_F(WildcardSourceDependencyTest, Absolute_IgnoredFolder)
{
AZStd::vector<AZStd::string> resolvedPaths;
QDir tempPath(m_tempDir.path());
ASSERT_TRUE(Test(tempPath.absoluteFilePath("*g.foo").toUtf8().constData(), resolvedPaths));
ASSERT_THAT(resolvedPaths, ::testing::UnorderedElementsAre());
}
TEST_F(WildcardSourceDependencyTest, Relative_IgnoredFile)
{
AZStd::vector<AZStd::string> resolvedPaths;
ASSERT_TRUE(Test("*z.foo", resolvedPaths));
ASSERT_THAT(resolvedPaths, ::testing::UnorderedElementsAre());
}
TEST_F(WildcardSourceDependencyTest, Absolute_IgnoredFile)
{
AZStd::vector<AZStd::string> resolvedPaths;
QDir tempPath(m_tempDir.path());
ASSERT_TRUE(Test(tempPath.absoluteFilePath("*z.foo").toUtf8().constData(), resolvedPaths));
ASSERT_THAT(resolvedPaths, ::testing::UnorderedElementsAre());
}
TEST_F(WildcardSourceDependencyTest, Relative_CacheFolder)
{
AZStd::vector<AZStd::string> resolvedPaths;
QDir tempPath(m_tempDir.path());
ASSERT_TRUE(Test("*cache.foo", resolvedPaths));
ASSERT_THAT(resolvedPaths, ::testing::UnorderedElementsAre());
}
TEST_F(WildcardSourceDependencyTest, FilesAddedAfterInitialCache)
{
AZStd::vector<AZStd::string> resolvedPaths;
QDir tempPath(m_tempDir.path());
auto excludedFolderCacheInterface = AZ::Interface<ExcludedFolderCacheInterface>::Get();
ASSERT_TRUE(excludedFolderCacheInterface);
{
const auto& excludedFolders = excludedFolderCacheInterface->GetExcludedFolders();
ASSERT_EQ(excludedFolders.size(), 2);
}
// Add a file to a new ignored folder
QString newFilePath = tempPath.absoluteFilePath("subfolder2/redirected/folder/two/ignored/three/new.foo");
UnitTestUtils::CreateDummyFile(newFilePath);
excludedFolderCacheInterface->FileAdded(newFilePath);
const auto& excludedFolders = excludedFolderCacheInterface->GetExcludedFolders();
ASSERT_EQ(excludedFolders.size(), 3);
ASSERT_THAT(excludedFolders, ::testing::Contains(AZStd::string(tempPath.absoluteFilePath("subfolder2/redirected/folder/two/ignored").toUtf8().constData())));
}
TEST_F(WildcardSourceDependencyTest, FilesRemovedAfterInitialCache)
{
AZStd::vector<AZStd::string> resolvedPaths;
QDir tempPath(m_tempDir.path());
// Add a file to a new ignored folder
QString newFilePath = tempPath.absoluteFilePath("subfolder2/redirected/folder/two/ignored/three/new.foo");
UnitTestUtils::CreateDummyFile(newFilePath);
auto excludedFolderCacheInterface = AZ::Interface<ExcludedFolderCacheInterface>::Get();
ASSERT_TRUE(excludedFolderCacheInterface);
{
const auto& excludedFolders = excludedFolderCacheInterface->GetExcludedFolders();
ASSERT_EQ(excludedFolders.size(), 3);
}
m_fileStateCache->SignalDeleteEvent(tempPath.absoluteFilePath("subfolder2/redirected/folder/two/ignored"));
const auto& excludedFolders = excludedFolderCacheInterface->GetExcludedFolders();
ASSERT_EQ(excludedFolders.size(), 2);
}
TEST_F(WildcardSourceDependencyTest, NewFile_MatchesSavedRelativeDependency)
{
QDir tempPath(m_tempDir.path());