From 5904a3453bf94df3f9bb44f22f9244781a5645ae Mon Sep 17 00:00:00 2001 From: Mishal Shah Date: Tue, 4 Mar 2025 23:25:10 -0800 Subject: [PATCH 1/9] [CI] Add support for GitHub Actions --- .github/workflows/pull_request.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 .github/workflows/pull_request.yml diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml new file mode 100644 index 000000000..19a0a1c14 --- /dev/null +++ b/.github/workflows/pull_request.yml @@ -0,0 +1,15 @@ +name: Pull request + +on: + pull_request: + types: [opened, reopened, synchronize] + +jobs: + tests: + name: Test + uses: swiftlang/github-workflows/.github/workflows/swift_package_test.yml@main + soundness: + name: Soundness + uses: swiftlang/github-workflows/.github/workflows/soundness.yml@main + with: + license_header_check_project_name: "Swift.org" From 25bd9c428e2e679bef28719f0a44394d4e47963b Mon Sep 17 00:00:00 2001 From: Nate Cook Date: Mon, 7 Jul 2025 15:58:49 -0500 Subject: [PATCH 2/9] Working --- .github/workflows/pull_request.yml | 7 +++++++ Sources/TestSupport/TestSupport.swift | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 19a0a1c14..5bcf54981 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -8,8 +8,15 @@ jobs: tests: name: Test uses: swiftlang/github-workflows/.github/workflows/swift_package_test.yml@main + with: + linux_exclude_swift_versions: '[{"swift_version": "5.9"}, {"swift_version": "5.10"}]' + windows_exclude_swift_versions: '[{"swift_version": "5.9"}]' + enable_macos_checks: true + macos_exclude_xcode_versions: '[{"xcode_version": "16.0"}, {"xcode_version": "16.1"}]' soundness: name: Soundness uses: swiftlang/github-workflows/.github/workflows/soundness.yml@main with: license_header_check_project_name: "Swift.org" + unacceptable_language_check_enabled: false + diff --git a/Sources/TestSupport/TestSupport.swift b/Sources/TestSupport/TestSupport.swift index b562f9255..fc9353f32 100644 --- a/Sources/TestSupport/TestSupport.swift +++ b/Sources/TestSupport/TestSupport.swift @@ -15,7 +15,7 @@ import XCTest // *without* `-disable-availability-checking` to ensure the #available check is // not compiled into a no-op. -#if os(Linux) || os(Android) +#if os(Linux) || os(Android) || os(Windows) public func XCTExpectFailure( _ message: String? = nil, body: () throws -> Void ) rethrows {} From 56974d0d9db8088da5655426ed8ef49a20639b99 Mon Sep 17 00:00:00 2001 From: Nate Cook Date: Mon, 7 Jul 2025 16:59:52 -0500 Subject: [PATCH 3/9] More --- .github/workflows/pull_request.yml | 1 + .license_header_template | 10 ++++++++++ .licenseignore | 24 ++++++++++++++++++++++++ 3 files changed, 35 insertions(+) create mode 100644 .license_header_template create mode 100644 .licenseignore diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 5bcf54981..bbf00bd4b 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -10,6 +10,7 @@ jobs: uses: swiftlang/github-workflows/.github/workflows/swift_package_test.yml@main with: linux_exclude_swift_versions: '[{"swift_version": "5.9"}, {"swift_version": "5.10"}]' + enable_windows_checks: false windows_exclude_swift_versions: '[{"swift_version": "5.9"}]' enable_macos_checks: true macos_exclude_xcode_versions: '[{"xcode_version": "16.0"}, {"xcode_version": "16.1"}]' diff --git a/.license_header_template b/.license_header_template new file mode 100644 index 000000000..c784192c2 --- /dev/null +++ b/.license_header_template @@ -0,0 +1,10 @@ +@@===----------------------------------------------------------------------===@@ +@@ +@@ This source file is part of the Swift.org open source project +@@ +@@ Copyright (c) YEARS Apple Inc. and the Swift project authors +@@ Licensed under Apache License v2.0 with Runtime Library Exception +@@ +@@ See https://swift.org/LICENSE.txt for license information +@@ +@@===----------------------------------------------------------------------===@@ diff --git a/.licenseignore b/.licenseignore new file mode 100644 index 000000000..fc621f77e --- /dev/null +++ b/.licenseignore @@ -0,0 +1,24 @@ +.gitignore +**/.gitignore +.licenseignore +.gitattributes +.git-blame-ignore-revs +.mailfilter +.mailmap +.spi.yml +.swift-format +.editorconfig +.github/* +.build +*.yml +*.yaml +*.cmake +*.cmake.in +Package.swift +**/Package.swift +Package@*.swift +**/Package@*.swift +Package.resolved +**/Package.resolved +.unacceptablelanguageignore + -a*/Snapshots/* From 29276502e199a6bb5c27b028896224c3a8ba2ada Mon Sep 17 00:00:00 2001 From: Nate Cook Date: Mon, 7 Jul 2025 17:07:30 -0500 Subject: [PATCH 4/9] Add licenses to RegexBenchmark --- Sources/RegexBenchmark/Benchmark.swift | 11 +++++++++++ Sources/RegexBenchmark/BenchmarkRegistration.swift | 11 +++++++++++ Sources/RegexBenchmark/BenchmarkResults.swift | 11 +++++++++++ Sources/RegexBenchmark/BenchmarkRunner.swift | 11 +++++++++++ Sources/RegexBenchmark/CLI.swift | 11 +++++++++++ Sources/RegexBenchmark/Debug.swift | 11 +++++++++++ Sources/RegexBenchmark/Inputs/CSS.swift | 11 +++++++++++ Sources/RegexBenchmark/Inputs/CompilerOutput.swift | 11 +++++++++++ Sources/RegexBenchmark/Inputs/Dice.swift | 10 ++++++++++ Sources/RegexBenchmark/Inputs/Email.swift | 10 ++++++++++ Sources/RegexBenchmark/Inputs/FSPaths.swift | 11 +++++++++++ .../RegexBenchmark/Inputs/GraphemeBreakData.swift | 11 +++++++++++ Sources/RegexBenchmark/Inputs/HTML.swift | 11 +++++++++++ Sources/RegexBenchmark/Inputs/NetworkingData.swift | 10 ++++++++++ Sources/RegexBenchmark/Inputs/TaggedUnicode.swift | 11 +++++++++++ Sources/RegexBenchmark/Inputs/URL.swift | 11 +++++++++++ Sources/RegexBenchmark/Suite/BuiltinCC.swift | 11 +++++++++++ Sources/RegexBenchmark/Suite/CssRegex.swift | 11 +++++++++++ .../Suite/CustomCharacterClasses.swift | 11 +++++++++++ Sources/RegexBenchmark/Suite/DiceNotation.swift | 11 +++++++++++ Sources/RegexBenchmark/Suite/EmailRegex.swift | 11 +++++++++++ Sources/RegexBenchmark/Suite/ErrorMessages.swift | 11 +++++++++++ Sources/RegexBenchmark/Suite/FSPathsRegex.swift | 12 +++++++++++- Sources/RegexBenchmark/Suite/GraphemeBreak.swift | 11 +++++++++++ Sources/RegexBenchmark/Suite/HtmlRegex.swift | 11 +++++++++++ Sources/RegexBenchmark/Suite/IpAddress.swift | 11 +++++++++++ Sources/RegexBenchmark/Suite/LiteralSearch.swift | 11 +++++++++++ Sources/RegexBenchmark/Suite/NotFound.swift | 11 +++++++++++ Sources/RegexBenchmark/Suite/ReluctantQuant.swift | 11 +++++++++++ Sources/RegexBenchmark/Suite/URLRegex.swift | 11 +++++++++++ Sources/RegexBenchmark/Suite/Unicode.swift | 11 +++++++++++ Sources/RegexBenchmark/Utils/Size.swift | 11 +++++++++++ Sources/RegexBenchmark/Utils/Stats.swift | 11 +++++++++++ Sources/RegexBenchmark/Utils/Tick.swift | 11 +++++++++++ Sources/RegexBenchmark/Utils/Time.swift | 11 +++++++++++ Sources/RegexBenchmark/Utils/Timer.swift | 11 +++++++++++ 36 files changed, 393 insertions(+), 1 deletion(-) diff --git a/Sources/RegexBenchmark/Benchmark.swift b/Sources/RegexBenchmark/Benchmark.swift index bcf8fa42a..548f976c9 100644 --- a/Sources/RegexBenchmark/Benchmark.swift +++ b/Sources/RegexBenchmark/Benchmark.swift @@ -1,3 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift.org open source project +// +// Copyright (c) 2021-2022 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See https://swift.org/LICENSE.txt for license information +// +//===----------------------------------------------------------------------===// + @_spi(RegexBenchmark) import _StringProcessing internal import _RegexParser import Foundation diff --git a/Sources/RegexBenchmark/BenchmarkRegistration.swift b/Sources/RegexBenchmark/BenchmarkRegistration.swift index a812b84be..24ebb02ec 100644 --- a/Sources/RegexBenchmark/BenchmarkRegistration.swift +++ b/Sources/RegexBenchmark/BenchmarkRegistration.swift @@ -1,3 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift.org open source project +// +// Copyright (c) 2021-2022 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See https://swift.org/LICENSE.txt for license information +// +//===----------------------------------------------------------------------===// + // This file has lines generated by createBenchmark.py // Do not remove the start of registration or end of registration markers diff --git a/Sources/RegexBenchmark/BenchmarkResults.swift b/Sources/RegexBenchmark/BenchmarkResults.swift index da66183fd..824322300 100644 --- a/Sources/RegexBenchmark/BenchmarkResults.swift +++ b/Sources/RegexBenchmark/BenchmarkResults.swift @@ -1,3 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift.org open source project +// +// Copyright (c) 2021-2022 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See https://swift.org/LICENSE.txt for license information +// +//===----------------------------------------------------------------------===// + import Foundation extension BenchmarkRunner { diff --git a/Sources/RegexBenchmark/BenchmarkRunner.swift b/Sources/RegexBenchmark/BenchmarkRunner.swift index 6abee43aa..62b039428 100644 --- a/Sources/RegexBenchmark/BenchmarkRunner.swift +++ b/Sources/RegexBenchmark/BenchmarkRunner.swift @@ -1,3 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift.org open source project +// +// Copyright (c) 2021-2022 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See https://swift.org/LICENSE.txt for license information +// +//===----------------------------------------------------------------------===// + import Foundation @_spi(RegexBenchmark) import _StringProcessing diff --git a/Sources/RegexBenchmark/CLI.swift b/Sources/RegexBenchmark/CLI.swift index ee3e94dae..e20241f18 100644 --- a/Sources/RegexBenchmark/CLI.swift +++ b/Sources/RegexBenchmark/CLI.swift @@ -1,3 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift.org open source project +// +// Copyright (c) 2021-2022 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See https://swift.org/LICENSE.txt for license information +// +//===----------------------------------------------------------------------===// + import ArgumentParser @main diff --git a/Sources/RegexBenchmark/Debug.swift b/Sources/RegexBenchmark/Debug.swift index 1171247e4..e31bd237a 100644 --- a/Sources/RegexBenchmark/Debug.swift +++ b/Sources/RegexBenchmark/Debug.swift @@ -1,3 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift.org open source project +// +// Copyright (c) 2021-2022 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See https://swift.org/LICENSE.txt for license information +// +//===----------------------------------------------------------------------===// + import Foundation protocol Debug { diff --git a/Sources/RegexBenchmark/Inputs/CSS.swift b/Sources/RegexBenchmark/Inputs/CSS.swift index ad8cf89b2..32cc9ef1e 100644 --- a/Sources/RegexBenchmark/Inputs/CSS.swift +++ b/Sources/RegexBenchmark/Inputs/CSS.swift @@ -1,3 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift.org open source project +// +// Copyright (c) 2021-2022 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See https://swift.org/LICENSE.txt for license information +// +//===----------------------------------------------------------------------===// + enum Inputs {} extension Inputs { diff --git a/Sources/RegexBenchmark/Inputs/CompilerOutput.swift b/Sources/RegexBenchmark/Inputs/CompilerOutput.swift index a63e789f0..9eddf640f 100644 --- a/Sources/RegexBenchmark/Inputs/CompilerOutput.swift +++ b/Sources/RegexBenchmark/Inputs/CompilerOutput.swift @@ -1,3 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift.org open source project +// +// Copyright (c) 2021-2022 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See https://swift.org/LICENSE.txt for license information +// +//===----------------------------------------------------------------------===// + extension Inputs { /// Output of trying to build after deleting `Sources/_StringProcessing/Regex` /// Mostly a ton of error messages diff --git a/Sources/RegexBenchmark/Inputs/Dice.swift b/Sources/RegexBenchmark/Inputs/Dice.swift index f17172df6..b081cba63 100644 --- a/Sources/RegexBenchmark/Inputs/Dice.swift +++ b/Sources/RegexBenchmark/Inputs/Dice.swift @@ -1,3 +1,13 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift.org open source project +// +// Copyright (c) 2021-2022 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See https://swift.org/LICENSE.txt for license information +// +//===----------------------------------------------------------------------===// extension Inputs { /// Generated by Utils/benchmark-generators/generateDiceNotation.py diff --git a/Sources/RegexBenchmark/Inputs/Email.swift b/Sources/RegexBenchmark/Inputs/Email.swift index e702df532..bc59db0c6 100644 --- a/Sources/RegexBenchmark/Inputs/Email.swift +++ b/Sources/RegexBenchmark/Inputs/Email.swift @@ -1,3 +1,13 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift.org open source project +// +// Copyright (c) 2021-2022 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See https://swift.org/LICENSE.txt for license information +// +//===----------------------------------------------------------------------===// extension Inputs { /// Generated by Utils/benchmark-generators/generateEmails.py diff --git a/Sources/RegexBenchmark/Inputs/FSPaths.swift b/Sources/RegexBenchmark/Inputs/FSPaths.swift index 78b6e4875..d168c6f3c 100644 --- a/Sources/RegexBenchmark/Inputs/FSPaths.swift +++ b/Sources/RegexBenchmark/Inputs/FSPaths.swift @@ -1,3 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift.org open source project +// +// Copyright (c) 2021-2022 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See https://swift.org/LICENSE.txt for license information +// +//===----------------------------------------------------------------------===// + // Successful match FSPaths private let pathSuccess = #""" ./First/Second/Third/some/really/long/content.extension/more/stuff/OptionLeft diff --git a/Sources/RegexBenchmark/Inputs/GraphemeBreakData.swift b/Sources/RegexBenchmark/Inputs/GraphemeBreakData.swift index 9f1abb615..ad3f16e67 100644 --- a/Sources/RegexBenchmark/Inputs/GraphemeBreakData.swift +++ b/Sources/RegexBenchmark/Inputs/GraphemeBreakData.swift @@ -1,3 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift.org open source project +// +// Copyright (c) 2021-2022 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See https://swift.org/LICENSE.txt for license information +// +//===----------------------------------------------------------------------===// + extension Inputs { static let graphemeBreakData = """ # GraphemeBreakProperty-13.0.0.txt diff --git a/Sources/RegexBenchmark/Inputs/HTML.swift b/Sources/RegexBenchmark/Inputs/HTML.swift index 25307ed94..47be5405b 100644 --- a/Sources/RegexBenchmark/Inputs/HTML.swift +++ b/Sources/RegexBenchmark/Inputs/HTML.swift @@ -1,3 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift.org open source project +// +// Copyright (c) 2021-2022 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See https://swift.org/LICENSE.txt for license information +// +//===----------------------------------------------------------------------===// + extension Inputs { static let swiftOrgHTML = """ diff --git a/Sources/RegexBenchmark/Inputs/NetworkingData.swift b/Sources/RegexBenchmark/Inputs/NetworkingData.swift index 21a82ccd3..58f2d348f 100644 --- a/Sources/RegexBenchmark/Inputs/NetworkingData.swift +++ b/Sources/RegexBenchmark/Inputs/NetworkingData.swift @@ -1,3 +1,13 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift.org open source project +// +// Copyright (c) 2021-2022 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See https://swift.org/LICENSE.txt for license information +// +//===----------------------------------------------------------------------===// extension Inputs { /// Generated by Utils/benchmark-generators/generateNetworkingData.py diff --git a/Sources/RegexBenchmark/Inputs/TaggedUnicode.swift b/Sources/RegexBenchmark/Inputs/TaggedUnicode.swift index f9ad62267..bb30d0c70 100644 --- a/Sources/RegexBenchmark/Inputs/TaggedUnicode.swift +++ b/Sources/RegexBenchmark/Inputs/TaggedUnicode.swift @@ -1,3 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift.org open source project +// +// Copyright (c) 2021-2022 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See https://swift.org/LICENSE.txt for license information +// +//===----------------------------------------------------------------------===// + extension Inputs { static let taggedEmojis = """ 😽🙄🙉😀😒😛😄😆🙋😂😫😴😋😜🙋😈😈😅🙅😻😴😕😑😇😤😲🙍😈🙈😢😴😟😌😟🙊😴😥😟🙋😰😒😳😩🙀🙂😲🙁😷😯😐😱😩😂😲🙍😏😞😮😍🙍🙁😔😿😹😧😏😤😫😹🙄😇😴😍😎😁😉😿 diff --git a/Sources/RegexBenchmark/Inputs/URL.swift b/Sources/RegexBenchmark/Inputs/URL.swift index b1b03f53d..d864bcef4 100644 --- a/Sources/RegexBenchmark/Inputs/URL.swift +++ b/Sources/RegexBenchmark/Inputs/URL.swift @@ -1,3 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift.org open source project +// +// Copyright (c) 2021-2022 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See https://swift.org/LICENSE.txt for license information +// +//===----------------------------------------------------------------------===// + extension Inputs { static let url: String = { let element = """ diff --git a/Sources/RegexBenchmark/Suite/BuiltinCC.swift b/Sources/RegexBenchmark/Suite/BuiltinCC.swift index 40566274e..53f98855b 100644 --- a/Sources/RegexBenchmark/Suite/BuiltinCC.swift +++ b/Sources/RegexBenchmark/Suite/BuiltinCC.swift @@ -1,3 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift.org open source project +// +// Copyright (c) 2021-2022 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See https://swift.org/LICENSE.txt for license information +// +//===----------------------------------------------------------------------===// + import _StringProcessing extension BenchmarkRunner { diff --git a/Sources/RegexBenchmark/Suite/CssRegex.swift b/Sources/RegexBenchmark/Suite/CssRegex.swift index 3c2922a34..49d259e21 100644 --- a/Sources/RegexBenchmark/Suite/CssRegex.swift +++ b/Sources/RegexBenchmark/Suite/CssRegex.swift @@ -1,3 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift.org open source project +// +// Copyright (c) 2021-2022 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See https://swift.org/LICENSE.txt for license information +// +//===----------------------------------------------------------------------===// + import Foundation import _StringProcessing diff --git a/Sources/RegexBenchmark/Suite/CustomCharacterClasses.swift b/Sources/RegexBenchmark/Suite/CustomCharacterClasses.swift index 27b2b07b4..508145591 100644 --- a/Sources/RegexBenchmark/Suite/CustomCharacterClasses.swift +++ b/Sources/RegexBenchmark/Suite/CustomCharacterClasses.swift @@ -1,3 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift.org open source project +// +// Copyright (c) 2021-2022 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See https://swift.org/LICENSE.txt for license information +// +//===----------------------------------------------------------------------===// + import _StringProcessing extension BenchmarkRunner { diff --git a/Sources/RegexBenchmark/Suite/DiceNotation.swift b/Sources/RegexBenchmark/Suite/DiceNotation.swift index f75152378..3a9aed231 100644 --- a/Sources/RegexBenchmark/Suite/DiceNotation.swift +++ b/Sources/RegexBenchmark/Suite/DiceNotation.swift @@ -1,3 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift.org open source project +// +// Copyright (c) 2021-2022 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See https://swift.org/LICENSE.txt for license information +// +//===----------------------------------------------------------------------===// + import _StringProcessing extension BenchmarkRunner { diff --git a/Sources/RegexBenchmark/Suite/EmailRegex.swift b/Sources/RegexBenchmark/Suite/EmailRegex.swift index a7076d4bf..dd5a45b46 100644 --- a/Sources/RegexBenchmark/Suite/EmailRegex.swift +++ b/Sources/RegexBenchmark/Suite/EmailRegex.swift @@ -1,3 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift.org open source project +// +// Copyright (c) 2021-2022 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See https://swift.org/LICENSE.txt for license information +// +//===----------------------------------------------------------------------===// + import _StringProcessing import Foundation diff --git a/Sources/RegexBenchmark/Suite/ErrorMessages.swift b/Sources/RegexBenchmark/Suite/ErrorMessages.swift index 3b66eef79..658724d31 100644 --- a/Sources/RegexBenchmark/Suite/ErrorMessages.swift +++ b/Sources/RegexBenchmark/Suite/ErrorMessages.swift @@ -1,3 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift.org open source project +// +// Copyright (c) 2021-2022 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See https://swift.org/LICENSE.txt for license information +// +//===----------------------------------------------------------------------===// + import _StringProcessing extension BenchmarkRunner { diff --git a/Sources/RegexBenchmark/Suite/FSPathsRegex.swift b/Sources/RegexBenchmark/Suite/FSPathsRegex.swift index f029e9348..1f1201785 100644 --- a/Sources/RegexBenchmark/Suite/FSPathsRegex.swift +++ b/Sources/RegexBenchmark/Suite/FSPathsRegex.swift @@ -1,5 +1,15 @@ -import _StringProcessing +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift.org open source project +// +// Copyright (c) 2021-2022 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See https://swift.org/LICENSE.txt for license information +// +//===----------------------------------------------------------------------===// +import _StringProcessing extension BenchmarkRunner { mutating func addFSPathsRegex() { diff --git a/Sources/RegexBenchmark/Suite/GraphemeBreak.swift b/Sources/RegexBenchmark/Suite/GraphemeBreak.swift index a6cdb4be7..f75dedc52 100644 --- a/Sources/RegexBenchmark/Suite/GraphemeBreak.swift +++ b/Sources/RegexBenchmark/Suite/GraphemeBreak.swift @@ -1,3 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift.org open source project +// +// Copyright (c) 2021-2022 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See https://swift.org/LICENSE.txt for license information +// +//===----------------------------------------------------------------------===// + import _StringProcessing import RegexBuilder diff --git a/Sources/RegexBenchmark/Suite/HtmlRegex.swift b/Sources/RegexBenchmark/Suite/HtmlRegex.swift index 95739c419..c14a4ae1e 100644 --- a/Sources/RegexBenchmark/Suite/HtmlRegex.swift +++ b/Sources/RegexBenchmark/Suite/HtmlRegex.swift @@ -1,3 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift.org open source project +// +// Copyright (c) 2021-2022 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See https://swift.org/LICENSE.txt for license information +// +//===----------------------------------------------------------------------===// + import _StringProcessing extension BenchmarkRunner { diff --git a/Sources/RegexBenchmark/Suite/IpAddress.swift b/Sources/RegexBenchmark/Suite/IpAddress.swift index ce6e4fd90..9fe453057 100644 --- a/Sources/RegexBenchmark/Suite/IpAddress.swift +++ b/Sources/RegexBenchmark/Suite/IpAddress.swift @@ -1,3 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift.org open source project +// +// Copyright (c) 2021-2022 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See https://swift.org/LICENSE.txt for license information +// +//===----------------------------------------------------------------------===// + import _StringProcessing extension BenchmarkRunner { diff --git a/Sources/RegexBenchmark/Suite/LiteralSearch.swift b/Sources/RegexBenchmark/Suite/LiteralSearch.swift index 32cf60a7d..ac13b09db 100644 --- a/Sources/RegexBenchmark/Suite/LiteralSearch.swift +++ b/Sources/RegexBenchmark/Suite/LiteralSearch.swift @@ -1,3 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift.org open source project +// +// Copyright (c) 2021-2022 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See https://swift.org/LICENSE.txt for license information +// +//===----------------------------------------------------------------------===// + import _StringProcessing extension BenchmarkRunner { diff --git a/Sources/RegexBenchmark/Suite/NotFound.swift b/Sources/RegexBenchmark/Suite/NotFound.swift index be2e67e79..b3c0a773c 100644 --- a/Sources/RegexBenchmark/Suite/NotFound.swift +++ b/Sources/RegexBenchmark/Suite/NotFound.swift @@ -1,3 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift.org open source project +// +// Copyright (c) 2021-2022 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See https://swift.org/LICENSE.txt for license information +// +//===----------------------------------------------------------------------===// + import _StringProcessing import Foundation diff --git a/Sources/RegexBenchmark/Suite/ReluctantQuant.swift b/Sources/RegexBenchmark/Suite/ReluctantQuant.swift index 72f776b5b..276d8acd2 100644 --- a/Sources/RegexBenchmark/Suite/ReluctantQuant.swift +++ b/Sources/RegexBenchmark/Suite/ReluctantQuant.swift @@ -1,3 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift.org open source project +// +// Copyright (c) 2021-2022 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See https://swift.org/LICENSE.txt for license information +// +//===----------------------------------------------------------------------===// + import _StringProcessing import RegexBuilder diff --git a/Sources/RegexBenchmark/Suite/URLRegex.swift b/Sources/RegexBenchmark/Suite/URLRegex.swift index 9e28f5396..61e3cc8f6 100644 --- a/Sources/RegexBenchmark/Suite/URLRegex.swift +++ b/Sources/RegexBenchmark/Suite/URLRegex.swift @@ -1,3 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift.org open source project +// +// Copyright (c) 2021-2022 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See https://swift.org/LICENSE.txt for license information +// +//===----------------------------------------------------------------------===// + import _StringProcessing extension BenchmarkRunner { diff --git a/Sources/RegexBenchmark/Suite/Unicode.swift b/Sources/RegexBenchmark/Suite/Unicode.swift index 46afda712..cd61a8a3f 100644 --- a/Sources/RegexBenchmark/Suite/Unicode.swift +++ b/Sources/RegexBenchmark/Suite/Unicode.swift @@ -1,3 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift.org open source project +// +// Copyright (c) 2021-2022 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See https://swift.org/LICENSE.txt for license information +// +//===----------------------------------------------------------------------===// + import _StringProcessing extension BenchmarkRunner { diff --git a/Sources/RegexBenchmark/Utils/Size.swift b/Sources/RegexBenchmark/Utils/Size.swift index 00802fe59..c41320e5c 100644 --- a/Sources/RegexBenchmark/Utils/Size.swift +++ b/Sources/RegexBenchmark/Utils/Size.swift @@ -1,3 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift.org open source project +// +// Copyright (c) 2021-2022 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See https://swift.org/LICENSE.txt for license information +// +//===----------------------------------------------------------------------===// + // Taken from swift-collections-benchmark import ArgumentParser diff --git a/Sources/RegexBenchmark/Utils/Stats.swift b/Sources/RegexBenchmark/Utils/Stats.swift index 175826a0b..bc1490d8e 100644 --- a/Sources/RegexBenchmark/Utils/Stats.swift +++ b/Sources/RegexBenchmark/Utils/Stats.swift @@ -1,3 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift.org open source project +// +// Copyright (c) 2021-2022 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See https://swift.org/LICENSE.txt for license information +// +//===----------------------------------------------------------------------===// + import Foundation enum Stats {} diff --git a/Sources/RegexBenchmark/Utils/Tick.swift b/Sources/RegexBenchmark/Utils/Tick.swift index 5209fab18..cd5b9f703 100644 --- a/Sources/RegexBenchmark/Utils/Tick.swift +++ b/Sources/RegexBenchmark/Utils/Tick.swift @@ -1,3 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift.org open source project +// +// Copyright (c) 2021-2022 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See https://swift.org/LICENSE.txt for license information +// +//===----------------------------------------------------------------------===// + // Taken from swift-collections-benchmark #if !USE_FOUNDATION_DATE && (os(macOS) || os(iOS) || os(watchOS) || os(tvOS)) import Foundation // For the side effect of reexporting Darwin/Glibc diff --git a/Sources/RegexBenchmark/Utils/Time.swift b/Sources/RegexBenchmark/Utils/Time.swift index 592e18058..36d615450 100644 --- a/Sources/RegexBenchmark/Utils/Time.swift +++ b/Sources/RegexBenchmark/Utils/Time.swift @@ -1,3 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift.org open source project +// +// Copyright (c) 2021-2022 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See https://swift.org/LICENSE.txt for license information +// +//===----------------------------------------------------------------------===// + // Taken from swift-collections-benchmark import Foundation diff --git a/Sources/RegexBenchmark/Utils/Timer.swift b/Sources/RegexBenchmark/Utils/Timer.swift index 960169fed..429a62a06 100644 --- a/Sources/RegexBenchmark/Utils/Timer.swift +++ b/Sources/RegexBenchmark/Utils/Timer.swift @@ -1,3 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift.org open source project +// +// Copyright (c) 2021-2022 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See https://swift.org/LICENSE.txt for license information +// +//===----------------------------------------------------------------------===// + // Taken from swift-collections-benchmark public struct Timer { From 13058d165c42d350f96fe02ae65e366b1a57b0de Mon Sep 17 00:00:00 2001 From: Nate Cook Date: Mon, 7 Jul 2025 17:21:55 -0500 Subject: [PATCH 5/9] Add license to Python scripts --- .../generateDiceNotation.py | 11 +++++++++ Utils/benchmark-generators/generateEmails.py | 11 +++++++++ .../generateNetworkingData.py | 11 +++++++++ .../generateTaggedUnicode.py | 11 +++++++++ Utils/createBenchmark.py | 24 ++++++++++++++++++- 5 files changed, 67 insertions(+), 1 deletion(-) diff --git a/Utils/benchmark-generators/generateDiceNotation.py b/Utils/benchmark-generators/generateDiceNotation.py index fa31defb4..b7cbe9cc8 100644 --- a/Utils/benchmark-generators/generateDiceNotation.py +++ b/Utils/benchmark-generators/generateDiceNotation.py @@ -1,3 +1,14 @@ +##===----------------------------------------------------------------------===## +## +## This source file is part of the Swift.org open source project +## +## Copyright (c) 2021-2022 Apple Inc. and the Swift project authors +## Licensed under Apache License v2.0 with Runtime Library Exception +## +## See https://swift.org/LICENSE.txt for license information +## +##===----------------------------------------------------------------------===## + import string import random diff --git a/Utils/benchmark-generators/generateEmails.py b/Utils/benchmark-generators/generateEmails.py index ff4d31a79..ceaedb3a5 100644 --- a/Utils/benchmark-generators/generateEmails.py +++ b/Utils/benchmark-generators/generateEmails.py @@ -1,3 +1,14 @@ +##===----------------------------------------------------------------------===## +## +## This source file is part of the Swift.org open source project +## +## Copyright (c) 2021-2022 Apple Inc. and the Swift project authors +## Licensed under Apache License v2.0 with Runtime Library Exception +## +## See https://swift.org/LICENSE.txt for license information +## +##===----------------------------------------------------------------------===## + # python3 generateEmails.py > output.txt import string diff --git a/Utils/benchmark-generators/generateNetworkingData.py b/Utils/benchmark-generators/generateNetworkingData.py index 9a62dacb5..e1cd3d518 100644 --- a/Utils/benchmark-generators/generateNetworkingData.py +++ b/Utils/benchmark-generators/generateNetworkingData.py @@ -1,3 +1,14 @@ +##===----------------------------------------------------------------------===## +## +## This source file is part of the Swift.org open source project +## +## Copyright (c) 2021-2022 Apple Inc. and the Swift project authors +## Licensed under Apache License v2.0 with Runtime Library Exception +## +## See https://swift.org/LICENSE.txt for license information +## +##===----------------------------------------------------------------------===## + import string import random diff --git a/Utils/benchmark-generators/generateTaggedUnicode.py b/Utils/benchmark-generators/generateTaggedUnicode.py index 6baa8862a..60b23db72 100644 --- a/Utils/benchmark-generators/generateTaggedUnicode.py +++ b/Utils/benchmark-generators/generateTaggedUnicode.py @@ -1,3 +1,14 @@ +##===----------------------------------------------------------------------===## +## +## This source file is part of the Swift.org open source project +## +## Copyright (c) 2021-2022 Apple Inc. and the Swift project authors +## Licensed under Apache License v2.0 with Runtime Library Exception +## +## See https://swift.org/LICENSE.txt for license information +## +##===----------------------------------------------------------------------===## + # Generates lines of junk unicode wrapped in html tags import random diff --git a/Utils/createBenchmark.py b/Utils/createBenchmark.py index 6fce1bc69..82636f64c 100644 --- a/Utils/createBenchmark.py +++ b/Utils/createBenchmark.py @@ -1,10 +1,32 @@ +##===----------------------------------------------------------------------===## +## +## This source file is part of the Swift.org open source project +## +## Copyright (c) 2021-2022 Apple Inc. and the Swift project authors +## Licensed under Apache License v2.0 with Runtime Library Exception +## +## See https://swift.org/LICENSE.txt for license information +## +##===----------------------------------------------------------------------===## + # python3 createBenchmark.py MyRegexBenchmark # reference: https://github.com/apple/swift/blob/main/benchmark/scripts/create_benchmark.py import argparse import os -template = """import _StringProcessing +template = """//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift.org open source project +// +// Copyright (c) 2021-2022 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See https://swift.org/LICENSE.txt for license information +// +//===----------------------------------------------------------------------===// + +import _StringProcessing extension BenchmarkRunner {{ mutating func add{name}() {{ From 78e148b91ffed4069552dcbc08daa49e74a7169b Mon Sep 17 00:00:00 2001 From: Nate Cook Date: Mon, 7 Jul 2025 17:36:15 -0500 Subject: [PATCH 6/9] License for 'gen-unicode-data' --- Utils/gen-unicode-data/Input/GraphemeData.h | 1 - Utils/gen-unicode-data/Input/NormalizationData.h | 1 - Utils/gen-unicode-data/Input/ScalarPropData.h | 1 - .../Sources/GenGraphemeBreakProperty/IndicRules.swift | 1 - .../gen-unicode-data/Sources/GenGraphemeBreakProperty/main.swift | 1 - Utils/gen-unicode-data/Sources/GenNormalization/CCC.swift | 1 - Utils/gen-unicode-data/Sources/GenNormalization/Comp.swift | 1 - Utils/gen-unicode-data/Sources/GenNormalization/Decomp.swift | 1 - Utils/gen-unicode-data/Sources/GenNormalization/NFX_QC.swift | 1 - Utils/gen-unicode-data/Sources/GenNormalization/NormData.swift | 1 - Utils/gen-unicode-data/Sources/GenNormalization/main.swift | 1 - Utils/gen-unicode-data/Sources/GenScalarProps/Age.swift | 1 - Utils/gen-unicode-data/Sources/GenScalarProps/BinProps.swift | 1 - .../Sources/GenScalarProps/GeneralCategory.swift | 1 - Utils/gen-unicode-data/Sources/GenScalarProps/Mappings.swift | 1 - Utils/gen-unicode-data/Sources/GenScalarProps/NameAlias.swift | 1 - Utils/gen-unicode-data/Sources/GenScalarProps/Names.swift | 1 - Utils/gen-unicode-data/Sources/GenScalarProps/Numeric.swift | 1 - Utils/gen-unicode-data/Sources/GenScalarProps/main.swift | 1 - Utils/gen-unicode-data/Sources/GenUtils/BitArray.swift | 1 - Utils/gen-unicode-data/Sources/GenUtils/Emit.swift | 1 - Utils/gen-unicode-data/Sources/GenUtils/Files.swift | 1 - Utils/gen-unicode-data/Sources/GenUtils/Flatten.swift | 1 - Utils/gen-unicode-data/Sources/GenUtils/Formatting.swift | 1 - Utils/gen-unicode-data/Sources/GenUtils/Hashing.swift | 1 - Utils/gen-unicode-data/Sources/GenUtils/Mph.swift | 1 - 26 files changed, 26 deletions(-) diff --git a/Utils/gen-unicode-data/Input/GraphemeData.h b/Utils/gen-unicode-data/Input/GraphemeData.h index dc06ade7b..c1c537d53 100644 --- a/Utils/gen-unicode-data/Input/GraphemeData.h +++ b/Utils/gen-unicode-data/Input/GraphemeData.h @@ -6,7 +6,6 @@ // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information -// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// diff --git a/Utils/gen-unicode-data/Input/NormalizationData.h b/Utils/gen-unicode-data/Input/NormalizationData.h index 7186cdc88..4785f29ed 100644 --- a/Utils/gen-unicode-data/Input/NormalizationData.h +++ b/Utils/gen-unicode-data/Input/NormalizationData.h @@ -6,7 +6,6 @@ // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information -// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// diff --git a/Utils/gen-unicode-data/Input/ScalarPropData.h b/Utils/gen-unicode-data/Input/ScalarPropData.h index 415259d1e..ca1e3a567 100644 --- a/Utils/gen-unicode-data/Input/ScalarPropData.h +++ b/Utils/gen-unicode-data/Input/ScalarPropData.h @@ -6,7 +6,6 @@ // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information -// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// diff --git a/Utils/gen-unicode-data/Sources/GenGraphemeBreakProperty/IndicRules.swift b/Utils/gen-unicode-data/Sources/GenGraphemeBreakProperty/IndicRules.swift index daf4f7aef..da759f2e0 100644 --- a/Utils/gen-unicode-data/Sources/GenGraphemeBreakProperty/IndicRules.swift +++ b/Utils/gen-unicode-data/Sources/GenGraphemeBreakProperty/IndicRules.swift @@ -6,7 +6,6 @@ // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information -// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// diff --git a/Utils/gen-unicode-data/Sources/GenGraphemeBreakProperty/main.swift b/Utils/gen-unicode-data/Sources/GenGraphemeBreakProperty/main.swift index d8b2aae40..80128fb3f 100644 --- a/Utils/gen-unicode-data/Sources/GenGraphemeBreakProperty/main.swift +++ b/Utils/gen-unicode-data/Sources/GenGraphemeBreakProperty/main.swift @@ -6,7 +6,6 @@ // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information -// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// diff --git a/Utils/gen-unicode-data/Sources/GenNormalization/CCC.swift b/Utils/gen-unicode-data/Sources/GenNormalization/CCC.swift index b39972c39..d4e0903cb 100644 --- a/Utils/gen-unicode-data/Sources/GenNormalization/CCC.swift +++ b/Utils/gen-unicode-data/Sources/GenNormalization/CCC.swift @@ -6,7 +6,6 @@ // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information -// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// diff --git a/Utils/gen-unicode-data/Sources/GenNormalization/Comp.swift b/Utils/gen-unicode-data/Sources/GenNormalization/Comp.swift index c9be203bd..35b022847 100644 --- a/Utils/gen-unicode-data/Sources/GenNormalization/Comp.swift +++ b/Utils/gen-unicode-data/Sources/GenNormalization/Comp.swift @@ -6,7 +6,6 @@ // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information -// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// diff --git a/Utils/gen-unicode-data/Sources/GenNormalization/Decomp.swift b/Utils/gen-unicode-data/Sources/GenNormalization/Decomp.swift index 00a3961bc..907243308 100644 --- a/Utils/gen-unicode-data/Sources/GenNormalization/Decomp.swift +++ b/Utils/gen-unicode-data/Sources/GenNormalization/Decomp.swift @@ -6,7 +6,6 @@ // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information -// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// diff --git a/Utils/gen-unicode-data/Sources/GenNormalization/NFX_QC.swift b/Utils/gen-unicode-data/Sources/GenNormalization/NFX_QC.swift index 30d72cdcd..a6cf73c18 100644 --- a/Utils/gen-unicode-data/Sources/GenNormalization/NFX_QC.swift +++ b/Utils/gen-unicode-data/Sources/GenNormalization/NFX_QC.swift @@ -6,7 +6,6 @@ // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information -// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// diff --git a/Utils/gen-unicode-data/Sources/GenNormalization/NormData.swift b/Utils/gen-unicode-data/Sources/GenNormalization/NormData.swift index fd7c70596..076bcecd8 100644 --- a/Utils/gen-unicode-data/Sources/GenNormalization/NormData.swift +++ b/Utils/gen-unicode-data/Sources/GenNormalization/NormData.swift @@ -6,7 +6,6 @@ // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information -// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// diff --git a/Utils/gen-unicode-data/Sources/GenNormalization/main.swift b/Utils/gen-unicode-data/Sources/GenNormalization/main.swift index 4e14328e1..bbd5a9a90 100644 --- a/Utils/gen-unicode-data/Sources/GenNormalization/main.swift +++ b/Utils/gen-unicode-data/Sources/GenNormalization/main.swift @@ -6,7 +6,6 @@ // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information -// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// diff --git a/Utils/gen-unicode-data/Sources/GenScalarProps/Age.swift b/Utils/gen-unicode-data/Sources/GenScalarProps/Age.swift index d1bf859ea..0c952b3d6 100644 --- a/Utils/gen-unicode-data/Sources/GenScalarProps/Age.swift +++ b/Utils/gen-unicode-data/Sources/GenScalarProps/Age.swift @@ -6,7 +6,6 @@ // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information -// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// diff --git a/Utils/gen-unicode-data/Sources/GenScalarProps/BinProps.swift b/Utils/gen-unicode-data/Sources/GenScalarProps/BinProps.swift index 9c28ac613..d3b7ea261 100644 --- a/Utils/gen-unicode-data/Sources/GenScalarProps/BinProps.swift +++ b/Utils/gen-unicode-data/Sources/GenScalarProps/BinProps.swift @@ -6,7 +6,6 @@ // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information -// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// diff --git a/Utils/gen-unicode-data/Sources/GenScalarProps/GeneralCategory.swift b/Utils/gen-unicode-data/Sources/GenScalarProps/GeneralCategory.swift index 3da9e8666..22bb8c943 100644 --- a/Utils/gen-unicode-data/Sources/GenScalarProps/GeneralCategory.swift +++ b/Utils/gen-unicode-data/Sources/GenScalarProps/GeneralCategory.swift @@ -6,7 +6,6 @@ // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information -// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// diff --git a/Utils/gen-unicode-data/Sources/GenScalarProps/Mappings.swift b/Utils/gen-unicode-data/Sources/GenScalarProps/Mappings.swift index 1e8886fce..37c000c90 100644 --- a/Utils/gen-unicode-data/Sources/GenScalarProps/Mappings.swift +++ b/Utils/gen-unicode-data/Sources/GenScalarProps/Mappings.swift @@ -6,7 +6,6 @@ // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information -// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// diff --git a/Utils/gen-unicode-data/Sources/GenScalarProps/NameAlias.swift b/Utils/gen-unicode-data/Sources/GenScalarProps/NameAlias.swift index 9cb5a9aee..23df53b27 100644 --- a/Utils/gen-unicode-data/Sources/GenScalarProps/NameAlias.swift +++ b/Utils/gen-unicode-data/Sources/GenScalarProps/NameAlias.swift @@ -6,7 +6,6 @@ // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information -// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// diff --git a/Utils/gen-unicode-data/Sources/GenScalarProps/Names.swift b/Utils/gen-unicode-data/Sources/GenScalarProps/Names.swift index 22616576b..baff7f17b 100644 --- a/Utils/gen-unicode-data/Sources/GenScalarProps/Names.swift +++ b/Utils/gen-unicode-data/Sources/GenScalarProps/Names.swift @@ -6,7 +6,6 @@ // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information -// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// diff --git a/Utils/gen-unicode-data/Sources/GenScalarProps/Numeric.swift b/Utils/gen-unicode-data/Sources/GenScalarProps/Numeric.swift index c91cf66d2..89e33515b 100644 --- a/Utils/gen-unicode-data/Sources/GenScalarProps/Numeric.swift +++ b/Utils/gen-unicode-data/Sources/GenScalarProps/Numeric.swift @@ -6,7 +6,6 @@ // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information -// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// diff --git a/Utils/gen-unicode-data/Sources/GenScalarProps/main.swift b/Utils/gen-unicode-data/Sources/GenScalarProps/main.swift index c86053c1b..9e2ef6297 100644 --- a/Utils/gen-unicode-data/Sources/GenScalarProps/main.swift +++ b/Utils/gen-unicode-data/Sources/GenScalarProps/main.swift @@ -6,7 +6,6 @@ // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information -// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// diff --git a/Utils/gen-unicode-data/Sources/GenUtils/BitArray.swift b/Utils/gen-unicode-data/Sources/GenUtils/BitArray.swift index 0501a4731..a8f9b8961 100644 --- a/Utils/gen-unicode-data/Sources/GenUtils/BitArray.swift +++ b/Utils/gen-unicode-data/Sources/GenUtils/BitArray.swift @@ -6,7 +6,6 @@ // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information -// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// diff --git a/Utils/gen-unicode-data/Sources/GenUtils/Emit.swift b/Utils/gen-unicode-data/Sources/GenUtils/Emit.swift index 66c13daa1..464f431d2 100644 --- a/Utils/gen-unicode-data/Sources/GenUtils/Emit.swift +++ b/Utils/gen-unicode-data/Sources/GenUtils/Emit.swift @@ -6,7 +6,6 @@ // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information -// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// diff --git a/Utils/gen-unicode-data/Sources/GenUtils/Files.swift b/Utils/gen-unicode-data/Sources/GenUtils/Files.swift index fad261d08..26c881abe 100644 --- a/Utils/gen-unicode-data/Sources/GenUtils/Files.swift +++ b/Utils/gen-unicode-data/Sources/GenUtils/Files.swift @@ -6,7 +6,6 @@ // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information -// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// diff --git a/Utils/gen-unicode-data/Sources/GenUtils/Flatten.swift b/Utils/gen-unicode-data/Sources/GenUtils/Flatten.swift index 309e0d490..e8eb197c4 100644 --- a/Utils/gen-unicode-data/Sources/GenUtils/Flatten.swift +++ b/Utils/gen-unicode-data/Sources/GenUtils/Flatten.swift @@ -6,7 +6,6 @@ // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information -// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// diff --git a/Utils/gen-unicode-data/Sources/GenUtils/Formatting.swift b/Utils/gen-unicode-data/Sources/GenUtils/Formatting.swift index 3bc75b0f9..ec6108c7e 100644 --- a/Utils/gen-unicode-data/Sources/GenUtils/Formatting.swift +++ b/Utils/gen-unicode-data/Sources/GenUtils/Formatting.swift @@ -6,7 +6,6 @@ // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information -// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// diff --git a/Utils/gen-unicode-data/Sources/GenUtils/Hashing.swift b/Utils/gen-unicode-data/Sources/GenUtils/Hashing.swift index 9d13cf109..c9b283b2f 100644 --- a/Utils/gen-unicode-data/Sources/GenUtils/Hashing.swift +++ b/Utils/gen-unicode-data/Sources/GenUtils/Hashing.swift @@ -6,7 +6,6 @@ // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information -// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// diff --git a/Utils/gen-unicode-data/Sources/GenUtils/Mph.swift b/Utils/gen-unicode-data/Sources/GenUtils/Mph.swift index 71e199207..34ccb3003 100644 --- a/Utils/gen-unicode-data/Sources/GenUtils/Mph.swift +++ b/Utils/gen-unicode-data/Sources/GenUtils/Mph.swift @@ -6,7 +6,6 @@ // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information -// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// From ed29672e41ddc594ec48197b27ffee991e5d7f5f Mon Sep 17 00:00:00 2001 From: Nate Cook Date: Mon, 7 Jul 2025 17:37:13 -0500 Subject: [PATCH 7/9] =?UTF-8?q?More=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Sources/_CUnicode/Common/ScriptData.h | 1 - Sources/_CUnicode/UnicodeData.c | 1 - Sources/_CUnicode/UnicodeScalarProps.c | 1 - Sources/_CUnicode/include/UnicodeData.h | 1 - 4 files changed, 4 deletions(-) diff --git a/Sources/_CUnicode/Common/ScriptData.h b/Sources/_CUnicode/Common/ScriptData.h index e5b6c68bc..8f4e54735 100644 --- a/Sources/_CUnicode/Common/ScriptData.h +++ b/Sources/_CUnicode/Common/ScriptData.h @@ -6,7 +6,6 @@ // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information -// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// diff --git a/Sources/_CUnicode/UnicodeData.c b/Sources/_CUnicode/UnicodeData.c index 01dc4dae5..4dae617d2 100644 --- a/Sources/_CUnicode/UnicodeData.c +++ b/Sources/_CUnicode/UnicodeData.c @@ -6,7 +6,6 @@ // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information -// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// diff --git a/Sources/_CUnicode/UnicodeScalarProps.c b/Sources/_CUnicode/UnicodeScalarProps.c index 9a353aa3c..d7d52ec8d 100644 --- a/Sources/_CUnicode/UnicodeScalarProps.c +++ b/Sources/_CUnicode/UnicodeScalarProps.c @@ -6,7 +6,6 @@ // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information -// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// diff --git a/Sources/_CUnicode/include/UnicodeData.h b/Sources/_CUnicode/include/UnicodeData.h index 2ca952231..ac7f47a35 100644 --- a/Sources/_CUnicode/include/UnicodeData.h +++ b/Sources/_CUnicode/include/UnicodeData.h @@ -6,7 +6,6 @@ // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information -// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// From 834886274e3acf9ebc6979edee8abe89c3df8a03 Mon Sep 17 00:00:00 2001 From: Nate Cook Date: Tue, 8 Jul 2025 00:07:01 -0500 Subject: [PATCH 8/9] More license changes ...and excluding python files, since the license check doesn't allow a #! at the start of a file. --- .licenseignore | 1 + Sources/_RegexParser/Regex/TreeProtocols.swift | 11 ++++++++++- Sources/_StringProcessing/Engine/MEBuiltins.swift | 11 +++++++++++ Sources/_StringProcessing/Engine/MEQuantify.swift | 11 +++++++++++ Sources/_StringProcessing/Engine/Metrics.swift | 11 +++++++++++ Sources/_StringProcessing/Engine/Structuralize.swift | 11 +++++++++++ Sources/_StringProcessing/Utility/AsciiBitset.swift | 11 +++++++++++ Tests/RegexBuilderTests/AnyRegexOutputTests.swift | 10 ++++++++++ Tests/RegexTests/AnyRegexOutputTests.swift | 10 ++++++++++ 9 files changed, 86 insertions(+), 1 deletion(-) diff --git a/.licenseignore b/.licenseignore index fc621f77e..766f10a2e 100644 --- a/.licenseignore +++ b/.licenseignore @@ -10,6 +10,7 @@ .editorconfig .github/* .build +*.py *.yml *.yaml *.cmake diff --git a/Sources/_RegexParser/Regex/TreeProtocols.swift b/Sources/_RegexParser/Regex/TreeProtocols.swift index 7f1ccb5f7..a54401093 100644 --- a/Sources/_RegexParser/Regex/TreeProtocols.swift +++ b/Sources/_RegexParser/Regex/TreeProtocols.swift @@ -1,4 +1,13 @@ - +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift.org open source project +// +// Copyright (c) 2021-2022 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See https://swift.org/LICENSE.txt for license information +// +//===----------------------------------------------------------------------===// public protocol _TreeNode { var children: [Self]? { get } diff --git a/Sources/_StringProcessing/Engine/MEBuiltins.swift b/Sources/_StringProcessing/Engine/MEBuiltins.swift index ab47a1a5f..f6d97555d 100644 --- a/Sources/_StringProcessing/Engine/MEBuiltins.swift +++ b/Sources/_StringProcessing/Engine/MEBuiltins.swift @@ -1,3 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift.org open source project +// +// Copyright (c) 2021-2022 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See https://swift.org/LICENSE.txt for license information +// +//===----------------------------------------------------------------------===// + internal import _RegexParser // For AssertionKind extension Character { var _isHorizontalWhitespace: Bool { diff --git a/Sources/_StringProcessing/Engine/MEQuantify.swift b/Sources/_StringProcessing/Engine/MEQuantify.swift index 48bbb9e9c..86e077616 100644 --- a/Sources/_StringProcessing/Engine/MEQuantify.swift +++ b/Sources/_StringProcessing/Engine/MEQuantify.swift @@ -1,3 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift.org open source project +// +// Copyright (c) 2021-2022 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See https://swift.org/LICENSE.txt for license information +// +//===----------------------------------------------------------------------===// + internal import _RegexParser private typealias ASCIIBitset = DSLTree.CustomCharacterClass.AsciiBitset diff --git a/Sources/_StringProcessing/Engine/Metrics.swift b/Sources/_StringProcessing/Engine/Metrics.swift index 372a7e1b4..8f3405a15 100644 --- a/Sources/_StringProcessing/Engine/Metrics.swift +++ b/Sources/_StringProcessing/Engine/Metrics.swift @@ -1,3 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift.org open source project +// +// Copyright (c) 2021-2022 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See https://swift.org/LICENSE.txt for license information +// +//===----------------------------------------------------------------------===// + extension Processor { #if PROCESSOR_MEASUREMENTS_ENABLED struct ProcessorMetrics { diff --git a/Sources/_StringProcessing/Engine/Structuralize.swift b/Sources/_StringProcessing/Engine/Structuralize.swift index d91d0f1a9..eed2e6cd0 100644 --- a/Sources/_StringProcessing/Engine/Structuralize.swift +++ b/Sources/_StringProcessing/Engine/Structuralize.swift @@ -1,3 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift.org open source project +// +// Copyright (c) 2021-2022 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See https://swift.org/LICENSE.txt for license information +// +//===----------------------------------------------------------------------===// + internal import _RegexParser @available(SwiftStdlib 5.7, *) diff --git a/Sources/_StringProcessing/Utility/AsciiBitset.swift b/Sources/_StringProcessing/Utility/AsciiBitset.swift index 2b0217cdc..61a6a6891 100644 --- a/Sources/_StringProcessing/Utility/AsciiBitset.swift +++ b/Sources/_StringProcessing/Utility/AsciiBitset.swift @@ -1,3 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift.org open source project +// +// Copyright (c) 2021-2022 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See https://swift.org/LICENSE.txt for license information +// +//===----------------------------------------------------------------------===// + // TODO: Probably refactor out of DSLTree extension DSLTree.CustomCharacterClass { internal struct AsciiBitset { diff --git a/Tests/RegexBuilderTests/AnyRegexOutputTests.swift b/Tests/RegexBuilderTests/AnyRegexOutputTests.swift index 6e36f4d9d..f8caed509 100644 --- a/Tests/RegexBuilderTests/AnyRegexOutputTests.swift +++ b/Tests/RegexBuilderTests/AnyRegexOutputTests.swift @@ -1,3 +1,13 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift.org open source project +// +// Copyright (c) 2021-2022 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See https://swift.org/LICENSE.txt for license information +// +//===----------------------------------------------------------------------===// import XCTest import _StringProcessing diff --git a/Tests/RegexTests/AnyRegexOutputTests.swift b/Tests/RegexTests/AnyRegexOutputTests.swift index 10bb6a061..bd3b8c552 100644 --- a/Tests/RegexTests/AnyRegexOutputTests.swift +++ b/Tests/RegexTests/AnyRegexOutputTests.swift @@ -1,3 +1,13 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift.org open source project +// +// Copyright (c) 2021-2022 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See https://swift.org/LICENSE.txt for license information +// +//===----------------------------------------------------------------------===// import _StringProcessing import XCTest From a1e1813865a0422f9401bc37899c54a43d34370a Mon Sep 17 00:00:00 2001 From: Nate Cook Date: Tue, 8 Jul 2025 00:14:14 -0500 Subject: [PATCH 9/9] YAML and Python lint changes --- .github/workflows/pull_request.yml | 1 - .../generateDiceNotation.py | 55 +++++++++++-------- Utils/benchmark-generators/generateEmails.py | 18 +++--- .../generateNetworkingData.py | 23 +++++--- .../generateTaggedUnicode.py | 11 +++- Utils/createBenchmark.py | 28 ++++++---- 6 files changed, 81 insertions(+), 55 deletions(-) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index bbf00bd4b..e9263e855 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -20,4 +20,3 @@ jobs: with: license_header_check_project_name: "Swift.org" unacceptable_language_check_enabled: false - diff --git a/Utils/benchmark-generators/generateDiceNotation.py b/Utils/benchmark-generators/generateDiceNotation.py index b7cbe9cc8..2b6344063 100644 --- a/Utils/benchmark-generators/generateDiceNotation.py +++ b/Utils/benchmark-generators/generateDiceNotation.py @@ -17,30 +17,39 @@ minDigits = 1 maxDigits = 4 + def number(): - return "".join([random.choice(string.digits) for _ in range(random.randint(minDigits,maxDigits))]) + return "".join([random.choice(string.digits) + for _ in range(random.randint(minDigits, maxDigits))]) + minWord = 5 maxWord = 10 + + def word(): - return "".join([random.choice(string.ascii_letters) for _ in range(random.randint(minWord,maxWord))]) + return "".join([random.choice(string.ascii_letters) + for _ in range(random.randint(minWord, maxWord))]) + minDice = 1 maxDice = 4 + + def roll(): - die = [] - for _ in range(random.randint(minDice, maxDice)): - roll = "" - if random.randint(0,1) == 1: - roll += number() - - if random.randint(0,1) == 1: - roll += "d" + number() - else: - roll += "D" + number() - - die.append(roll) - return "+".join(die) + die = [] + for _ in range(random.randint(minDice, maxDice)): + roll = "" + if random.randint(0, 1) == 1: + roll += number() + + if random.randint(0, 1) == 1: + roll += "d" + number() + else: + roll += "D" + number() + + die.append(roll) + return "+".join(die) line_num = 2000 @@ -48,19 +57,19 @@ def roll(): lines = [] for _ in range(line_num): - line = [] - for _ in range(things_per_line): - if random.randint(0,1) == 1: - line.append(word()) - else: - line.append(roll()) - lines.append(" ".join(line)) + line = [] + for _ in range(things_per_line): + if random.randint(0, 1) == 1: + line.append(word()) + else: + line.append(roll()) + lines.append(" ".join(line)) dice_text = "\n ".join(lines) dice_rolls = [] for _ in range(2000): - dice_rolls.append(roll()) + dice_rolls.append(roll()) dice_rolls_formatted = "[" + ",\n ".join(["\"" + x + "\"" for x in dice_rolls]) + "]" diff --git a/Utils/benchmark-generators/generateEmails.py b/Utils/benchmark-generators/generateEmails.py index ceaedb3a5..860437fb0 100644 --- a/Utils/benchmark-generators/generateEmails.py +++ b/Utils/benchmark-generators/generateEmails.py @@ -26,15 +26,15 @@ # issues but otherwise this should work emails = [] for _ in range(n): - domain_len = random.randint(2,64) - locale_len = random.randint(2,64) - tld_len = random.randint(2,10) - - domain = "".join(random.sample(domain_charset, domain_len)) - locale = "".join(random.sample(locale_charset, locale_len)) - tld = "".join(random.sample(string.ascii_lowercase, tld_len)) - email = locale + "@" + domain + "." + tld - emails.append(email) + domain_len = random.randint(2, 64) + locale_len = random.randint(2, 64) + tld_len = random.randint(2, 10) + + domain = "".join(random.sample(domain_charset, domain_len)) + locale = "".join(random.sample(locale_charset, locale_len)) + tld = "".join(random.sample(string.ascii_lowercase, tld_len)) + email = locale + "@" + domain + "." + tld + emails.append(email) res = """ extension Inputs {{ diff --git a/Utils/benchmark-generators/generateNetworkingData.py b/Utils/benchmark-generators/generateNetworkingData.py index e1cd3d518..984f2aaf3 100644 --- a/Utils/benchmark-generators/generateNetworkingData.py +++ b/Utils/benchmark-generators/generateNetworkingData.py @@ -14,20 +14,25 @@ random.seed(0) + def ipv6(): - return ":".join(["".join([random.choice(string.hexdigits) for _ in range(4)]) for _ in range(8)]) + return ":".join(["".join([random.choice(string.hexdigits) + for _ in range(4)]) for _ in range(8)]) + def ipv4(): - return ".".join([str(random.randint(1,255)) for _ in range(4)]) + return ".".join([str(random.randint(1, 255)) for _ in range(4)]) + def mac(): - x = random.randint(0,1) - if x == 0: - raw = "{:02x}".format(random.randint(0,2**48-1)) - return ":".join([raw[i:i + 2] for i in range(0, len(raw), 2)]) - else: - raw = "{:02x}".format(random.randint(0,2**48-1)) - return "-".join([raw[i:i + 2] for i in range(0, len(raw), 2)]) + x = random.randint(0, 1) + if x == 0: + raw = "{:02x}".format(random.randint(0, 2**48 - 1)) + return ":".join([raw[i:i + 2] for i in range(0, len(raw), 2)]) + else: + raw = "{:02x}".format(random.randint(0, 2**48 - 1)) + return "-".join([raw[i:i + 2] for i in range(0, len(raw), 2)]) + res = """ extension Inputs {{ diff --git a/Utils/benchmark-generators/generateTaggedUnicode.py b/Utils/benchmark-generators/generateTaggedUnicode.py index 60b23db72..0277d7ed5 100644 --- a/Utils/benchmark-generators/generateTaggedUnicode.py +++ b/Utils/benchmark-generators/generateTaggedUnicode.py @@ -27,9 +27,14 @@ minLine = 10 maxLine = 100 + def get_random(i): - return "".join([chr(random.randint(low, high)) for _ in range(i)]) - -lines = [start + get_random(random.randint(minLine, maxLine)) + end for _ in range(numLines)] + return "".join([chr(random.randint(low, high)) for _ in range(i)]) + + +lines = [ + start + get_random(random.randint(minLine, maxLine)) + end + for _ in range(numLines) +] print("\n".join(lines)) diff --git a/Utils/createBenchmark.py b/Utils/createBenchmark.py index 82636f64c..8038c06ba 100644 --- a/Utils/createBenchmark.py +++ b/Utils/createBenchmark.py @@ -10,12 +10,14 @@ ##===----------------------------------------------------------------------===## # python3 createBenchmark.py MyRegexBenchmark -# reference: https://github.com/apple/swift/blob/main/benchmark/scripts/create_benchmark.py +# reference: +# https://github.com/apple/swift/blob/main/benchmark/scripts/create_benchmark.py import argparse import os -template = """//===----------------------------------------------------------------------===// +template = """\ +//===----------------------------------------------------------------------===// // // This source file is part of the Swift.org open source project // @@ -34,34 +36,38 @@ }} """ + def main(): p = argparse.ArgumentParser() p.add_argument("name", help="The name of the new benchmark to be created") args = p.parse_args() - + # create a file in Sources/RegexBenchmark/Suite with the benchmark template create_benchmark_file(args.name) - + # add to the registration function in BenchmarkRunner register_benchmark(args.name) + def create_benchmark_file(name): - contents = template.format(name= name) + contents = template.format(name=name) relative_path = create_relative_path("../Sources/RegexBenchmark/Suite/") source_file_path = os.path.join(relative_path, name + ".swift") - + print(f"Creating new benchmark file: {source_file_path}") with open(source_file_path, "w") as f: f.write(contents) + def register_benchmark(name): - relative_path = create_relative_path("../Sources/RegexBenchmark/BenchmarkRegistration.swift") + relative_path = create_relative_path( + "../Sources/RegexBenchmark/BenchmarkRegistration.swift") # read current contents into an array file_contents = [] with open(relative_path, "r") as f: file_contents = f.readlines() - + new_file_contents = [] for line in file_contents: if "end of registrations" not in line: @@ -70,14 +76,16 @@ def register_benchmark(name): # add the newest benchmark new_file_contents.append(f" self.add{name}()\n") new_file_contents.append(line) - + # write the new contents with open(relative_path, "w") as f: for line in new_file_contents: f.write(line) - + + def create_relative_path(file_path): return os.path.join(os.path.dirname(__file__), file_path) + if __name__ == "__main__": main()