code: def test_with_cmake(args: argparse.Namespace) -> None:
      os.mkdir("build")
      with DirectoryExcursion("build"):
          if args.compiler == "mingw":
              mingw_bin = get_mingw_bin()
              CXX = os.path.join(mingw_bin, "g++.exe")
              CC = os.path.join(mingw_bin, "gcc.exe")
              env = os.environ.copy()
              env.update({"CC": CC, "CXX": CXX})
              subprocess.check_call(
                  [
                      "cmake",
                      os.path.pardir,
                      "-DUSE_OPENMP=ON",
                      "-DR_LIB=ON",
                      "-DCMAKE_CONFIGURATION_TYPES=Release",
                      "-G",
                      "Unix Makefiles",
                  ],
                  env=env,
              )
              subprocess.check_call(["make", "-j", "install"])
          elif args.compiler == "msvc":
              subprocess.check_call(
                  [
                      "cmake",
                      os.path.pardir,
                      "-DUSE_OPENMP=ON",
                      "-DR_LIB=ON",
                      "-DCMAKE_CONFIGURATION_TYPES=Release",
                      "-A",
                      "x64",
                      "-G",
                      "Visual Studio 17 2022",
                  ]
              )
              subprocess.check_call(
                  [
                      "cmake",
                      "--build",
                      os.path.curdir,
                      "--target",
                      "install",
                      "--config",
                      "Release",
                  ]
              )
          else:
              raise ValueError("Wrong compiler")
      with DirectoryExcursion(R_PACKAGE):
          subprocess.check_call(
              [
                  R,
                  "-q",
                  "-e",
                  "library(testthat); setwd('tests'); source('testthat.R')",
              ]
          )
          subprocess.check_call(
              [R, "-q", "-e", "demo(runall, package = 'xgboost')"]
          )
  
file_path: xgboost/tests/ci_build/test_r_package.py
imports: import argparse
  import os
  import shutil
  import subprocess
  from io import StringIO
  from pathlib import Path
  from platform import system
  from test_utils import R_PACKAGE, ROOT, DirectoryExcursion, cd, print_time, record_time
label_desc: Use image node_id 8 for calling a global function with example usage: test_with_cmake(args) without return types