Skip to content

Commit

Permalink
[CI] Added MSVC 2022 test (grpc#36236)
Browse files Browse the repository at this point in the history
- Added Visual C++ 2022 test to Windows C/C++ test set
- Windows potability test is now running two tests
  - CMake / Ninja / Visual C++ 2019 on x86
  - CMake / MSBuild / Visual C++ 2022 on x64

Closes grpc#36236

COPYBARA_INTEGRATE_REVIEW=grpc#36236 from veblush:vc2022 1000853
PiperOrigin-RevId: 623244062
  • Loading branch information
veblush authored and copybara-github committed Apr 9, 2024
1 parent 4e735be commit d3a92c9
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 43 deletions.
24 changes: 19 additions & 5 deletions tools/run_tests/helper_scripts/build_cxx.bat
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,18 @@ If "%GRPC_BUILD_ACTIVATE_VS_TOOLS%" == "2019" (
echo on
)

If "%GRPC_BUILD_ACTIVATE_VS_TOOLS%" == "2022" (
@rem set cl.exe build environment to build with VS2022 tooling
@rem this is required for Ninja build to work
call "%VS170COMNTOOLS%..\..\VC\Auxiliary\Build\vcvarsall.bat" %GRPC_BUILD_VS_TOOLS_ARCHITECTURE%
@rem restore command echo
echo on
)

@rem Setting the env variable to a single space translates to passing no argument
@rem when evaluated on the command line.
set "CMAKE_SYSTEM_VERSION_ARG= "

If "%GRPC_CMAKE_GENERATOR%" == "Visual Studio 16 2019" (
@rem Always use the newest Windows 10 SDK available.
@rem A new-enough Windows 10 SDK that supports C++11's stdalign.h is required
Expand All @@ -41,10 +53,11 @@ If "%GRPC_CMAKE_GENERATOR%" == "Visual Studio 16 2019" (
@rem When using Ninja generator, this problem doesn't happen.
@rem See b/275694647 and https://gitlab.kitware.com/cmake/cmake/-/issues/16202#note_140259
set "CMAKE_SYSTEM_VERSION_ARG=-DCMAKE_SYSTEM_VERSION=10.0"
) else (
@rem Setting the env variable to a single space translates to passing no argument
@rem when evaluated on the command line.
set "CMAKE_SYSTEM_VERSION_ARG= "
)

If "%GRPC_CMAKE_GENERATOR%" == "Visual Studio 17 2022" (
@rem The same as above.
set "CMAKE_SYSTEM_VERSION_ARG=-DCMAKE_SYSTEM_VERSION=10.0"
)

If "%GRPC_CMAKE_GENERATOR%" == "Ninja" (
Expand Down Expand Up @@ -105,7 +118,8 @@ If "%GRPC_CMAKE_GENERATOR%" == "Ninja" (
cmake -G "%GRPC_CMAKE_GENERATOR%" -A "%GRPC_CMAKE_ARCHITECTURE%" %CMAKE_SYSTEM_VERSION_ARG% -DCMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE=x64 -DgRPC_BUILD_GRPCPP_OTEL_PLUGIN=ON -DgRPC_ABSL_PROVIDER=package -DgRPC_BUILD_TESTS=ON -DgRPC_BUILD_MSVC_MP_COUNT=%GRPC_RUN_TESTS_JOBS% -DCMAKE_INSTALL_PREFIX="%INSTALL_PATH%" %* ../.. || goto :error

@rem GRPC_RUN_TESTS_CXX_LANGUAGE_SUFFIX will be set to either "c" or "cxx"
cmake --build . --target buildtests_%GRPC_RUN_TESTS_CXX_LANGUAGE_SUFFIX% --config %MSBUILD_CONFIG% -j%GRPC_RUN_TESTS_JOBS% || goto :error
@rem Don't add -j option here because it will disable gRPC_BUILD_MSVC_MP_COUNT option
cmake --build . --target buildtests_%GRPC_RUN_TESTS_CXX_LANGUAGE_SUFFIX% --config %MSBUILD_CONFIG% || goto :error
)

endlocal
Expand Down
5 changes: 5 additions & 0 deletions tools/run_tests/run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ def configure(self, config, args):
"default",
"cmake",
"cmake_ninja_vs2019",
"cmake_ninja_vs2022",
"cmake_vs2019",
"cmake_vs2022",
],
Expand All @@ -300,6 +301,9 @@ def configure(self, config, args):
# the compiler used is exactly the same as for cmake_vs2017
cmake_generator = "Ninja"
activate_vs_tools = "2019"
elif self.args.compiler == "cmake_ninja_vs2022":
cmake_generator = "Ninja"
activate_vs_tools = "2022"
elif self.args.compiler == "cmake_vs2019":
cmake_generator = "Visual Studio 16 2019"
elif self.args.compiler == "cmake_vs2022":
Expand Down Expand Up @@ -1678,6 +1682,7 @@ def _build_and_run(
"coreclr",
"cmake",
"cmake_ninja_vs2019",
"cmake_ninja_vs2022",
"cmake_vs2019",
"cmake_vs2022",
"mono",
Expand Down
47 changes: 9 additions & 38 deletions tools/run_tests/run_tests_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,62 +377,33 @@ def _create_portability_test_jobs(
timeout_seconds=_CPP_RUNTESTS_TIMEOUT,
)

# portability C on Windows 64-bit (x86 is the default)
# portability C & C++ on Windows 64-bit
test_jobs += _generate_jobs(
languages=["c"],
languages=["c", "c++"],
configs=["dbg"],
platforms=["windows"],
arch="x64",
compiler="default",
arch="default",
compiler="cmake_ninja_vs2019",
labels=["portability", "corelang"],
extra_args=extra_args,
inner_jobs=inner_jobs,
timeout_seconds=_CPP_RUNTESTS_TIMEOUT,
)

# portability C on Windows with the "Visual Studio" cmake
# portability C and C++ on Windows with the "Visual Studio 2022" cmake
# generator, i.e. not using Ninja (to verify that we can still build with msbuild)
test_jobs += _generate_jobs(
languages=["c"],
languages=["c", "c++"],
configs=["dbg"],
platforms=["windows"],
arch="default",
compiler="cmake_vs2019",
arch="x64",
compiler="cmake_vs2022",
labels=["portability", "corelang"],
extra_args=extra_args,
inner_jobs=inner_jobs,
)

# portability C++ on Windows
# TODO(jtattermusch): some of the tests are failing, so we force --build_only
test_jobs += _generate_jobs(
languages=["c++"],
configs=["dbg"],
platforms=["windows"],
arch="default",
compiler="default",
labels=["portability", "corelang"],
extra_args=extra_args + ["--build_only"],
inner_jobs=inner_jobs,
timeout_seconds=_CPP_RUNTESTS_TIMEOUT,
)

# portability C and C++ on Windows using VS2019 (build only)
# TODO(jtattermusch): The C tests with exactly the same config are already running as part of the
# basictests_c suite (so we force --build_only to avoid running them twice).
# The C++ tests aren't all passing, so also force --build_only.
# NOTE(veblush): This is not neded as default=cmake_ninja_vs2019
# test_jobs += _generate_jobs(
# languages=["c", "c++"],
# configs=["dbg"],
# platforms=["windows"],
# arch="x64",
# compiler="cmake_ninja_vs2019",
# labels=["portability", "corelang"],
# extra_args=extra_args + ["--build_only"],
# inner_jobs=inner_jobs,
# timeout_seconds=_CPP_RUNTESTS_TIMEOUT,
# )

# C and C++ with no-exceptions on Linux
test_jobs += _generate_jobs(
languages=["c", "c++"],
Expand Down

0 comments on commit d3a92c9

Please sign in to comment.