修复原生壳静态断言格式兼容
Project CI / Repository checks (push) Successful in 4m5s
Project CI / Frontend tests (push) Successful in 4m59s
Project CI / Backend tests (push) Successful in 8m12s
Project CI / Native shell tests (push) Failing after 18m0s

放宽能力文档方法表的 Markdown 空白解析

统一源码片段断言的空白、括号与尾逗号归一化
This commit is contained in:
2026-09-01 18:37:41 +08:00
parent 80f34d062d
commit a187d78a1c
+18 -7
View File
@@ -3608,7 +3608,7 @@ function extractDocumentMethodTable(source) {
throw new Error('native shell plan method table missing end marker');
}
return [...source.slice(start, end).matchAll(/^\| `([^`]+)` \|/gm)].map(
return [...source.slice(start, end).matchAll(/^\|\s*`([^`]+)`\s*\|/gm)].map(
(entry) => entry[1],
);
}
@@ -3831,7 +3831,7 @@ function assertNativeShellCapabilityPlan() {
],
]) {
for (const snippet of snippets) {
if (!source.includes(snippet)) {
if (!sourceIncludesSnippet(source, snippet)) {
throw new Error(
`${label} must derive unsupported methods from shared method list`,
);
@@ -4118,7 +4118,7 @@ function assertWechatMiniProgramRouteParity() {
"readWebViewSourceQueryValue('clientType')",
"readWebViewSourceQueryValue('clientRuntime')",
]) {
if (!webViewShellSource.includes(snippet)) {
if (!sourceIncludesSnippet(webViewShellSource, snippet)) {
throw new Error(
'wechat request headers must read runtime markers from WEB_VIEW_SOURCE_QUERY',
);
@@ -4136,11 +4136,22 @@ function assertWechatMiniProgramRouteParity() {
function assertFileIncludesSnippet(filePath, snippet, label) {
const source = fs.readFileSync(filePath, 'utf8');
if (!source.includes(snippet)) {
if (!sourceIncludesSnippet(source, snippet)) {
throw new Error(`${label} must include ${snippet} in ${filePath}`);
}
}
function sourceIncludesSnippet(source, snippet) {
const compact = (value) =>
value
.replace(/\s+/g, ' ')
.replace(/\s*([()[\]{}])\s*/g, '$1')
.replace(/\s*,\s*/g, ',')
.replace(/,\)/g, ')')
.trim();
return source.includes(snippet) || compact(source).includes(compact(snippet));
}
function assertWechatMiniProgramCapabilityFlows() {
const protocol = requireCommonJsModule('miniprogram/host-bridge/protocol.js');
const declaredCapabilities = protocol.WECHAT_HOST_CAPABILITIES ?? [];
@@ -4461,7 +4472,7 @@ function assertWechatAuthFailureBoundaries() {
"console.warn('[web-view] read mini program env failed')",
'logMiniProgramEnvReadFailure(error)',
]) {
if (!webViewShellSource.includes(snippet)) {
if (!sourceIncludesSnippet(webViewShellSource, snippet)) {
throw new Error(
`wechat web-view env diagnostics must include ${snippet}`,
);
@@ -4497,7 +4508,7 @@ function assertWechatAuthFailureBoundaries() {
'errorMessage: WECHAT_BIND_PHONE_UNAVAILABLE_MESSAGE',
'errorMessage: WECHAT_BIND_PHONE_AUTH_REQUIRED_MESSAGE',
]) {
if (!webViewShellSource.includes(snippet)) {
if (!sourceIncludesSnippet(webViewShellSource, snippet)) {
throw new Error(`wechat auth shell must include ${snippet}`);
}
}
@@ -4566,7 +4577,7 @@ function assertWechatWebViewPageEventBoundaries() {
"logWebViewPageFailure('load failed', event.detail)",
"logWebViewPageEvent('message', event.detail)",
]) {
if (!webViewShellSource.includes(snippet)) {
if (!sourceIncludesSnippet(webViewShellSource, snippet)) {
throw new Error(
`wechat web-view page event diagnostics must include ${snippet}`,
);