代码之家  ›  专栏  ›  技术社区  ›  Charlie Fish

重击错误的退出代码

  •  1
  • Charlie Fish  · 技术社区  · 7 年前

    在CircleCI我在跑步 npm run test-ci 在我的配置文件中。

    我的软件包中有以下脚本。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",
    

    问题是,摩卡测试失败了,但它仍然在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
    
    1 回复  |  直到 7 年前
        1
  •  1
  •   alindobre    7 年前

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

    根本原因似乎是摩卡咖啡,或者更具体地说是诺德咖啡。发布了一个github问题: Mocha exits with 0 exit code with failing tests #2713

    从问题评论来看,它似乎在节点8.10中得到了修复。

    推荐文章