Skip to content

[Clang-Repl] Add custom function as lambda in launchExecutor and fetch PID of launched executor #147478

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
71 changes: 59 additions & 12 deletions .ci/compute_projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
PROJECT_DEPENDENCIES = {
"llvm": set(),
"clang": {"llvm"},
"CIR": {"clang", "mlir"},
"bolt": {"clang", "lld", "llvm"},
"clang-tools-extra": {"clang", "llvm"},
"compiler-rt": {"clang", "lld"},
Expand Down Expand Up @@ -55,6 +56,7 @@
".ci": {
"llvm",
"clang",
"CIR",
"lld",
"lldb",
"bolt",
Expand Down Expand Up @@ -98,6 +100,9 @@
"libc", # No Windows Support.
"lldb", # TODO(issues/132800): Needs environment setup.
"bolt", # No Windows Support.
"libcxx",
"libcxxabi",
"libunwind",
}

# These are projects that we should test if the project itself is changed but
Expand All @@ -116,6 +121,9 @@
"lldb",
"openmp",
"polly",
"libcxx",
"libcxxabi",
"libunwind",
}

PROJECT_CHECK_TARGETS = {
Expand All @@ -128,6 +136,7 @@
"lldb": "check-lldb",
"llvm": "check-llvm",
"clang": "check-clang",
"CIR": "check-clang-cir",
"bolt": "check-bolt",
"lld": "check-lld",
"flang": "check-flang",
Expand All @@ -141,6 +150,23 @@

RUNTIMES = {"libcxx", "libcxxabi", "libunwind", "compiler-rt", "libc"}

# Meta projects are projects that need explicit handling but do not reside
# in their own top level folder. To add a meta project, the start of the path
# for the metaproject should be mapped to the name of the project below.
# Multiple paths can map to the same metaproject.
META_PROJECTS = {
("clang", "lib", "CIR"): "CIR",
("clang", "test", "CIR"): "CIR",
("clang", "include", "clang", "CIR"): "CIR",
("*", "docs"): "docs",
("llvm", "utils", "gn"): "gn",
(".github", "workflows", "premerge.yaml"): ".ci",
("third-party",): ".ci",
}

# Projects that should not run any tests. These need to be metaprojects.
SKIP_PROJECTS = ["docs", "gn"]


def _add_dependencies(projects: Set[str], runtimes: Set[str]) -> Set[str]:
projects_with_dependents = set(projects)
Expand Down Expand Up @@ -233,21 +259,34 @@ def _compute_runtimes_to_build(
return _exclude_projects(runtimes_to_build, platform)


def _path_matches(matcher: tuple[str], file_path: tuple[str]) -> bool:
if len(file_path) < len(matcher):
return False
for match_part, file_part in zip(matcher, file_path):
if match_part == "*" or file_part == "*":
continue
if match_part != file_part:
return False
return True


def _get_modified_projects_for_file(modified_file: str) -> Set[str]:
modified_projects = set()
path_parts = pathlib.Path(modified_file).parts
for meta_project_files in META_PROJECTS.keys():
if _path_matches(meta_project_files, path_parts):
meta_project = META_PROJECTS[meta_project_files]
if meta_project in SKIP_PROJECTS:
return set()
modified_projects.add(meta_project)
modified_projects.add(pathlib.Path(modified_file).parts[0])
return modified_projects


def _get_modified_projects(modified_files: list[str]) -> Set[str]:
modified_projects = set()
for modified_file in modified_files:
path_parts = pathlib.Path(modified_file).parts
# Exclude files in the docs directory. They do not impact an test
# targets and there is a separate workflow used for ensuring the
# documentation builds.
if len(path_parts) > 2 and path_parts[1] == "docs":
continue
# Exclude files for the gn build. We do not test it within premerge
# and changes occur often enough that they otherwise take up
# capacity.
if len(path_parts) > 3 and path_parts[:3] == ("llvm", "utils", "gn"):
continue
modified_projects.add(pathlib.Path(modified_file).parts[0])
modified_projects.update(_get_modified_projects_for_file(modified_file))
return modified_projects


Expand All @@ -267,6 +306,13 @@ def get_env_variables(modified_files: list[str], platform: str) -> Set[str]:
runtimes_check_targets_needs_reconfig = _compute_project_check_targets(
runtimes_to_test_needs_reconfig
)

# CIR is used as a pseudo-project in this script. It is built as part of the
# clang build, but it requires an explicit option to enable. We set that
# option here, and remove it from the projects_to_build list.
enable_cir = "ON" if "CIR" in projects_to_build else "OFF"
projects_to_build.discard("CIR")

# We use a semicolon to separate the projects/runtimes as they get passed
# to the CMake invocation and thus we need to use the CMake list separator
# (;). We use spaces to separate the check targets as they end up getting
Expand All @@ -279,6 +325,7 @@ def get_env_variables(modified_files: list[str], platform: str) -> Set[str]:
"runtimes_check_targets_needs_reconfig": " ".join(
sorted(runtimes_check_targets_needs_reconfig)
),
"enable_cir": enable_cir,
}


Expand Down
137 changes: 124 additions & 13 deletions .ci/compute_projects_test.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
"""Does some stuff."""
"""Tests for compute_projects.py"""

import unittest

Expand Down Expand Up @@ -45,16 +45,14 @@ def test_llvm_windows(self):
env_variables["project_check_targets"],
"check-clang check-clang-tools check-lld check-llvm check-mlir check-polly",
)
self.assertEqual(
env_variables["runtimes_to_build"], "libcxx;libcxxabi;libunwind"
)
self.assertEqual(env_variables["runtimes_to_build"], "")
self.assertEqual(
env_variables["runtimes_check_targets"],
"",
)
self.assertEqual(
env_variables["runtimes_check_targets_needs_reconfig"],
"check-cxx check-cxxabi check-unwind",
"",
)

def test_llvm_mac(self):
Expand All @@ -69,16 +67,14 @@ def test_llvm_mac(self):
env_variables["project_check_targets"],
"check-clang check-clang-tools check-lld check-llvm check-mlir",
)
self.assertEqual(
env_variables["runtimes_to_build"], "libcxx;libcxxabi;libunwind"
)
self.assertEqual(env_variables["runtimes_to_build"], "")
self.assertEqual(
env_variables["runtimes_check_targets"],
"",
)
self.assertEqual(
env_variables["runtimes_check_targets_needs_reconfig"],
"check-cxx check-cxxabi check-unwind",
"",
)

def test_clang(self):
Expand All @@ -104,6 +100,10 @@ def test_clang(self):
env_variables["runtimes_check_targets_needs_reconfig"],
"check-cxx check-cxxabi check-unwind",
)
self.assertEqual(
env_variables["enable_cir"],
"OFF",
)

def test_clang_windows(self):
env_variables = compute_projects.get_env_variables(
Expand All @@ -115,17 +115,41 @@ def test_clang_windows(self):
self.assertEqual(
env_variables["project_check_targets"], "check-clang check-clang-tools"
)
self.assertEqual(env_variables["runtimes_to_build"], "")
self.assertEqual(
env_variables["runtimes_to_build"], "libcxx;libcxxabi;libunwind"
env_variables["runtimes_check_targets"],
"",
)
self.assertEqual(
env_variables["runtimes_check_targets"],
env_variables["runtimes_check_targets_needs_reconfig"],
"",
)
self.assertEqual(env_variables["enable_cir"], "OFF")

def test_cir(self):
env_variables = compute_projects.get_env_variables(
["clang/lib/CIR/CMakeLists.txt"], "Linux"
)
self.assertEqual(
env_variables["projects_to_build"],
"clang;clang-tools-extra;lld;llvm;mlir",
)
self.assertEqual(
env_variables["project_check_targets"],
"check-clang check-clang-cir check-clang-tools",
)
self.assertEqual(
env_variables["runtimes_to_build"], "compiler-rt;libcxx;libcxxabi;libunwind"
)
self.assertEqual(
env_variables["runtimes_check_targets"],
"check-compiler-rt",
)
self.assertEqual(
env_variables["runtimes_check_targets_needs_reconfig"],
"check-cxx check-cxxabi check-unwind",
)
self.assertEqual(env_variables["enable_cir"], "ON")

def test_bolt(self):
env_variables = compute_projects.get_env_variables(
Expand Down Expand Up @@ -158,6 +182,7 @@ def test_mlir(self):
self.assertEqual(env_variables["runtimes_to_build"], "")
self.assertEqual(env_variables["runtimes_check_targets"], "")
self.assertEqual(env_variables["runtimes_check_targets_needs_reconfig"], "")
self.assertEqual(env_variables["enable_cir"], "OFF")

def test_flang(self):
env_variables = compute_projects.get_env_variables(
Expand All @@ -168,10 +193,11 @@ def test_flang(self):
self.assertEqual(env_variables["runtimes_to_build"], "")
self.assertEqual(env_variables["runtimes_check_targets"], "")
self.assertEqual(env_variables["runtimes_check_targets_needs_reconfig"], "")
self.assertEqual(env_variables["enable_cir"], "OFF")

def test_invalid_subproject(self):
env_variables = compute_projects.get_env_variables(
["third-party/benchmark/CMakeLists.txt"], "Linux"
["llvm-libgcc/CMakeLists.txt"], "Linux"
)
self.assertEqual(env_variables["projects_to_build"], "")
self.assertEqual(env_variables["project_check_targets"], "")
Expand Down Expand Up @@ -237,7 +263,7 @@ def test_ci(self):
)
self.assertEqual(
env_variables["project_check_targets"],
"check-bolt check-clang check-clang-tools check-flang check-lld check-lldb check-llvm check-mlir check-polly",
"check-bolt check-clang check-clang-cir check-clang-tools check-flang check-lld check-lldb check-llvm check-mlir check-polly",
)
self.assertEqual(
env_variables["runtimes_to_build"],
Expand All @@ -252,6 +278,31 @@ def test_ci(self):
"check-cxx check-cxxabi check-unwind",
)

def test_windows_ci(self):
env_variables = compute_projects.get_env_variables(
[".ci/compute_projects.py"], "Windows"
)
self.assertEqual(
env_variables["projects_to_build"],
"clang;clang-tools-extra;libclc;lld;llvm;mlir;polly",
)
self.assertEqual(
env_variables["project_check_targets"],
"check-clang check-clang-cir check-clang-tools check-lld check-llvm check-mlir check-polly",
)
self.assertEqual(
env_variables["runtimes_to_build"],
"",
)
self.assertEqual(
env_variables["runtimes_check_targets"],
"",
)
self.assertEqual(
env_variables["runtimes_check_targets_needs_reconfig"],
"",
)

def test_lldb(self):
env_variables = compute_projects.get_env_variables(
["lldb/CMakeLists.txt"], "Linux"
Expand All @@ -276,6 +327,66 @@ def test_clang_tools_extra(self):
self.assertEqual(env_variables["runtimes_check_targets"], "check-libc")
self.assertEqual(env_variables["runtimes_check_targets_needs_reconfig"], "")

def test_premerge_workflow(self):
env_variables = compute_projects.get_env_variables(
[".github/workflows/premerge.yaml"], "Linux"
)
self.assertEqual(
env_variables["projects_to_build"],
"bolt;clang;clang-tools-extra;flang;libclc;lld;lldb;llvm;mlir;polly",
)
self.assertEqual(
env_variables["project_check_targets"],
"check-bolt check-clang check-clang-cir check-clang-tools check-flang check-lld check-lldb check-llvm check-mlir check-polly",
)
self.assertEqual(
env_variables["runtimes_to_build"],
"compiler-rt;libc;libcxx;libcxxabi;libunwind",
)
self.assertEqual(
env_variables["runtimes_check_targets"],
"check-compiler-rt check-libc",
)
self.assertEqual(
env_variables["runtimes_check_targets_needs_reconfig"],
"check-cxx check-cxxabi check-unwind",
)

def test_other_github_workflow(self):
env_variables = compute_projects.get_env_variables(
[".github/workflows/docs.yml"], "Linux"
)
self.assertEqual(env_variables["projects_to_build"], "")
self.assertEqual(env_variables["project_check_targets"], "")
self.assertEqual(env_variables["runtimes_to_build"], "")
self.assertEqual(env_variables["runtimes_check_targets"], "")
self.assertEqual(env_variables["runtimes_check_targets_needs_reconfig"], "")

def test_third_party_benchmark(self):
env_variables = compute_projects.get_env_variables(
["third-party/benchmark/CMakeLists.txt"], "Linux"
)
self.assertEqual(
env_variables["projects_to_build"],
"bolt;clang;clang-tools-extra;flang;libclc;lld;lldb;llvm;mlir;polly",
)
self.assertEqual(
env_variables["project_check_targets"],
"check-bolt check-clang check-clang-cir check-clang-tools check-flang check-lld check-lldb check-llvm check-mlir check-polly",
)
self.assertEqual(
env_variables["runtimes_to_build"],
"compiler-rt;libc;libcxx;libcxxabi;libunwind",
)
self.assertEqual(
env_variables["runtimes_check_targets"],
"check-compiler-rt check-libc",
)
self.assertEqual(
env_variables["runtimes_check_targets_needs_reconfig"],
"check-cxx check-cxxabi check-unwind",
)


if __name__ == "__main__":
unittest.main()
13 changes: 8 additions & 5 deletions .ci/generate_test_report_github.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,23 @@
"""Script to generate a build report for Github."""

import argparse
import platform

import generate_test_report_lib

PLATFORM_TITLES = {
"Windows": ":window: Windows x64 Test Results",
"Linux": ":penguin: Linux x64 Test Results",
}

if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument(
"title", help="Title of the test report, without Markdown formatting."
)
parser.add_argument("return_code", help="The build's return code.", type=int)
parser.add_argument("junit_files", help="Paths to JUnit report files.", nargs="*")
args = parser.parse_args()

report, _ = generate_test_report_lib.generate_report_from_files(
args.title, args.return_code, args.junit_files, None
report = generate_test_report_lib.generate_report_from_files(
PLATFORM_TITLES[platform.system()], args.return_code, args.junit_files
)

print(report)
Loading