gpt4 book ai didi

node.js - Bash 错误的退出代码

转载 作者:太空宇宙 更新时间:2023-11-04 00:03:34 26 4
gpt4 key购买 nike

在 CircleCI 上,我在配置文件中运行 npm run test-ci

我的 package.json 中有以下脚本:

"test-ci": ". ./envvars/test.sh && nyc --all mocha --recursive --timeout 10000 && npm run report-coverage-ci",
"report-coverage-ci": "nyc report --reporter=text-lcov > coverage.lcov && codecov -f coverage.json && echo CodeCov Done",

问题是,Mocha 测试失败,但在 CircleCI 上仍然显示测试成功。

因此,如果 Mocha 测试失败,它不应该继续到报告代码覆盖率等所有内容的部分。但它正在继续该部分。

您可以看到下面日志的最后一部分(我已经撤回了一些敏感信息)。

我该如何解决这个问题?

    ✓ Should work with last key (3760ms)

<--- Last few GCs --->

[8488:0x3743ca0] 140011 ms: Scavenge 1328.2 (1422.9) -> 1327.9 (1423.9) MB, 7.2 / 0.0 ms (average mu = 0.151, current mu = 0.118) allocation failure
[8488:0x3743ca0] 140033 ms: Scavenge 1328.7 (1423.9) -> 1328.3 (1424.4) MB, 15.9 / 0.0 ms (average mu = 0.151, current mu = 0.118) allocation failure
[8488:0x3743ca0] 140056 ms: Scavenge 1329.1 (1424.4) -> 1328.8 (1425.4) MB, 7.7 / 0.0 ms (average mu = 0.151, current mu = 0.118) allocation failure


<--- JS stacktrace --->

==== JS stack trace =========================================

0: ExitFrame [pc: 0x1581d2a5c01d]
Security context: 0x18382199e549 <JSObject>
1: /* anonymous */ [0x74025342ac9] [/home/circleci/repo/node_modules/q/q.js:~846] [pc=0x1581d355b56f](this=0x1ccc2a3a6ac9 <Object map = 0x3093e6868539>,fulfilled=0x1ccc2a3a67c1 <JSFunction query (sfi = 0x35b314d784e9)>,rejected=0x3344031826f1 <undefined>,progressed=0x3344031826f1 <undefined>)
2: arguments adaptor frame: 1->3
3: /* anonymous */ [0...

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
1: 0x8c02c0 node::Abort() [/opt/circleci/.nvm/versions/node/v10.9.0/bin/node]
2: 0x8c030c [/opt/circleci/.nvm/versions/node/v10.9.0/bin/node]
3: 0xad15de v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/opt/circleci/.nvm/versions/node/v10.9.0/bin/node]
4: 0xad1814 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/opt/circleci/.nvm/versions/node/v10.9.0/bin/node]
5: 0xebe752 [/opt/circleci/.nvm/versions/node/v10.9.0/bin/node]
6: 0xebe858 v8::internal::Heap::CheckIneffectiveMarkCompact(unsigned long, double) [/opt/circleci/.nvm/versions/node/v10.9.0/bin/node]
7: 0xeca982 v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [/opt/circleci/.nvm/versions/node/v10.9.0/bin/node]
8: 0xecb2b4 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/opt/circleci/.nvm/versions/node/v10.9.0/bin/node]
9: 0xecdf21 v8::internal::Heap::AllocateRawWithRetryOrFail(int, v8::internal::AllocationSpace, v8::internal::AllocationAlignment) [/opt/circleci/.nvm/versions/node/v10.9.0/bin/node]
10: 0xe97444 v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationSpace) [/opt/circleci/.nvm/versions/node/v10.9.0/bin/node]
11: 0x1136d5e v8::internal::Runtime_AllocateInNewSpace(int, v8::internal::Object**, v8::internal::Isolate*) [/opt/circleci/.nvm/versions/node/v10.9.0/bin/node]
12: 0x1581d2a5c01d
-----------------------------------------|----------|----------|----------|----------|-------------------|
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s |
-----------------------------------------|----------|----------|----------|----------|-------------------|
All files | 0 | 0 | 0 | 0 | |
repo | 0 | 0 | 100 | 0 | |
create_tables.js | 0 | 0 | 0 | 0 | |
-----------------------------------------|----------|----------|----------|----------|-------------------|

> Project@1.0.0 report-coverage-ci /home/circleci/repo
> nyc report --reporter=text-lcov > coverage.lcov && codecov -f coverage.json && echo CodeCov Done

_____ _
/ ____| | |
| | ___ __| | ___ ___ _____ __
| | / _ \ / _` |/ _ \/ __/ _ \ \ / /
| |___| (_) | (_| | __/ (_| (_) \ V /
\_____\___/ \__,_|\___|\___\___/ \_/
v3.1.0
==> Detecting CI Provider
Circle CI Detected
==> Configuration:
Endpoint: https://codecov.io
{ commit: '',
branch: 'master',
package: 'node-v3.1.0' }
==> Building file structure
==> Generating gcov reports (skip via --disable=gcov)
$ find /home/circleci/repo -type f -name '*.gcno' -exec gcov {} +
==> Targeting specific file
X Failed to read file at /home/circleci/repo/coverage.json
==> Uploading reports
Success!
View report at: https://codecov.io/github/rrainn/package/commit/
CodeCov Done

最佳答案

就 bash 而言,您的命令行是正确的。问题似乎是命令 nyc --all mocha --recursive --timeout 10000 失败,但以零退出代码完成执行。因此 && 运算符认为可以转到下一个命令。

根本原因似乎是在 mocha 中,或者更具体地说是在 Node 中。 github上发布了一个问题: Mocha exits with 0 exit code with failing tests #2713

从问题评论来看,它似乎已在 Node 8.10 中修复。

关于node.js - Bash 错误的退出代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53455281/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com