Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
赵月辉
/
fastgpt-migrated
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Unverified
Commit
f64a5caf
authored
Mar 03, 2026
by
Archer
Committed by
GitHub
Mar 03, 2026
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add test (#6498)
parent
95f01662
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
50 additions
and
2 deletions
+50
-2
projects/sandbox/test/integration/functional.test.ts
+50
-2
No files found.
projects/sandbox/test/integration/functional.test.ts
View file @
f64a5caf
...
@@ -21,6 +21,7 @@ interface TestCase {
...
@@ -21,6 +21,7 @@ interface TestCase {
codeReturnMatch
?:
Record
<
string
,
any
>
;
// 部分匹配
codeReturnMatch
?:
Record
<
string
,
any
>
;
// 部分匹配
errorMatch
?:
RegExp
;
// 错误信息匹配
errorMatch
?:
RegExp
;
// 错误信息匹配
hasLog
?:
boolean
;
// 是否有日志输出
hasLog
?:
boolean
;
// 是否有日志输出
logMatch
?:
RegExp
;
// 日志内容匹配
};
};
}
}
...
@@ -49,6 +50,9 @@ function runMatrix(getPool: () => ProcessPool | PythonProcessPool, cases: TestCa
...
@@ -49,6 +50,9 @@ function runMatrix(getPool: () => ProcessPool | PythonProcessPool, cases: TestCa
expect
(
result
.
data
?.
log
).
toBeTruthy
();
expect
(
result
.
data
?.
log
).
toBeTruthy
();
expect
(
result
.
data
!
.
log
!
.
length
).
toBeGreaterThan
(
0
);
expect
(
result
.
data
!
.
log
!
.
length
).
toBeGreaterThan
(
0
);
}
}
if
(
tc
.
expect
.
logMatch
)
{
expect
(
result
.
data
?.
log
).
toMatch
(
tc
.
expect
.
logMatch
);
}
});
});
}
}
}
}
...
@@ -195,7 +199,7 @@ describe('JS 功能测试', () => {
...
@@ -195,7 +199,7 @@ describe('JS 功能测试', () => {
);
);
});
});
// --- console
.log
日志 ---
// --- console 日志 ---
describe
(
'日志输出'
,
()
=>
{
describe
(
'日志输出'
,
()
=>
{
runMatrix
(
runMatrix
(
()
=>
pool
,
()
=>
pool
,
...
@@ -203,7 +207,32 @@ describe('JS 功能测试', () => {
...
@@ -203,7 +207,32 @@ describe('JS 功能测试', () => {
{
{
name
:
'console.log 被捕获'
,
name
:
'console.log 被捕获'
,
code
:
`async function main() { console.log('debug info'); return { done: true }; }`
,
code
:
`async function main() { console.log('debug info'); return { done: true }; }`
,
expect
:
{
success
:
true
,
codeReturn
:
{
done
:
true
},
hasLog
:
true
}
expect
:
{
success
:
true
,
codeReturn
:
{
done
:
true
},
logMatch
:
/debug info/
}
},
{
name
:
'console.error 不报错,内容被捕获'
,
code
:
`async function main() { console.error('err msg'); return { done: true }; }`
,
expect
:
{
success
:
true
,
codeReturn
:
{
done
:
true
},
logMatch
:
/err msg/
}
},
{
name
:
'console.warn 不报错,内容被捕获'
,
code
:
`async function main() { console.warn('warn msg'); return { done: true }; }`
,
expect
:
{
success
:
true
,
codeReturn
:
{
done
:
true
},
logMatch
:
/warn msg/
}
},
{
name
:
'console.info 不报错,内容被捕获'
,
code
:
`async function main() { console.info('info msg'); return { done: true }; }`
,
expect
:
{
success
:
true
,
codeReturn
:
{
done
:
true
},
logMatch
:
/info msg/
}
},
{
name
:
'console.debug 不报错,内容被捕获'
,
code
:
`async function main() { console.debug('debug msg'); return { done: true }; }`
,
expect
:
{
success
:
true
,
codeReturn
:
{
done
:
true
},
logMatch
:
/debug msg/
}
},
{
name
:
'多次 console 调用均被捕获'
,
code
:
`async function main() { console.log('a'); console.warn('b'); console.error('c'); return { done: true }; }`
,
expect
:
{
success
:
true
,
codeReturn
:
{
done
:
true
},
logMatch
:
/a/
}
}
}
]
]
);
);
...
@@ -602,6 +631,25 @@ describe('Python 功能测试', () => {
...
@@ -602,6 +631,25 @@ describe('Python 功能测试', () => {
);
);
});
});
// --- print 日志 ---
describe
(
'日志输出'
,
()
=>
{
runMatrix
(
()
=>
pool
,
[
{
name
:
'print 被捕获'
,
code
:
`def main():\n print('hello log')\n return {'done': True}`
,
expect
:
{
success
:
true
,
codeReturn
:
{
done
:
true
},
logMatch
:
/hello log/
}
},
{
name
:
'多次 print 均被捕获'
,
code
:
`def main():\n print('line1')\n print('line2')\n return {'done': True}`
,
expect
:
{
success
:
true
,
logMatch
:
/line1/
}
}
]
);
});
// --- 错误处理 ---
// --- 错误处理 ---
describe
(
'错误处理'
,
()
=>
{
describe
(
'错误处理'
,
()
=>
{
runMatrix
(
runMatrix
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment