From 0b5bdf94a207a9facfcdd17eb34362ffca845212 Mon Sep 17 00:00:00 2001 From: Wes Haggard Date: Wed, 15 Feb 2017 15:37:29 -0800 Subject: [PATCH] Adds -tests option for build.cmd that will add the test build and running --- .../building/build-tests-against-packages.md | 52 ------------------- Documentation/project-docs/developer-guide.md | 5 ++ build-tests.cmd | 2 +- build-tests.sh | 2 +- build.proj | 1 + config.json | 23 ++++---- 6 files changed, 20 insertions(+), 65 deletions(-) delete mode 100644 Documentation/building/build-tests-against-packages.md diff --git a/Documentation/building/build-tests-against-packages.md b/Documentation/building/build-tests-against-packages.md deleted file mode 100644 index 0d9b63a34d40..000000000000 --- a/Documentation/building/build-tests-against-packages.md +++ /dev/null @@ -1,52 +0,0 @@ -# Building Tests Against Packages - -## Usage Scenarios - -### Build the product locally and then test what you've built - -In this scenario, you produce a product build, including packages, then generate test project.json's which reference the locally built package versions and finally build tests compiling against the local packages. - -1. Build the product and packages - - ```Build.cmd -BuildTests=false``` -2. Generate Test project.json files - - ```sync.cmd -t -- /p:"SkipCleanPackages=true" /p:"PackagesDrops=[ProjectDir]bin/packages/[Release|Debug]/"``` - - /p:SkipCleanPackages=true is required for release branches where the packages folder is cleaned during every build. -3. Build Tests against packages - - ```build-tests.cmd -BuildTestsAgainstPackages -- /p:"PackagesDrops=[ProjectDir]bin/packages/[Release|Debug]/"``` - - -BuildTestsAgainstPackages tells the build to use the project.json files you generated in the "Generate Test project.json files" step - - /p:"PackagesDrops=[ProjectDir]bin/packages/[Release|Debug]/" tells the build to use the packages from your local build drop. - -### Download product from an Azure blob - -This scenario skips the product build step, and instead downloads packages from Azure blob storage - -1. Sync product from Azure - - ```sync.cmd -ab -AzureAccount=dotnetbuildoutput -AzureToken=******** -Container=[Azure container name] -- /p:"DownloadDirectory=[ProjectDir]Packages\AzureTransfer" /p:"SkipCleanPackages=true"``` -2. Generate Test project.json files - - ```sync.cmd -t -- /p:"SkipCleanPackages=true" /p:"PackagesDrops=[ProjectDir]Packages/AzureTransfer/[Release|Debug]/"``` - - /p:SkipCleanPackages=true is required for release branches where the packages folder is cleaned during every build. -3. Build Tests against packages - - ```build-tests.cmd -BuildTestsAgainstPackages -- /p:"PackagesDrops=[ProjectDir]Packages/AzureTransfer/[Release|Debug]/"``` - - -BuildTestsAgainstPackages tells the build to use the project.json files you generated in the "Generate Test project.json files" step - - /p:"PackagesDrops=[ProjectDir]Packages/AzureTransfer/[Release|Debug]/" tells the build to use the packages from the Azure download (DownloadDirectory). - -### Use a versions file for specifying package versions - -This scenario uses a versions file (https://github.com/dotnet/versions/blob/master/build-info/dotnet/corefx/master/Latest_Packages.txt, for example) to determine what package versions to build tests against. - -1. Generate Test project.json files using a 'versions' file. - - ```sync.cmd -t -- /p:"SkipCleanPackages=true" /p:"VersionsFiles=[local version file path]"``` - - /p:SkipCleanPackages=true is required for release branches where the packages folder is cleaned during every build. -2. Build Tests against packages - - ```build-tests.cmd -BuildTestsAgainstPackages -- /p:"PackagesDrops=[ProjectDir]bin/packages/[Release|Debug]/"``` - - -BuildTestsAgainstPackages tells the build to use the project.json files you generated in the "Generate Test project.json files" step - - /p:"PackagesDrops=[ProjectDir]bin/packages/[Release|Debug]/" tells the build to use the packages from your local build drop. - - If the package versions you are referencing have been published publicly, you can omit the "PackagesDrops" property. - -## Common Questions - -- **How do I know it worked?** The best way is to look in the log for the compilation line ("csc.exe") and ensure that its references now point to packages (packages\blah) where previously they pointed to build product binaries (bin\blah). - -- **Why are there build failures?** Not all of our tests build nicely against package references due to differences in the public surface area (compiling against the reference assembly versus an implementation assembly). In cases where we were unable to sync / restore (packages were unavailable or other restore problems), we've opted those projects out of this process by adding "KeepAllProjectReferences" or "KeepProjectReference" (added to a Project Reference's metadata) to the test project. - -- **Where are the generated project.json files?** Generated project.json files get created under "[ProjectDir]bin/obj/generated". diff --git a/Documentation/project-docs/developer-guide.md b/Documentation/project-docs/developer-guide.md index c1979c223974..249cf4eefcfe 100644 --- a/Documentation/project-docs/developer-guide.md +++ b/Documentation/project-docs/developer-guide.md @@ -64,6 +64,11 @@ build-tests build -debug -buildArch=x64 ``` +- Building the src and then building and running the tests +``` +build -tests +``` + - Building for different target frameworks ``` build -framework netcoreapp diff --git a/build-tests.cmd b/build-tests.cmd index 3a829d9e43e4..6435941f4d5c 100644 --- a/build-tests.cmd +++ b/build-tests.cmd @@ -1,2 +1,2 @@ -@call %~dp0run.cmd build-managed -tests %* +@call %~dp0run.cmd build-managed -testsOnly %* @exit /b %ERRORLEVEL% \ No newline at end of file diff --git a/build-tests.sh b/build-tests.sh index ce36da5ede6b..b0eed8574bac 100755 --- a/build-tests.sh +++ b/build-tests.sh @@ -31,5 +31,5 @@ done export CORECLR_SERVER_GC="$__ServerGC" working_tree_root="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -$working_tree_root/run.sh build-managed -tests $__UnprocessedBuildArgs +$working_tree_root/run.sh build-managed -testsOnly $__UnprocessedBuildArgs exit $? diff --git a/build.proj b/build.proj index 7a5003bcfa71..ebafba2a61af 100644 --- a/build.proj +++ b/build.proj @@ -16,6 +16,7 @@ + diff --git a/config.json b/config.json index 54b10c3a36ef..adcb6eeb555f 100644 --- a/config.json +++ b/config.json @@ -48,12 +48,6 @@ "values": ["True", "False"], "defaultValue": true }, - "RestoreDuringBuild": { - "description": "Enables/Disables the restoration of packages.", - "valueType": "property", - "values": ["True", "False"], - "defaultValue": true - }, "BuildPackages": { "description": "Enables/Disables building packages.", "valueType": "property", @@ -262,9 +256,14 @@ "settings": { } }, "tests": { - "description": "Builds the tests that are in the repository, doesn't restore packages.", + "description": "Builds src and then builds and runs the tests for the given configuration.", + "settings": { + "BuildTests": true + } + }, + "testsOnly": { + "description": "Builds and runs the tests for the given configuration.", "settings": { - "RestoreDuringBuild": "false", "Project": "src/tests.builds", "MsBuildLogging":"/flp:v=normal;LogFile=build-tests.log" } @@ -396,7 +395,11 @@ "settings": { "StripSymbolsAdditionalArg": "stripSymbols" } - } + }, + "tests": { + "description": "No-op for build-native, included just to enable easy combination with build-managed", + "settings": { } + }, }, "defaultValues": { "toolName": "terminal", @@ -489,7 +492,6 @@ "p": { "description": "Restores all NuGet packages for repository.", "settings": { - "RestoreDuringBuild": true, "Sync": "default" } }, @@ -502,7 +504,6 @@ "t": { "description": "Deprecated, use sync /p instead.", "settings": { - "RestoreDuringBuild": true, "Sync": "default" } },