mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
Swift: add autobuild failure diagnostics
This commit is contained in:
@@ -1,15 +1,34 @@
|
|||||||
"""
|
"""
|
||||||
recreation of internal `create_database_utils.py` to run the tests locally, with minimal
|
Simplified version of internal `create_database_utils.py` used to run the tests locally, with
|
||||||
and swift-specialized functionality
|
minimal and swift-specialized functionality
|
||||||
|
TODO unify integration testing code across the public and private repositories
|
||||||
"""
|
"""
|
||||||
import subprocess
|
import subprocess
|
||||||
import pathlib
|
import pathlib
|
||||||
import sys
|
import sys
|
||||||
|
import shutil
|
||||||
|
|
||||||
|
|
||||||
def run_codeql_database_create(cmds, lang, keep_trap=True):
|
def runSuccessfully(cmd):
|
||||||
|
res = subprocess.run(cmd)
|
||||||
|
if res.returncode:
|
||||||
|
print("FAILED", file=sys.stderr)
|
||||||
|
print(" ", *cmd, f"(exit code {res.returncode})", file=sys.stderr)
|
||||||
|
sys.exit(res.returncode)
|
||||||
|
|
||||||
|
def runUnsuccessfully(cmd):
|
||||||
|
res = subprocess.run(cmd)
|
||||||
|
if res.returncode == 0:
|
||||||
|
print("FAILED", file=sys.stderr)
|
||||||
|
print(" ", *cmd, f"(exit code 0, expected to fail)", file=sys.stderr)
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
|
def run_codeql_database_create(cmds, lang, keep_trap=True, db=None, runFunction=runSuccessfully):
|
||||||
|
""" db parameter is here solely for compatibility with the internal test runner """
|
||||||
assert lang == 'swift'
|
assert lang == 'swift'
|
||||||
codeql_root = pathlib.Path(__file__).parents[2]
|
codeql_root = pathlib.Path(__file__).parents[2]
|
||||||
|
shutil.rmtree("db", ignore_errors=True)
|
||||||
cmd = [
|
cmd = [
|
||||||
"codeql", "database", "create",
|
"codeql", "database", "create",
|
||||||
"-s", ".", "-l", "swift", "--internal-use-lua-tracing", f"--search-path={codeql_root}", "--no-cleanup",
|
"-s", ".", "-l", "swift", "--internal-use-lua-tracing", f"--search-path={codeql_root}", "--no-cleanup",
|
||||||
@@ -19,8 +38,4 @@ def run_codeql_database_create(cmds, lang, keep_trap=True):
|
|||||||
for c in cmds:
|
for c in cmds:
|
||||||
cmd += ["-c", c]
|
cmd += ["-c", c]
|
||||||
cmd.append("db")
|
cmd.append("db")
|
||||||
res = subprocess.run(cmd)
|
runFunction(cmd)
|
||||||
if res.returncode:
|
|
||||||
print("FAILED", file=sys.stderr)
|
|
||||||
print(" ", *cmd, file=sys.stderr)
|
|
||||||
sys.exit(res.returncode)
|
|
||||||
|
|||||||
64
swift/integration-tests/diagnostics_test_utils.py
Normal file
64
swift/integration-tests/diagnostics_test_utils.py
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
"""
|
||||||
|
Simplified POSIX only version of internal `diagnostics_test_utils.py` used to run the tests locally
|
||||||
|
TODO unify integration testing code across the public and private repositories
|
||||||
|
"""
|
||||||
|
|
||||||
|
import json
|
||||||
|
import pathlib
|
||||||
|
import subprocess
|
||||||
|
import os
|
||||||
|
import difflib
|
||||||
|
import sys
|
||||||
|
|
||||||
|
|
||||||
|
def _normalize_actual(test_dir, database_dir):
|
||||||
|
proc = subprocess.run(['codeql', 'database', 'export-diagnostics', '--format', 'raw', '--', database_dir],
|
||||||
|
stdout=subprocess.PIPE, universal_newlines=True, check=True, text=True)
|
||||||
|
data = proc.stdout.replace(str(test_dir.absolute()), "<test-root-directory>")
|
||||||
|
data = json.loads(data)
|
||||||
|
data[:] = [e for e in data if not e["source"]["id"].startswith("cli/")]
|
||||||
|
for e in data:
|
||||||
|
e.pop("timestamp")
|
||||||
|
return _normalize_json(data)
|
||||||
|
|
||||||
|
|
||||||
|
def _normalize_expected(test_dir):
|
||||||
|
with open(test_dir / "diagnostics.expected") as expected:
|
||||||
|
text = expected.read()
|
||||||
|
return _normalize_json(_load_concatenated_json(text))
|
||||||
|
|
||||||
|
|
||||||
|
def _load_concatenated_json(text):
|
||||||
|
text = text.lstrip()
|
||||||
|
entries = []
|
||||||
|
decoder = json.JSONDecoder()
|
||||||
|
while text:
|
||||||
|
obj, index = decoder.raw_decode(text)
|
||||||
|
entries.append(obj)
|
||||||
|
text = text[index:].lstrip()
|
||||||
|
return entries
|
||||||
|
|
||||||
|
|
||||||
|
def _normalize_json(data):
|
||||||
|
entries = [json.dumps(e, sort_keys=True, indent=2) for e in data]
|
||||||
|
entries.sort()
|
||||||
|
entries.append("")
|
||||||
|
return "\n".join(entries)
|
||||||
|
|
||||||
|
|
||||||
|
def check_diagnostics(test_dir=".", test_db="db"):
|
||||||
|
test_dir = pathlib.Path(test_dir)
|
||||||
|
test_db = pathlib.Path(test_db)
|
||||||
|
actual = _normalize_actual(test_dir, test_db)
|
||||||
|
if os.environ.get("CODEQL_INTEGRATION_TEST_LEARN") == "true":
|
||||||
|
with open(test_dir / "diagnostics.expected", "w") as expected:
|
||||||
|
expected.write(actual)
|
||||||
|
return
|
||||||
|
expected = _normalize_expected(test_dir)
|
||||||
|
if actual != expected:
|
||||||
|
with open(test_dir / "diagnostics.actual", "w") as actual_out:
|
||||||
|
actual_out.write(actual)
|
||||||
|
actual = actual.splitlines(keepends=True)
|
||||||
|
expected = expected.splitlines(keepends=True)
|
||||||
|
print("".join(difflib.unified_diff(actual, expected, fromfile="diagnostics.actual", tofile="diagnostics.expected")), file=sys.stderr)
|
||||||
|
sys.exit(1)
|
||||||
1
swift/integration-tests/osx-only/autobuilder/failure/.gitignore
vendored
Normal file
1
swift/integration-tests/osx-only/autobuilder/failure/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
/build
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"helpLinks": [
|
||||||
|
"https://docs.github.com/en/enterprise-server/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/customizing-code-scanning"
|
||||||
|
],
|
||||||
|
"plaintextMessage": "The detected build command failed (tried /usr/bin/xcodebuild build -project <test-root-directory>/hello-failure.xcodeproj -target hello-failure CODE_SIGNING_REQUIRED=NO CODE_SIGNING_ALLOWED=NO).\n\nSet up a manual build command.",
|
||||||
|
"severity": "error",
|
||||||
|
"source": {
|
||||||
|
"extractorName": "swift",
|
||||||
|
"id": "swift/autobuilder/build-command-failed",
|
||||||
|
"name": "Detected build command failed"
|
||||||
|
},
|
||||||
|
"visibility": {
|
||||||
|
"cliSummaryTable": true,
|
||||||
|
"statusPage": true,
|
||||||
|
"telemetry": true
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,364 @@
|
|||||||
|
// !$*UTF8*$!
|
||||||
|
{
|
||||||
|
archiveVersion = 1;
|
||||||
|
classes = {
|
||||||
|
};
|
||||||
|
objectVersion = 56;
|
||||||
|
objects = {
|
||||||
|
|
||||||
|
/* Begin PBXBuildFile section */
|
||||||
|
5700ECA72A09043B006BF37C /* hello_failureApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5700ECA62A09043B006BF37C /* hello_failureApp.swift */; };
|
||||||
|
5700ECA92A09043B006BF37C /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5700ECA82A09043B006BF37C /* ContentView.swift */; };
|
||||||
|
5700ECAB2A09043C006BF37C /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 5700ECAA2A09043C006BF37C /* Assets.xcassets */; };
|
||||||
|
5700ECAE2A09043C006BF37C /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 5700ECAD2A09043C006BF37C /* Preview Assets.xcassets */; };
|
||||||
|
/* End PBXBuildFile section */
|
||||||
|
|
||||||
|
/* Begin PBXFileReference section */
|
||||||
|
5700ECA32A09043B006BF37C /* hello-failure.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "hello-failure.app"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
|
5700ECA62A09043B006BF37C /* hello_failureApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = hello_failureApp.swift; sourceTree = "<group>"; };
|
||||||
|
5700ECA82A09043B006BF37C /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
|
||||||
|
5700ECAA2A09043C006BF37C /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
|
||||||
|
5700ECAD2A09043C006BF37C /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; };
|
||||||
|
/* End PBXFileReference section */
|
||||||
|
|
||||||
|
/* Begin PBXFrameworksBuildPhase section */
|
||||||
|
5700ECA02A09043B006BF37C /* Frameworks */ = {
|
||||||
|
isa = PBXFrameworksBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
};
|
||||||
|
/* End PBXFrameworksBuildPhase section */
|
||||||
|
|
||||||
|
/* Begin PBXGroup section */
|
||||||
|
5700EC9A2A09043B006BF37C = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
5700ECA52A09043B006BF37C /* hello-failure */,
|
||||||
|
5700ECA42A09043B006BF37C /* Products */,
|
||||||
|
);
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
5700ECA42A09043B006BF37C /* Products */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
5700ECA32A09043B006BF37C /* hello-failure.app */,
|
||||||
|
);
|
||||||
|
name = Products;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
5700ECA52A09043B006BF37C /* hello-failure */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
5700ECA62A09043B006BF37C /* hello_failureApp.swift */,
|
||||||
|
5700ECA82A09043B006BF37C /* ContentView.swift */,
|
||||||
|
5700ECAA2A09043C006BF37C /* Assets.xcassets */,
|
||||||
|
5700ECAC2A09043C006BF37C /* Preview Content */,
|
||||||
|
);
|
||||||
|
path = "hello-failure";
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
5700ECAC2A09043C006BF37C /* Preview Content */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
5700ECAD2A09043C006BF37C /* Preview Assets.xcassets */,
|
||||||
|
);
|
||||||
|
path = "Preview Content";
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
/* End PBXGroup section */
|
||||||
|
|
||||||
|
/* Begin PBXNativeTarget section */
|
||||||
|
5700ECA22A09043B006BF37C /* hello-failure */ = {
|
||||||
|
isa = PBXNativeTarget;
|
||||||
|
buildConfigurationList = 5700ECB12A09043C006BF37C /* Build configuration list for PBXNativeTarget "hello-failure" */;
|
||||||
|
buildPhases = (
|
||||||
|
5700ECB42A090460006BF37C /* ShellScript */,
|
||||||
|
5700EC9F2A09043B006BF37C /* Sources */,
|
||||||
|
5700ECA02A09043B006BF37C /* Frameworks */,
|
||||||
|
5700ECA12A09043B006BF37C /* Resources */,
|
||||||
|
);
|
||||||
|
buildRules = (
|
||||||
|
);
|
||||||
|
dependencies = (
|
||||||
|
);
|
||||||
|
name = "hello-failure";
|
||||||
|
productName = "hello-failure";
|
||||||
|
productReference = 5700ECA32A09043B006BF37C /* hello-failure.app */;
|
||||||
|
productType = "com.apple.product-type.application";
|
||||||
|
};
|
||||||
|
/* End PBXNativeTarget section */
|
||||||
|
|
||||||
|
/* Begin PBXProject section */
|
||||||
|
5700EC9B2A09043B006BF37C /* Project object */ = {
|
||||||
|
isa = PBXProject;
|
||||||
|
attributes = {
|
||||||
|
BuildIndependentTargetsInParallel = 1;
|
||||||
|
LastSwiftUpdateCheck = 1430;
|
||||||
|
LastUpgradeCheck = 1430;
|
||||||
|
TargetAttributes = {
|
||||||
|
5700ECA22A09043B006BF37C = {
|
||||||
|
CreatedOnToolsVersion = 14.3;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
buildConfigurationList = 5700EC9E2A09043B006BF37C /* Build configuration list for PBXProject "hello-failure" */;
|
||||||
|
compatibilityVersion = "Xcode 14.0";
|
||||||
|
developmentRegion = en;
|
||||||
|
hasScannedForEncodings = 0;
|
||||||
|
knownRegions = (
|
||||||
|
en,
|
||||||
|
Base,
|
||||||
|
);
|
||||||
|
mainGroup = 5700EC9A2A09043B006BF37C;
|
||||||
|
productRefGroup = 5700ECA42A09043B006BF37C /* Products */;
|
||||||
|
projectDirPath = "";
|
||||||
|
projectRoot = "";
|
||||||
|
targets = (
|
||||||
|
5700ECA22A09043B006BF37C /* hello-failure */,
|
||||||
|
);
|
||||||
|
};
|
||||||
|
/* End PBXProject section */
|
||||||
|
|
||||||
|
/* Begin PBXResourcesBuildPhase section */
|
||||||
|
5700ECA12A09043B006BF37C /* Resources */ = {
|
||||||
|
isa = PBXResourcesBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
5700ECAE2A09043C006BF37C /* Preview Assets.xcassets in Resources */,
|
||||||
|
5700ECAB2A09043C006BF37C /* Assets.xcassets in Resources */,
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
};
|
||||||
|
/* End PBXResourcesBuildPhase section */
|
||||||
|
|
||||||
|
/* Begin PBXShellScriptBuildPhase section */
|
||||||
|
5700ECB42A090460006BF37C /* ShellScript */ = {
|
||||||
|
isa = PBXShellScriptBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
);
|
||||||
|
inputFileListPaths = (
|
||||||
|
);
|
||||||
|
inputPaths = (
|
||||||
|
);
|
||||||
|
outputFileListPaths = (
|
||||||
|
);
|
||||||
|
outputPaths = (
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
shellPath = /bin/sh;
|
||||||
|
shellScript = "false\n";
|
||||||
|
showEnvVarsInLog = 0;
|
||||||
|
};
|
||||||
|
/* End PBXShellScriptBuildPhase section */
|
||||||
|
|
||||||
|
/* Begin PBXSourcesBuildPhase section */
|
||||||
|
5700EC9F2A09043B006BF37C /* Sources */ = {
|
||||||
|
isa = PBXSourcesBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
5700ECA92A09043B006BF37C /* ContentView.swift in Sources */,
|
||||||
|
5700ECA72A09043B006BF37C /* hello_failureApp.swift in Sources */,
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
};
|
||||||
|
/* End PBXSourcesBuildPhase section */
|
||||||
|
|
||||||
|
/* Begin XCBuildConfiguration section */
|
||||||
|
5700ECAF2A09043C006BF37C /* Debug */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
buildSettings = {
|
||||||
|
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||||
|
CLANG_ANALYZER_NONNULL = YES;
|
||||||
|
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
|
||||||
|
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
|
||||||
|
CLANG_ENABLE_MODULES = YES;
|
||||||
|
CLANG_ENABLE_OBJC_ARC = YES;
|
||||||
|
CLANG_ENABLE_OBJC_WEAK = YES;
|
||||||
|
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
||||||
|
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||||
|
CLANG_WARN_COMMA = YES;
|
||||||
|
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||||
|
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
|
||||||
|
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||||
|
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
|
||||||
|
CLANG_WARN_EMPTY_BODY = YES;
|
||||||
|
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||||
|
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||||
|
CLANG_WARN_INT_CONVERSION = YES;
|
||||||
|
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||||
|
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
|
||||||
|
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||||
|
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||||
|
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
|
||||||
|
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||||
|
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
||||||
|
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||||
|
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
|
||||||
|
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||||
|
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||||
|
COPY_PHASE_STRIP = NO;
|
||||||
|
DEBUG_INFORMATION_FORMAT = dwarf;
|
||||||
|
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||||
|
ENABLE_TESTABILITY = YES;
|
||||||
|
GCC_C_LANGUAGE_STANDARD = gnu11;
|
||||||
|
GCC_DYNAMIC_NO_PIC = NO;
|
||||||
|
GCC_NO_COMMON_BLOCKS = YES;
|
||||||
|
GCC_OPTIMIZATION_LEVEL = 0;
|
||||||
|
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||||
|
"DEBUG=1",
|
||||||
|
"$(inherited)",
|
||||||
|
);
|
||||||
|
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||||
|
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||||
|
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||||
|
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||||
|
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||||
|
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||||
|
IPHONEOS_DEPLOYMENT_TARGET = 16.4;
|
||||||
|
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
|
||||||
|
MTL_FAST_MATH = YES;
|
||||||
|
ONLY_ACTIVE_ARCH = YES;
|
||||||
|
SDKROOT = iphoneos;
|
||||||
|
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
|
||||||
|
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||||
|
};
|
||||||
|
name = Debug;
|
||||||
|
};
|
||||||
|
5700ECB02A09043C006BF37C /* Release */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
buildSettings = {
|
||||||
|
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||||
|
CLANG_ANALYZER_NONNULL = YES;
|
||||||
|
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
|
||||||
|
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
|
||||||
|
CLANG_ENABLE_MODULES = YES;
|
||||||
|
CLANG_ENABLE_OBJC_ARC = YES;
|
||||||
|
CLANG_ENABLE_OBJC_WEAK = YES;
|
||||||
|
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
||||||
|
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||||
|
CLANG_WARN_COMMA = YES;
|
||||||
|
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||||
|
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
|
||||||
|
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||||
|
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
|
||||||
|
CLANG_WARN_EMPTY_BODY = YES;
|
||||||
|
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||||
|
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||||
|
CLANG_WARN_INT_CONVERSION = YES;
|
||||||
|
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||||
|
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
|
||||||
|
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||||
|
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||||
|
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
|
||||||
|
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||||
|
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
||||||
|
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||||
|
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
|
||||||
|
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||||
|
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||||
|
COPY_PHASE_STRIP = NO;
|
||||||
|
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||||
|
ENABLE_NS_ASSERTIONS = NO;
|
||||||
|
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||||
|
GCC_C_LANGUAGE_STANDARD = gnu11;
|
||||||
|
GCC_NO_COMMON_BLOCKS = YES;
|
||||||
|
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||||
|
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||||
|
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||||
|
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||||
|
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||||
|
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||||
|
IPHONEOS_DEPLOYMENT_TARGET = 16.4;
|
||||||
|
MTL_ENABLE_DEBUG_INFO = NO;
|
||||||
|
MTL_FAST_MATH = YES;
|
||||||
|
SDKROOT = iphoneos;
|
||||||
|
SWIFT_COMPILATION_MODE = wholemodule;
|
||||||
|
SWIFT_OPTIMIZATION_LEVEL = "-O";
|
||||||
|
VALIDATE_PRODUCT = YES;
|
||||||
|
};
|
||||||
|
name = Release;
|
||||||
|
};
|
||||||
|
5700ECB22A09043C006BF37C /* Debug */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
buildSettings = {
|
||||||
|
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||||
|
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
|
||||||
|
CODE_SIGN_STYLE = Automatic;
|
||||||
|
CURRENT_PROJECT_VERSION = 1;
|
||||||
|
DEVELOPMENT_ASSET_PATHS = "\"hello-failure/Preview Content\"";
|
||||||
|
ENABLE_PREVIEWS = YES;
|
||||||
|
GENERATE_INFOPLIST_FILE = YES;
|
||||||
|
INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES;
|
||||||
|
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
|
||||||
|
INFOPLIST_KEY_UILaunchScreen_Generation = YES;
|
||||||
|
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
|
||||||
|
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
|
||||||
|
LD_RUNPATH_SEARCH_PATHS = (
|
||||||
|
"$(inherited)",
|
||||||
|
"@executable_path/Frameworks",
|
||||||
|
);
|
||||||
|
MARKETING_VERSION = 1.0;
|
||||||
|
PRODUCT_BUNDLE_IDENTIFIER = "com.example.hello-failure";
|
||||||
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
|
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||||
|
SWIFT_VERSION = 5.0;
|
||||||
|
TARGETED_DEVICE_FAMILY = "1,2";
|
||||||
|
};
|
||||||
|
name = Debug;
|
||||||
|
};
|
||||||
|
5700ECB32A09043C006BF37C /* Release */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
buildSettings = {
|
||||||
|
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||||
|
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
|
||||||
|
CODE_SIGN_STYLE = Automatic;
|
||||||
|
CURRENT_PROJECT_VERSION = 1;
|
||||||
|
DEVELOPMENT_ASSET_PATHS = "\"hello-failure/Preview Content\"";
|
||||||
|
ENABLE_PREVIEWS = YES;
|
||||||
|
GENERATE_INFOPLIST_FILE = YES;
|
||||||
|
INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES;
|
||||||
|
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
|
||||||
|
INFOPLIST_KEY_UILaunchScreen_Generation = YES;
|
||||||
|
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
|
||||||
|
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
|
||||||
|
LD_RUNPATH_SEARCH_PATHS = (
|
||||||
|
"$(inherited)",
|
||||||
|
"@executable_path/Frameworks",
|
||||||
|
);
|
||||||
|
MARKETING_VERSION = 1.0;
|
||||||
|
PRODUCT_BUNDLE_IDENTIFIER = "com.example.hello-failure";
|
||||||
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
|
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||||
|
SWIFT_VERSION = 5.0;
|
||||||
|
TARGETED_DEVICE_FAMILY = "1,2";
|
||||||
|
};
|
||||||
|
name = Release;
|
||||||
|
};
|
||||||
|
/* End XCBuildConfiguration section */
|
||||||
|
|
||||||
|
/* Begin XCConfigurationList section */
|
||||||
|
5700EC9E2A09043B006BF37C /* Build configuration list for PBXProject "hello-failure" */ = {
|
||||||
|
isa = XCConfigurationList;
|
||||||
|
buildConfigurations = (
|
||||||
|
5700ECAF2A09043C006BF37C /* Debug */,
|
||||||
|
5700ECB02A09043C006BF37C /* Release */,
|
||||||
|
);
|
||||||
|
defaultConfigurationIsVisible = 0;
|
||||||
|
defaultConfigurationName = Release;
|
||||||
|
};
|
||||||
|
5700ECB12A09043C006BF37C /* Build configuration list for PBXNativeTarget "hello-failure" */ = {
|
||||||
|
isa = XCConfigurationList;
|
||||||
|
buildConfigurations = (
|
||||||
|
5700ECB22A09043C006BF37C /* Debug */,
|
||||||
|
5700ECB32A09043C006BF37C /* Release */,
|
||||||
|
);
|
||||||
|
defaultConfigurationIsVisible = 0;
|
||||||
|
defaultConfigurationName = Release;
|
||||||
|
};
|
||||||
|
/* End XCConfigurationList section */
|
||||||
|
};
|
||||||
|
rootObject = 5700EC9B2A09043B006BF37C /* Project object */;
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Workspace
|
||||||
|
version = "1.0">
|
||||||
|
<FileRef
|
||||||
|
location = "self:">
|
||||||
|
</FileRef>
|
||||||
|
</Workspace>
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>IDEDidComputeMac32BitWarning</key>
|
||||||
|
<true/>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
from create_database_utils import *
|
||||||
|
from diagnostics_test_utils import *
|
||||||
|
|
||||||
|
run_codeql_database_create([], lang='swift', keep_trap=True, db=None, runFunction=runUnsuccessfully)
|
||||||
|
check_diagnostics()
|
||||||
@@ -43,6 +43,8 @@ def skipped(test):
|
|||||||
def main(opts):
|
def main(opts):
|
||||||
test_dirs = opts.test_dir or [this_dir]
|
test_dirs = opts.test_dir or [this_dir]
|
||||||
tests = [t for d in test_dirs for t in d.rglob("test.py") if not skipped(t)]
|
tests = [t for d in test_dirs for t in d.rglob("test.py") if not skipped(t)]
|
||||||
|
if opts.learn:
|
||||||
|
os.environ["CODEQL_INTEGRATION_TEST_LEARN"] = "true"
|
||||||
|
|
||||||
if not tests:
|
if not tests:
|
||||||
print("No tests found", file=sys.stderr)
|
print("No tests found", file=sys.stderr)
|
||||||
|
|||||||
@@ -49,10 +49,10 @@
|
|||||||
#define DIAGNOSE_CRITICAL(ID, ...) DIAGNOSE_WITH_LEVEL(critical, ID, __VA_ARGS__)
|
#define DIAGNOSE_CRITICAL(ID, ...) DIAGNOSE_WITH_LEVEL(critical, ID, __VA_ARGS__)
|
||||||
#define DIAGNOSE_ERROR(ID, ...) DIAGNOSE_WITH_LEVEL(error, ID, __VA_ARGS__)
|
#define DIAGNOSE_ERROR(ID, ...) DIAGNOSE_WITH_LEVEL(error, ID, __VA_ARGS__)
|
||||||
|
|
||||||
#define DIAGNOSE_WITH_LEVEL(LEVEL, ID, ...) \
|
#define DIAGNOSE_WITH_LEVEL(LEVEL, ID, ...) \
|
||||||
do { \
|
do { \
|
||||||
codeql::SwiftDiagnosticsSource::inscribe<&codeql_diagnostics::ID>(); \
|
codeql::SwiftDiagnosticsSource::ensureRegistered<&codeql_diagnostics::ID>(); \
|
||||||
LOG_WITH_LEVEL_AND_CATEGORY(LEVEL, ID, __VA_ARGS__); \
|
LOG_WITH_LEVEL_AND_CATEGORY(LEVEL, ID, __VA_ARGS__); \
|
||||||
} while (false)
|
} while (false)
|
||||||
|
|
||||||
// avoid calling into binlog's original macros
|
// avoid calling into binlog's original macros
|
||||||
|
|||||||
@@ -13,6 +13,10 @@ swift_cc_binary(
|
|||||||
"-framework CoreFoundation",
|
"-framework CoreFoundation",
|
||||||
],
|
],
|
||||||
target_compatible_with = ["@platforms//os:macos"],
|
target_compatible_with = ["@platforms//os:macos"],
|
||||||
|
deps = [
|
||||||
|
"@absl//absl/strings",
|
||||||
|
"//swift/logging",
|
||||||
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
generate_cmake(
|
generate_cmake(
|
||||||
|
|||||||
17
swift/xcode-autobuilder/XcodeBuildLogging.h
Normal file
17
swift/xcode-autobuilder/XcodeBuildLogging.h
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "swift/logging/SwiftLogging.h"
|
||||||
|
|
||||||
|
namespace codeql {
|
||||||
|
constexpr const std::string_view programName = "autobuilder";
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace codeql_diagnostics {
|
||||||
|
constexpr codeql::SwiftDiagnosticsSource build_command_failed{
|
||||||
|
"build_command_failed",
|
||||||
|
"Detected build command failed",
|
||||||
|
"Set up a manual build command",
|
||||||
|
"https://docs.github.com/en/enterprise-server/code-security/code-scanning/"
|
||||||
|
"automatically-scanning-your-code-for-vulnerabilities-and-errors/customizing-code-scanning",
|
||||||
|
};
|
||||||
|
} // namespace codeql_diagnostics
|
||||||
@@ -3,6 +3,14 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <spawn.h>
|
#include <spawn.h>
|
||||||
|
#include "absl/strings/str_join.h"
|
||||||
|
|
||||||
|
#include "swift/xcode-autobuilder/XcodeBuildLogging.h"
|
||||||
|
|
||||||
|
static codeql::Logger& logger() {
|
||||||
|
static codeql::Logger ret{"build"};
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
static int waitpid_status(pid_t child) {
|
static int waitpid_status(pid_t child) {
|
||||||
int status;
|
int status;
|
||||||
@@ -52,13 +60,12 @@ void buildTarget(Target& target, bool dryRun) {
|
|||||||
argv.push_back("CODE_SIGNING_ALLOWED=NO");
|
argv.push_back("CODE_SIGNING_ALLOWED=NO");
|
||||||
|
|
||||||
if (dryRun) {
|
if (dryRun) {
|
||||||
for (auto& arg : argv) {
|
std::cout << absl::StrJoin(argv, " ") << "\n";
|
||||||
std::cout << arg + " ";
|
|
||||||
}
|
|
||||||
std::cout << "\n";
|
|
||||||
} else {
|
} else {
|
||||||
if (!exec(argv)) {
|
if (!exec(argv)) {
|
||||||
std::cerr << "Build failed\n";
|
DIAGNOSE_ERROR(build_command_failed, "The detected build command failed (tried {})",
|
||||||
|
absl::StrJoin(argv, " "));
|
||||||
|
codeql::Log::flush();
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user