From 7fb736f53eb4d47c7f9ce0d082acc938acd131e1 Mon Sep 17 00:00:00 2001 From: Qiu Yuzhou Date: Sun, 4 Oct 2026 00:22:45 +0800 Subject: [PATCH] =?UTF-8?q?test:=20=E4=B8=BA=E4=BB=A3=E7=90=86=E6=8E=A7?= =?UTF-8?q?=E5=88=B6=E9=9B=86=E6=88=90=E6=B5=8B=E8=AF=95=E6=B3=A8=E5=85=A5?= =?UTF-8?q?=E5=B0=8F=E8=A7=84=E5=88=99=E5=A4=B9=E5=85=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ProxyControlWorkflowIntegrationTests.swift | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/ShadowsocksX-NG2/Tests/ProxyControlWorkflowIntegrationTests.swift b/ShadowsocksX-NG2/Tests/ProxyControlWorkflowIntegrationTests.swift index 2a6e5dd5..a8accfb7 100644 --- a/ShadowsocksX-NG2/Tests/ProxyControlWorkflowIntegrationTests.swift +++ b/ShadowsocksX-NG2/Tests/ProxyControlWorkflowIntegrationTests.swift @@ -73,6 +73,8 @@ final class ProxyControlWorkflowIntegrationTests: XCTestCase { settings: ActivationFixture.listen, unreadableError: nil), settingsStore: settingsStore ?? InMemoryProxySettingsStore(), appBundle: AppArtifact.bundle, + // Keep real ACL compilation; corpus coverage belongs to the packaged-rule tests. + ruleSnapshots: BuiltinRuleSnapshots(loader: Self.controlFlowRuleSnapshot), settingsRestore: RestoredProxySettings( settings: settings ?? ProxySettings(listen: ActivationFixture.listen), unreadableError: nil), @@ -304,3 +306,34 @@ final class ProxyControlWorkflowIntegrationTests: XCTestCase { } } + +extension ProxyControlWorkflowIntegrationTests { + fileprivate nonisolated static func controlFlowRuleSnapshot(_ source: RulesSource) throws + -> RuleSnapshot + { + switch source { + case .geolocationCN: + return rulesFixture( + source, + rules: [ + ProxyRule(action: .direct, match: .domainExact("direct.example")), + ProxyRule(action: .direct, match: .domainSuffix("internal.example")), + ]) + case .chinaIPv4: + return rulesFixture( + source, + rules: [ + ProxyRule(action: .direct, match: .ipv4CIDR("1.0.0.0/24")) + ]) + case .gfwlist: + return rulesFixture( + source, + rules: [ + ProxyRule(action: .proxy, match: .domainSuffix("proxy.example")), + ProxyRule(action: .direct, match: .domainExact("safe.proxy.example")), + ]) + case .custom, .fixed: + throw RuleSnapshotError.missing + } + } +}