Integrating github/staging through commit 5f214be
This commit is contained in:
@@ -81,7 +81,7 @@ namespace UnitTests
|
||||
// Product: "someproduct4.dds" subid: 4
|
||||
void CreateCoverageTestData()
|
||||
{
|
||||
m_data->m_scanFolder = { "c:/lumberyard/dev", "dev", "rootportkey", "" };
|
||||
m_data->m_scanFolder = { "c:/O3DE/dev", "dev", "rootportkey", "" };
|
||||
ASSERT_TRUE(m_data->m_connection.SetScanFolder(m_data->m_scanFolder));
|
||||
|
||||
m_data->m_sourceFile1 = { m_data->m_scanFolder.m_scanFolderID, "somefile.tif", AZ::Uuid::CreateRandom(), "AnalysisFingerprint1"};
|
||||
@@ -239,7 +239,7 @@ namespace UnitTests
|
||||
// we'll create all of those first (except product) before starting the product test.
|
||||
|
||||
//add a scanfolder. None of this has to exist in real disk, this is a db test only.
|
||||
ScanFolderDatabaseEntry scanFolder {"c:/lumberyard/dev", "dev", "rootportkey", ""};
|
||||
ScanFolderDatabaseEntry scanFolder {"c:/O3DE/dev", "dev", "rootportkey", ""};
|
||||
EXPECT_TRUE(m_data->m_connection.SetScanFolder(scanFolder));
|
||||
ASSERT_NE(scanFolder.m_scanFolderID, AzToolsFramework::AssetDatabase::InvalidEntryId);
|
||||
|
||||
@@ -278,7 +278,7 @@ namespace UnitTests
|
||||
// to add a product legitimately you have to have a full chain of primary keys, chain is:
|
||||
// ScanFolder --> Source --> job --> product.
|
||||
// we'll create all of those first (except product) before starting the product test.
|
||||
ScanFolderDatabaseEntry scanFolder{ "c:/lumberyard/dev", "dev", "rootportkey", "" };
|
||||
ScanFolderDatabaseEntry scanFolder{ "c:/O3DE/dev", "dev", "rootportkey", "" };
|
||||
ASSERT_TRUE(m_data->m_connection.SetScanFolder(scanFolder));
|
||||
|
||||
SourceDatabaseEntry sourceEntry{ scanFolder.m_scanFolderID, "somefile.tif", AZ::Uuid::CreateRandom(), "fingerprint1" };
|
||||
@@ -323,7 +323,7 @@ namespace UnitTests
|
||||
// this is actually a very common case (same job id, same subID)
|
||||
TEST_F(AssetDatabaseTest, SetProduct_SpecificPK_Succeeds_SameSubID_SameJobID)
|
||||
{
|
||||
ScanFolderDatabaseEntry scanFolder{ "c:/lumberyard/dev", "dev", "rootportkey", "" };
|
||||
ScanFolderDatabaseEntry scanFolder{ "c:/O3DE/dev", "dev", "rootportkey", "" };
|
||||
ASSERT_TRUE(m_data->m_connection.SetScanFolder(scanFolder));
|
||||
SourceDatabaseEntry sourceEntry{ scanFolder.m_scanFolderID, "somefile.tif", AZ::Uuid::CreateRandom(), "fingerprint1" };
|
||||
ASSERT_TRUE(m_data->m_connection.SetSource(sourceEntry));
|
||||
|
||||
@@ -4540,9 +4540,17 @@ void ModtimeScanningTest::TearDown()
|
||||
|
||||
void ModtimeScanningTest::ProcessAssetJobs()
|
||||
{
|
||||
m_data->m_productPaths.clear();
|
||||
|
||||
for (const auto& processResult : m_data->m_processResults)
|
||||
{
|
||||
auto file = QDir(processResult.m_destinationPath).absoluteFilePath(processResult.m_jobEntry.m_databaseSourceName + ".arc1");
|
||||
m_data->m_productPaths.emplace(
|
||||
QDir(processResult.m_jobEntry.m_watchFolderPath)
|
||||
.absoluteFilePath(processResult.m_jobEntry.m_databaseSourceName)
|
||||
.toUtf8()
|
||||
.constData(),
|
||||
file);
|
||||
|
||||
// Create the file on disk
|
||||
ASSERT_TRUE(UnitTestUtils::CreateDummyFile(file, "products."));
|
||||
@@ -4793,6 +4801,123 @@ TEST_F(ModtimeScanningTest, ModtimeSkipping_ModifyFile_AndThenRevert_ProcessesAg
|
||||
ExpectWork(2, 2);
|
||||
}
|
||||
|
||||
struct LockedFileTest
|
||||
: ModtimeScanningTest
|
||||
, AssetProcessor::ConnectionBus::Handler
|
||||
{
|
||||
MOCK_METHOD3(SendRaw, size_t (unsigned, unsigned, const QByteArray&));
|
||||
MOCK_METHOD3(SendPerPlatform, size_t (unsigned, const AzFramework::AssetSystem::BaseAssetProcessorMessage&, const QString&));
|
||||
MOCK_METHOD4(SendRawPerPlatform, size_t (unsigned, unsigned, const QByteArray&, const QString&));
|
||||
MOCK_METHOD2(SendRequest, unsigned (const AzFramework::AssetSystem::BaseAssetProcessorMessage&, const ResponseCallback&));
|
||||
MOCK_METHOD2(SendResponse, size_t (unsigned, const AzFramework::AssetSystem::BaseAssetProcessorMessage&));
|
||||
MOCK_METHOD1(RemoveResponseHandler, void (unsigned));
|
||||
|
||||
size_t Send(unsigned, const AzFramework::AssetSystem::BaseAssetProcessorMessage&) override
|
||||
{
|
||||
if(m_callback)
|
||||
{
|
||||
m_callback();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void SetUp() override
|
||||
{
|
||||
ModtimeScanningTest::SetUp();
|
||||
|
||||
ConnectionBus::Handler::BusConnect(0);
|
||||
}
|
||||
|
||||
void TearDown() override
|
||||
{
|
||||
ConnectionBus::Handler::BusDisconnect();
|
||||
|
||||
ModtimeScanningTest::TearDown();
|
||||
}
|
||||
|
||||
AZStd::function<void()> m_callback;
|
||||
};
|
||||
|
||||
TEST_F(LockedFileTest, DeleteFile_LockedProduct_DeleteFails)
|
||||
{
|
||||
auto theFile = m_data->m_absolutePath[1].toUtf8();
|
||||
const char* theFileString = theFile.constData();
|
||||
auto [sourcePath, productPath] = *m_data->m_productPaths.find(theFileString);
|
||||
|
||||
{
|
||||
QFile file(theFileString);
|
||||
file.remove();
|
||||
}
|
||||
|
||||
ASSERT_GT(m_data->m_productPaths.size(), 0);
|
||||
QFile product(productPath);
|
||||
|
||||
ASSERT_TRUE(product.open(QIODevice::ReadOnly));
|
||||
|
||||
// Check if we can delete the file now, if we can't, proceed with the test
|
||||
// If we can, it means the OS running this test doesn't lock open files so there's nothing to test
|
||||
if (!AZ::IO::SystemFile::Delete(productPath.toUtf8().constData()))
|
||||
{
|
||||
QMetaObject::invokeMethod(
|
||||
m_assetProcessorManager.get(), "AssessDeletedFile", Qt::QueuedConnection, Q_ARG(QString, QString(theFileString)));
|
||||
|
||||
EXPECT_TRUE(BlockUntilIdle(5000));
|
||||
|
||||
EXPECT_TRUE(QFile::exists(productPath));
|
||||
EXPECT_EQ(m_data->m_deletedSources.size(), 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
SUCCEED() << "Skipping test. OS does not lock open files.";
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(LockedFileTest, DeleteFile_LockedProduct_DeletesWhenReleased)
|
||||
{
|
||||
auto theFile = m_data->m_absolutePath[1].toUtf8();
|
||||
const char* theFileString = theFile.constData();
|
||||
auto [sourcePath, productPath] = *m_data->m_productPaths.find(theFileString);
|
||||
|
||||
{
|
||||
QFile file(theFileString);
|
||||
file.remove();
|
||||
}
|
||||
|
||||
ASSERT_GT(m_data->m_productPaths.size(), 0);
|
||||
QFile product(productPath);
|
||||
|
||||
ASSERT_TRUE(product.open(QIODevice::ReadOnly));
|
||||
|
||||
// Check if we can delete the file now, if we can't, proceed with the test
|
||||
// If we can, it means the OS running this test doesn't lock open files so there's nothing to test
|
||||
if (!AZ::IO::SystemFile::Delete(productPath.toUtf8().constData()))
|
||||
{
|
||||
AZStd::thread workerThread;
|
||||
|
||||
m_callback = [&product, &workerThread]() {
|
||||
workerThread = AZStd::thread([&product]() {
|
||||
AZStd::this_thread::sleep_for(AZStd::chrono::milliseconds(60));
|
||||
product.close();
|
||||
});
|
||||
};
|
||||
|
||||
QMetaObject::invokeMethod(
|
||||
m_assetProcessorManager.get(), "AssessDeletedFile", Qt::QueuedConnection, Q_ARG(QString, QString(theFileString)));
|
||||
|
||||
EXPECT_TRUE(BlockUntilIdle(5000));
|
||||
|
||||
EXPECT_FALSE(QFile::exists(productPath));
|
||||
EXPECT_EQ(m_data->m_deletedSources.size(), 1);
|
||||
|
||||
workerThread.join();
|
||||
}
|
||||
else
|
||||
{
|
||||
SUCCEED() << "Skipping test. OS does not lock open files.";
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(ModtimeScanningTest, ModtimeSkipping_ModifyFilesSameHash_BothProcess)
|
||||
{
|
||||
using namespace AzToolsFramework::AssetSystem;
|
||||
|
||||
@@ -174,6 +174,7 @@ struct ModtimeScanningTest
|
||||
QString m_relativePathFromWatchFolder[3];
|
||||
AZStd::vector<QString> m_absolutePath;
|
||||
AZStd::vector<AssetProcessor::JobDetails> m_processResults;
|
||||
AZStd::unordered_multimap<AZStd::string, QString> m_productPaths;
|
||||
AZStd::vector<QString> m_deletedSources;
|
||||
AZStd::shared_ptr<AssetProcessor::InternalMockBuilder> m_builderTxtBuilder;
|
||||
MockBuilderInfoHandler m_mockBuilderInfoHandler;
|
||||
|
||||
Reference in New Issue
Block a user