REGISTER_TESTS_END // BuildGenerate //------------------------------------------------------------------------------ FBuildStats TestUnity::BuildGenerate( FBuildOptions options, bool useDB ) const { options.m_ConfigFile = "Data/TestUnity/unity.bff"; options.m_ShowSummary = true; // required to generate stats for node count checks FBuild fBuild( options ); TEST_ASSERT( fBuild.Initialize( useDB ? GetTestGenerateDBFileName() : nullptr ) ); // Implement Unity and activate this test TEST_ASSERT( fBuild.Build( AStackString<>( "Unity-Test" ) ) ); TEST_ASSERT( fBuild.SaveDependencyGraph( GetTestGenerateDBFileName() ) ); return fBuild.GetStats(); }
// TestZiDebugFormat_Local //------------------------------------------------------------------------------ void TestDistributed::TestZiDebugFormat_Local() const { FBuildOptions options; options.m_ConfigFile = "Data/TestDistributed/fbuild.bff"; options.m_AllowDistributed = true; options.m_ForceCleanBuild = true; FBuild fBuild( options ); JobQueueRemote jqr( 1 ); // start a client to emulate the other end Server s; s.Listen( Protocol::PROTOCOL_PORT ); TEST_ASSERT( fBuild.Initialize() ); TEST_ASSERT( fBuild.Build( AStackString<>( "remoteZi" ) ) ); }
REGISTER_TESTS_END // Build //------------------------------------------------------------------------------ FBuildStats TestPrecompiledHeaders::Build( FBuildOptions options, bool useDB ) const { options.m_ConfigFile = "Data/TestPrecompiledHeaders/fbuild.bff"; options.m_ShowSummary = true; // required to generate stats for node count checks FBuild fBuild( options ); TEST_ASSERT( fBuild.Initialize( useDB ? GetPCHDBFileName() : nullptr ) ); AStackString<> target( "PCHTest" ); TEST_ASSERT( fBuild.Build( target ) ); TEST_ASSERT( fBuild.SaveDependencyGraph( GetPCHDBFileName() ) ); return fBuild.GetStats(); }
// TestMultipleAssemblies_NoRebuild //------------------------------------------------------------------------------ void TestCSharp::TestMultipleAssemblies_NoRebuild() const { FBuildTestOptions options; options.m_ConfigFile = "Tools/FBuild/FBuildTest/Data/TestCSharp/csharp.bff"; FBuild fBuild( options ); TEST_ASSERT( fBuild.Initialize( "../tmp/Test/CSharp/csharpmultipleassemblies.fdb" ) ); // Build it TEST_ASSERT( fBuild.Build( AStackString<>( "CSharp-AssemblyC" ) ) ); // Check stats // Seen, Built, Type CheckStatsNode ( 1, 0, Node::COMPILER_NODE ); CheckStatsNode ( 3, 3, Node::FILE_NODE ); // 3x cs CheckStatsNode ( 3, 0, Node::CS_NODE ); CheckStatsNode ( 1, 1, Node::ALIAS_NODE ); CheckStatsTotal( 8, 4 ); }
// TestMultipleAssemblies_NoRebuild //------------------------------------------------------------------------------ void TestCSharp::TestMultipleAssemblies_NoRebuild() const { FBuildOptions options; options.m_ConfigFile = "Data/TestCSharp/csharp.bff"; options.m_ShowSummary = true; // required to generate stats for node count checks FBuild fBuild( options ); TEST_ASSERT( fBuild.Initialize( "../../../../tmp/Test/CSharp/csharpmultipleassemblies.fdb" ) ); // Build it TEST_ASSERT( fBuild.Build( AStackString<>( "CSharp-AssemblyC" ) ) ); // Check stats // Seen, Built, Type CheckStatsNode ( 3, 3, Node::FILE_NODE ); // 2x cs CheckStatsNode ( 3, 0, Node::CS_NODE ); CheckStatsNode ( 1, 1, Node::ALIAS_NODE ); CheckStatsTotal( 7, 4 ); }
// TestSingleFile_NoRebuild //------------------------------------------------------------------------------ void TestCSharp::TestSingleFile_NoRebuild() const { FBuildOptions options; options.m_ConfigFile = "Data/TestCSharp/csharp.bff"; options.m_ShowSummary = true; // required to generate stats for node count checks FBuild fBuild( options ); TEST_ASSERT( fBuild.Initialize( "../../../../tmp/Test/CSharp/csharpsingle.fdb" ) ); // Build it TEST_ASSERT( fBuild.Build( AStackString<>( "CSharp-Single-Target" ) ) ); // Check stats // Seen, Built, Type CheckStatsNode ( 1, 1, Node::FILE_NODE ); // cs CheckStatsNode ( 1, 0, Node::CS_NODE ); CheckStatsNode ( 1, 1, Node::ALIAS_NODE ); CheckStatsTotal( 3, 2 ); }
// BuildResource_NoRebuild //------------------------------------------------------------------------------ void TestResources::BuildResource_NoRebuild() const { FBuildOptions options; options.m_ConfigFile = "Data/TestResources/fbuild.bff"; options.m_ShowSummary = true; // required to generate stats for node count checks FBuild fBuild( options ); fBuild.Initialize( "..\\..\\..\\..\\ftmp\\Test\\Resources\\resource.fdb" ); TEST_ASSERT( fBuild.Build( AStackString<>( "exe" ) ) ); // Check stats // Seen, Built, Type // NOTE: Don't test file nodes since test used windows.h CheckStatsNode ( 2, 0, Node::OBJECT_NODE ); CheckStatsNode ( 1, 0, Node::OBJECT_LIST_NODE ); CheckStatsNode ( 1, 0, Node::LIBRARY_NODE ); CheckStatsNode ( 1, 1, Node::ALIAS_NODE ); CheckStatsNode ( 1, 0, Node::EXE_NODE ); }
// XCode //------------------------------------------------------------------------------ void TestProjectGeneration::XCode() const { AStackString<> project( "../../../../ftmp/Test/ProjectGeneration/Test.xcodeproj/project.pbxproj" ); EnsureFileDoesNotExist( project ); // do build FBuildOptions options; options.m_ConfigFile = "Data/TestProjectGeneration/xcodeproject.bff"; options.m_ShowSummary = true; // required to generate stats for node count checks FBuild fBuild( options ); TEST_ASSERT( fBuild.Initialize() ); TEST_ASSERT( fBuild.Build( AStackString<>( "XCodeProj" ) ) ); // Check stats // Seen, Built, Type CheckStatsNode ( 0, 0, Node::DIRECTORY_LIST_NODE ); CheckStatsNode ( 1, 1, Node::XCODEPROJECT_NODE ); CheckStatsNode ( 1, 1, Node::ALIAS_NODE ); CheckStatsTotal( 2, 2 ); }
// TestMultipleAssemblies_NoRebuild_BFFChange //------------------------------------------------------------------------------ void TestCSharp::TestMultipleAssemblies_NoRebuild_BFFChange() const { FBuildOptions options; options.m_ConfigFile = "Tools/FBuild/FBuildTest/Data/TestCSharp/csharp.bff"; options.m_ShowSummary = true; // required to generate stats for node count checks options.m_ForceDBMigration_Debug = true; FBuild fBuild( options ); TEST_ASSERT( fBuild.Initialize( "../tmp/Test/CSharp/csharpmultipleassemblies.fdb" ) ); // Build it TEST_ASSERT( fBuild.Build( AStackString<>( "CSharp-AssemblyC" ) ) ); // Check stats // Seen, Built, Type CheckStatsNode ( 1, 1, Node::COMPILER_NODE ); // Compiler rebuilds after migration CheckStatsNode ( 3, 3, Node::FILE_NODE ); // 3x cs CheckStatsNode ( 3, 0, Node::CS_NODE ); CheckStatsNode ( 1, 1, Node::ALIAS_NODE ); CheckStatsTotal( 8, 5 ); }
// TestSingleFile_NoRebuild_BFFChange //------------------------------------------------------------------------------ void TestCSharp::TestSingleFile_NoRebuild_BFFChange() const { FBuildOptions options; options.m_ConfigFile = "Tools/FBuild/FBuildTest//Data/TestCSharp/csharp.bff"; options.m_ShowSummary = true; // required to generate stats for node count checks options.m_ForceDBMigration_Debug = true; FBuild fBuild( options ); TEST_ASSERT( fBuild.Initialize( "../tmp/Test/CSharp/csharpsingle.fdb" ) ); // Build it TEST_ASSERT( fBuild.Build( AStackString<>( "CSharp-Single-Target" ) ) ); // Check stats // Seen, Built, Type CheckStatsNode ( 1, 1, Node::COMPILER_NODE); // Compiler rebuilds after migration CheckStatsNode ( 1, 1, Node::FILE_NODE ); // 1 cs file CheckStatsNode ( 1, 0, Node::CS_NODE ); CheckStatsNode ( 1, 1, Node::ALIAS_NODE ); CheckStatsTotal( 4, 3 ); }
// TestZiDebugFormat //------------------------------------------------------------------------------ void TestDistributed::TestZiDebugFormat() const { FBuildOptions options; options.m_ConfigFile = "Data/TestDistributed/fbuild.bff"; options.m_AllowDistributed = true; options.m_NumWorkerThreads = 0; options.m_NoLocalConsumptionOfRemoteJobs = true; // ensure all jobs happen on the remote worker options.m_AllowLocalRace = false; options.m_ForceCleanBuild = true; FBuild fBuild( options ); JobQueueRemote jqr( 1 ); // start a client to emulate the other end Server s; s.Listen( Protocol::PROTOCOL_PORT ); TEST_ASSERT( fBuild.Initialize() ); TEST_ASSERT( fBuild.Build( AStackString<>( "remoteZi" ) ) ); }
// TestSingleDLL_NoRebuild //------------------------------------------------------------------------------ void TestDLL::TestSingleDLL_NoRebuild() const { FBuildOptions options; options.m_ConfigFile = "Data/TestDLL/fbuild.bff"; options.m_ShowSummary = true; // required to generate stats for node count checks FBuild fBuild( options ); TEST_ASSERT( fBuild.Initialize( GetSingleDLLDBFileName() ) ); const AStackString<> dll( "../../../../tmp/Test/DLL/dll.dll" ); TEST_ASSERT( fBuild.Build( dll ) ); // Check stats // Seen, Built, Type CheckStatsNode ( 3, 3, Node::FILE_NODE ); // cpp + 2 .h CheckStatsNode ( 1, 0, Node::COMPILER_NODE ); CheckStatsNode ( 1, 0, Node::OBJECT_NODE ); CheckStatsNode ( 1, 0, Node::OBJECT_LIST_NODE ); CheckStatsNode ( 1, 0, Node::DLL_NODE ); CheckStatsTotal( 7, 3 ); }
REGISTER_TESTS_END // BuildResource //------------------------------------------------------------------------------ void TestResources::BuildResource() const { FBuildOptions options; options.m_ConfigFile = "Data/TestResources/fbuild.bff"; options.m_ForceCleanBuild = true; options.m_ShowSummary = true; // required to generate stats for node count checks FBuild fBuild( options ); fBuild.Initialize(); const AStackString<> binRes( "../../../../ftmp/Test/Resources/resource.res" ); // clean up anything left over from previous runs EnsureFileDoesNotExist( "binRes" ); TEST_ASSERT( fBuild.Build( AStackString<>( "exe" ) ) ); TEST_ASSERT( fBuild.SaveDependencyGraph( "..\\..\\..\\..\\ftmp\\Test\\Resources\\resource.fdb" ) ); // make sure all output files are as expected EnsureFileExists( binRes ); // spawn exe which does a runtime check that the resource is availble Process p; p.Spawn( "..\\..\\..\\..\\ftmp\\Test\\Resources\\exe.exe", nullptr, nullptr, nullptr ); int ret = p.WaitForExit(); TEST_ASSERT( ret == 1 ); // verify expected ret code // Check stats // Seen, Built, Type // NOTE: Don't test file nodes since test used windows.h CheckStatsNode ( 2, 2, Node::OBJECT_NODE ); CheckStatsNode ( 1, 1, Node::OBJECT_LIST_NODE ); CheckStatsNode ( 1, 1, Node::LIBRARY_NODE ); CheckStatsNode ( 1, 1, Node::ALIAS_NODE ); CheckStatsNode ( 1, 1, Node::EXE_NODE ); }
// TestFunction_NoRebuild //------------------------------------------------------------------------------ void TestProjectGeneration::TestFunction_NoRebuild() const { AStackString<> project( "../../../../ftmp/Test/ProjectGeneration/testproj.vcxproj" ); AStackString<> filters( "../../../../ftmp/Test/ProjectGeneration/testproj.vcxproj.filters" ); EnsureFileExists( project ); EnsureFileExists( filters ); // Projects and Solutions must be "built" every time, but only write files when they change // so record the time before and after uint64_t dateTime1 = FileIO::GetFileLastWriteTime( project ); uint64_t dateTime2 = FileIO::GetFileLastWriteTime( filters ); // NTFS file resolution is 100ns and HFS is 1 second, // so sleep long enough to ensure an invalid write would modify the time #if defined( __WINDOWS__ ) Thread::Sleep( 1 ); // 1ms #else Thread::Sleep( 1000 ); // 1 second #endif // do build FBuildOptions options; options.m_ConfigFile = "Data/TestProjectGeneration/fbuild.bff"; options.m_ShowSummary = true; // required to generate stats for node count checks FBuild fBuild( options ); TEST_ASSERT( fBuild.Initialize( "../../../../ftmp/Test/ProjectGeneration/fbuild.fdb" ) ); TEST_ASSERT( fBuild.Build( AStackString<>( "TestProj" ) ) ); // Make sure files have not been changed TEST_ASSERT( dateTime1 == FileIO::GetFileLastWriteTime( project ) ); TEST_ASSERT( dateTime2 == FileIO::GetFileLastWriteTime( filters ) ); // Check stats // Seen, Built, Type CheckStatsNode ( 1, 1, Node::DIRECTORY_LIST_NODE ); CheckStatsNode ( 1, 1, Node::VCXPROJECT_NODE ); CheckStatsNode ( 1, 1, Node::ALIAS_NODE ); CheckStatsTotal( 3, 3 ); }
// TestTwoDLLs_NoRebuild //------------------------------------------------------------------------------ void TestDLL::TestTwoDLLs_NoRebuild() const { FBuildOptions options; options.m_ConfigFile = "Data/TestDLL/fbuild.bff"; options.m_ShowSummary = true; // required to generate stats for node count checks FBuild fBuild( options ); TEST_ASSERT( fBuild.Initialize( GetTwoDLLsDBFileName() ) ); // build again const AStackString<> dllB( "../../../../tmp/Test/DLL/dllB.dll" ); TEST_ASSERT( fBuild.Build( dllB ) ); // Check stats to be sure nothing was built // Check stats // Seen, Built, Type CheckStatsNode ( 5, 5, Node::FILE_NODE ); // 2 cpp files + 3 .h CheckStatsNode ( 1, 0, Node::COMPILER_NODE ); CheckStatsNode ( 2, 0, Node::OBJECT_NODE ); CheckStatsNode ( 2, 0, Node::OBJECT_LIST_NODE ); CheckStatsNode ( 2, 0, Node::DLL_NODE ); CheckStatsTotal( 12, 5 ); }
// Build_NoRebuild //------------------------------------------------------------------------------ void TestExe::Build_NoRebuild() const { FBuildOptions options; options.m_ConfigFile = "Data/TestExe/exe.bff"; options.m_ShowSummary = true; // required to generate stats for node count checks FBuild fBuild( options ); TEST_ASSERT( fBuild.Initialize( "../../../../tmp/Test/Exe/exe.fdb" ) ); // build (via alias) TEST_ASSERT( fBuild.Build( AStackString<>( "Exe" ) ) ); // Check stats // Seen, Built, Type CheckStatsNode ( 1, 1, Node::FILE_NODE ); // cpp CheckStatsNode ( 1, 0, Node::COMPILER_NODE ); CheckStatsNode ( 1, 0, Node::OBJECT_NODE ); CheckStatsNode ( 1, 0, Node::OBJECT_LIST_NODE ); CheckStatsNode ( 1, 0, Node::EXE_NODE ); CheckStatsNode ( 1, 1, Node::ALIAS_NODE ); CheckStatsTotal( 6, 2 ); }
// TestPCHClangWithCache_NoRebuild //------------------------------------------------------------------------------ void TestPrecompiledHeaders::TestPCHClangWithCache_NoRebuild() const { FBuildOptions options; options.m_ConfigFile = "Data/TestPrecompiledHeaders/fbuild.bff"; options.m_ShowSummary = true; // required to generate stats for node count checks FBuild fBuild( options ); TEST_ASSERT( fBuild.Initialize( GetPCHDBClangFileName() ) ); AStackString<> target( "PCHTestClang" ); TEST_ASSERT( fBuild.Build( target ) ); TEST_ASSERT( fBuild.SaveDependencyGraph( GetPCHDBClangFileName() ) ); // Check stats // Seen, Built, Type CheckStatsNode ( 2, 2, Node::FILE_NODE ); // cpp + pch CheckStatsNode ( 1, 0, Node::COMPILER_NODE ); CheckStatsNode ( 2, 0, Node::OBJECT_NODE );// obj + pch obj CheckStatsNode ( 1, 0, Node::OBJECT_LIST_NODE ); CheckStatsTotal( 6, 2 ); }
// TestPCHClang //------------------------------------------------------------------------------ void TestPrecompiledHeaders::TestPCHClang() const { FBuildOptions options; options.m_ConfigFile = "Data/TestPrecompiledHeaders/fbuild.bff"; options.m_ForceCleanBuild = true; options.m_UseCacheWrite = true; options.m_ShowSummary = true; // required to generate stats for node count checks #if defined( __WINDOWS__ ) AStackString<> obj( "../../../../ftmp/Test/PrecompiledHeaders/Clang/PCHUser.obj" ); #else AStackString<> obj( "../../../../ftmp/Test/PrecompiledHeaders/Clang/PCHUser.o" ); #endif AStackString<> pch( "../../../../ftmp/Test/PrecompiledHeaders/Clang/PrecompiledHeader.pch" ); EnsureFileDoesNotExist( obj ); EnsureFileDoesNotExist( pch ); FBuild fBuild( options ); TEST_ASSERT( fBuild.Initialize( nullptr ) ); AStackString<> target( "PCHTestClang" ); TEST_ASSERT( fBuild.Build( target ) ); TEST_ASSERT( fBuild.SaveDependencyGraph( GetPCHDBClangFileName() ) ); EnsureFileExists( obj ); EnsureFileExists( pch ); // Check stats // Seen, Built, Type CheckStatsNode ( 2, 2, Node::FILE_NODE ); // cpp + pch CheckStatsNode ( 1, 1, Node::COMPILER_NODE ); CheckStatsNode ( 2, 2, Node::OBJECT_NODE );// obj + pch obj CheckStatsNode ( 1, 1, Node::OBJECT_LIST_NODE ); CheckStatsTotal( 6, 6 ); // check we wrote all objects to the cache TEST_ASSERT( fBuild.GetStats().GetStatsFor( Node::OBJECT_NODE ).m_NumCacheStores == 2 ); // can store the pch & the obj using it }
REGISTER_TESTS_END // Build //------------------------------------------------------------------------------ void TestCUDA::Build() const { FBuildOptions options; options.m_ConfigFile = "Data/TestCUDA/cuda.bff"; options.m_ForceCleanBuild = true; options.m_UseCacheWrite = true; options.m_ShowSummary = true; // required to generate stats for node count checks FBuild fBuild( options ); TEST_ASSERT( fBuild.Initialize() ); const AStackString<> obj( "../../../../tmp/Test/CUDA/test.obj" ); // clean up anything left over from previous runs EnsureFileDoesNotExist( obj ); // build (via alias) TEST_ASSERT( fBuild.Build( AStackString<>( "CUDA-Obj" ) ) ); TEST_ASSERT( fBuild.SaveDependencyGraph( "../../../../tmp/Test/CUDA/cuda.fdb" ) ); // make sure all output is where it is expected EnsureFileExists( obj ); // Check stats // Seen, Built, Type CheckStatsNode ( 65, 1, Node::FILE_NODE ); // many included files CheckStatsNode ( 1, 1, Node::COMPILER_NODE ); CheckStatsNode ( 1, 1, Node::OBJECT_NODE ); CheckStatsNode ( 1, 1, Node::OBJECT_LIST_NODE ); CheckStatsTotal( 68, 4 ); // Test cache was stored to const FBuildStats::Stats & objStats = fBuild.GetStats().GetStatsFor( Node::OBJECT_NODE ); TEST_ASSERT( objStats.m_NumCacheStores == 1 ); }
// TestExeWithDLL_NoRebuild //------------------------------------------------------------------------------ void TestDLL::TestExeWithDLL_NoRebuild() const { FBuildOptions options; options.m_ConfigFile = "Data/TestDLL/fbuild.bff"; options.m_ShowSummary = true; // required to generate stats for node count checks FBuild fBuild( options ); TEST_ASSERT( fBuild.Initialize( GetExeWithDLLDBFileName() ) ); const AStackString<> exe( "../../../../tmp/Test/DLL/exe.exe" ); // build executable with depends on DLLA TEST_ASSERT( fBuild.Build( exe ) ); // Check stats // Seen, Built, Type CheckStatsNode ( 4, 4, Node::FILE_NODE ); // 2 cpp + a.h + precompiledheader.h CheckStatsNode ( 1, 0, Node::COMPILER_NODE ); CheckStatsNode ( 2, 0, Node::OBJECT_NODE ); // exe.obj + a.obj CheckStatsNode ( 2, 0, Node::OBJECT_LIST_NODE ); // exe lib + dll lib CheckStatsNode ( 1, 0, Node::DLL_NODE ); CheckStatsNode ( 1, 0, Node::EXE_NODE ); CheckStatsTotal( 11, 4 ); }
// TestLinkWithCopy //------------------------------------------------------------------------------ void TestDLL::TestLinkWithCopy() const { FBuildOptions options; options.m_ConfigFile = "Data/TestDLL/fbuild.bff"; options.m_ShowSummary = true; // required to generate stats for node count checks options.m_ForceCleanBuild = true; FBuild fBuild( options ); TEST_ASSERT( fBuild.Initialize() ); // build executable with depends on DLLA TEST_ASSERT( fBuild.Build( AStackString<>( "DllBUsingCopy" ) ) ); // Check stats // Seen, Built, Type CheckStatsNode ( 2, 2, Node::COPY_NODE ); CheckStatsNode ( 5, 2, Node::FILE_NODE ); CheckStatsNode ( 1, 1, Node::COMPILER_NODE ); CheckStatsNode ( 2, 2, Node::OBJECT_NODE ); CheckStatsNode ( 2, 2, Node::OBJECT_LIST_NODE ); CheckStatsNode ( 2, 2, Node::DLL_NODE ); CheckStatsNode ( 1, 1, Node::ALIAS_NODE ); CheckStatsTotal( 15, 12 ); }
// TestLibMerge_NoRebuild //------------------------------------------------------------------------------ void TestBuildAndLinkLibrary::TestLibMerge_NoRebuild() const { FBuildOptions options; options.m_ConfigFile = "Data/TestBuildAndLinkLibrary/fbuild.bff"; options.m_ShowSummary = true; // required to generate stats for node count checks FBuild fBuild( options ); TEST_ASSERT( fBuild.Initialize( GetMergeLibDBFileName() ) ); const AStackString<> lib( "../../../../tmp/Test/BuildAndLinkLibrary/merged.lib" ); // Build TEST_ASSERT( fBuild.Build( lib ) ); // Check stats // Seen, Built, Type CheckStatsNode ( 7, 7, Node::FILE_NODE ); // 3 cpps + 3 headers + librarian CheckStatsNode ( 1, 0, Node::COMPILER_NODE ); CheckStatsNode ( 1, 0, Node::OBJECT_LIST_NODE ); CheckStatsNode ( 3, 0, Node::OBJECT_NODE ); CheckStatsNode ( 3, 0, Node::LIBRARY_NODE ); // 2 libs + merge lib CheckStatsTotal( 15, 7 ); }
// Build_NoRebuild //------------------------------------------------------------------------------ void TestCUDA::Build_NoRebuild() const { FBuildOptions options; options.m_ConfigFile = "Data/TestCUDA/cuda.bff"; options.m_ShowSummary = true; // required to generate stats for node count checks FBuild fBuild( options ); TEST_ASSERT( fBuild.Initialize( "../../../../tmp/Test/CUDA/cuda.fdb" ) ); const AStackString<> obj( "../../../../tmp/Test/CUDA/test.obj" ); // build (via alias) TEST_ASSERT( fBuild.Build( AStackString<>( "CUDA-Obj" ) ) ); // make sure all output is where it is expected EnsureFileExists( obj ); // Check stats // Seen, Built, Type CheckStatsNode ( 65, 65, Node::FILE_NODE ); // many included files CheckStatsNode ( 1, 0, Node::COMPILER_NODE ); CheckStatsNode ( 1, 0, Node::OBJECT_NODE ); CheckStatsNode ( 1, 0, Node::OBJECT_LIST_NODE ); CheckStatsTotal( 68, 65 ); }
REGISTER_TESTS_END // TestStaleDynamicDeps //------------------------------------------------------------------------------ void TestObject::TestStaleDynamicDeps() const { const char* fileA = "../../../../ftmp/Test/Object/StaleDynamicDeps/GeneratedInput/FileA.h"; const char* fileB = "../../../../ftmp/Test/Object/StaleDynamicDeps/GeneratedInput/FileB.h"; const char* fileC = "../../../../ftmp/Test/Object/StaleDynamicDeps/GeneratedInput/FileC.h"; const char* database = "../../../../ftmp/Test/Object/StaleDynamicDeps/fbuild.fdb"; // Generate some header files { // Need FBuild for CleanPath FBuildOptions options; FBuild fBuild( options ); // Ensure output path exists AStackString<> fullOutputPath; NodeGraph::CleanPath( AStackString<>( fileA ), fullOutputPath ); TEST_ASSERT( Node::EnsurePathExistsForFile( fullOutputPath ) ); // Create files FileStream f; TEST_ASSERT( f.Open( fileA, FileStream::WRITE_ONLY ) ); f.Close(); TEST_ASSERT( f.Open( fileB, FileStream::WRITE_ONLY ) ); f.Close(); TEST_ASSERT( f.Open( fileC, FileStream::WRITE_ONLY ) ); f.Close(); } // Build CPP Generator { // Init FBuildOptions options; options.m_ConfigFile = "Data/TestObject/StaleDynamicDeps/cppgenerator.bff"; options.m_ForceCleanBuild = true; FBuild fBuild( options ); TEST_ASSERT( fBuild.Initialize() ); // Compile TEST_ASSERT( fBuild.Build( AStackString<>( "CPPGenerator" ) ) ); } // Build using CPP Generator (clean) { // Init FBuildOptions options; options.m_ConfigFile = "Data/TestObject/StaleDynamicDeps/staledeps.bff"; options.m_ForceCleanBuild = true; options.m_ShowSummary = true; // required to generate stats for node count checks FBuild fBuild( options ); TEST_ASSERT( fBuild.Initialize() ); // Compile TEST_ASSERT( fBuild.Build( AStackString<>( "StaleDynamicDeps" ) ) ); // Save DB TEST_ASSERT( fBuild.SaveDependencyGraph( database ) ); // Check stats // Seen, Built, Type CheckStatsNode ( 1, 1, Node::DIRECTORY_LIST_NODE ); CheckStatsNode ( 2, 2, Node::COMPILER_NODE ); CheckStatsNode ( 4, 4, Node::OBJECT_NODE ); // 3xCPPGen + 1xUnity } // Delete one of the generated headers EnsureFileDoesNotExist( fileB ); // Work around poor time resolution of file system on OSX by waiting at least 1 second // TODO:C Changes to the way dependencies are managed might make this unnecessary #if defined( __OSX__ ) Thread::Sleep(1001); #endif // Build Again { // Init FBuildOptions options; options.m_ConfigFile = "Data/TestObject/StaleDynamicDeps/staledeps.bff"; options.m_ShowSummary = true; // required to generate stats for node count checks FBuild fBuild( options ); TEST_ASSERT( fBuild.Initialize( database ) ); // Compile TEST_ASSERT( fBuild.Build( AStackString<>( "StaleDynamicDeps" ) ) ); // Check stats // Seen, Built, Type CheckStatsNode ( 1, 1, Node::DIRECTORY_LIST_NODE ); CheckStatsNode ( 2, 0, Node::COMPILER_NODE ); CheckStatsNode ( 3, 1, Node::OBJECT_NODE ); // 3xCPPGen + 1xUnity, rebuild of unity } }