+}
+
+build_Tests()
+{
+ __TestDir=$__ProjectDir/tests
+ __ProjectFilesDir=$__TestDir
+ __TestBinDir=$__TestWorkingDir
+
+ if [ $__RebuildTests -ne 0 ]; then
+ if [ -d "${__TestBinDir}" ]; then
+ echo "Removing tests build dir: ${__TestBinDir}"
+ rm -rf $__TestBinDir
+ fi
+ fi
+
+ __CMakeBinDir="${__TestBinDir}"
+
+ if [ -z "$__TestIntermediateDir" ]; then
+ __TestIntermediateDir="tests/obj/${__BuildOS}.${__BuildArch}.${__BuildType}"
+ fi
+
+ echo "__BuildOS: ${__BuildOS}"
+ echo "__BuildArch: ${__BuildArch}"
+ echo "__BuildType: ${__BuildType}"
+ echo "__TestIntermediateDir: ${__TestIntermediateDir}"
+
+ if [ ! -f "$__TestBinDir" ]; then
+ echo "Creating TestBinDir: ${__TestBinDir}"
+ mkdir -p $__TestBinDir
+ fi
+ if [ ! -f "$__LogsDir" ]; then
+ echo "Creating LogsDir: ${__LogsDir}"
+ mkdir -p $__LogsDir
+ fi
+
+ __BuildProperties="-p:OSGroup=${__BuildOS} -p:BuildOS=${__BuildOS} -p:BuildArch=${__BuildArch} -p:BuildType=${__BuildType}"
+
+ # =========================================================================================
+ # ===
+ # === Restore product binaries from packages
+ # ===
+ # =========================================================================================
+
+ build_Tests_internal "Restore_Product" "${__ProjectDir}/tests/build.proj" " -BatchRestorePackages" "Restore product binaries (build tests)"
+
+ if [ -n "$__BuildAgainstPackagesArg" ]; then
+ build_Tests_internal "Tests_GenerateRuntimeLayout" "${__ProjectDir}/tests/runtest.proj" "-BinPlaceRef -BinPlaceProduct -CopyCrossgenToProduct" "Restore product binaries (run tests)"
+ fi