Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

try Stryker Mutator 4 (beta) #42

Draft
wants to merge 14 commits into
base: main
Choose a base branch
from
Draft

try Stryker Mutator 4 (beta) #42

wants to merge 14 commits into from

Conversation

brodycj
Copy link
Owner

@brodycj brodycj commented Aug 18, 2020

This is an attempt to try Stryker 4 beta with mutation switching as discussed in: stryker-mutator/stryker-js#1514

Some high-level JavaScript files are not included in the mutate list, and I removed a couple src files to avoid memory issues:

  • src/language-js/needs-parens.js
  • src/language-js/printer-estree.js
initial results with Stryker 4.0.0-beta.2, with Jest mutator At this point `npx stryker run --fileLogLevel trace --logLevel debug --timeoutMS 5000000` on an 8 vCPU cloud instance gives me this timeout error, shows more debug trace, then goes quiet:
15:11:43 (28071) DEBUG TimeoutDecorator Timeout expired, restarting the process and reporting timeout
15:11:45 (28071) DEBUG ChildProcessProxy Disposing of worker process 28085
15:11:47 (28071) DEBUG ChildProcessProxy Kill 28085
15:11:47 (28071) DEBUG ChildProcessProxy Starting /home/brodybits/prettier/node_modules/@stryker-mutator/core/src/test-runner/ChildProcessTestRunnerWorker.js in child process 28168
15:11:47 (28071) ERROR DryRunExecutor Initial test run timed out!
15:11:47 (28071) ERROR StrykerCli an error occurred Error: Something went wrong in the initial test run
    at DryRunExecutor.validateResultCompleted (/home/brodybits/prettier/node_modules/@stryker-mutator/core/src/process/3-DryRunExecutor.js:75:15)
    at DryRunExecutor.execute (/home/brodybits/prettier/node_modules/@stryker-mutator/core/src/process/3-DryRunExecutor.js:39:14)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async Stryker.runMutationTest (/home/brodybits/prettier/node_modules/@stryker-mutator/core/src/Stryker.js:30:45)
15:11:47 (28168) DEBUG ChildProcessProxyWorker Changing current working directory for this process to /home/brodybits/prettier/.stryker-tmp/sandbox4864588
15:11:47 (28168) DEBUG PluginLoader Loading @stryker-mutator/* from /home/brodybits/prettier/node_modules/@stryker-mutator
15:11:47 (28168) DEBUG PluginLoader Loading plugin "/home/brodybits/prettier/node_modules/@stryker-mutator/instrumenter" (matched with expression @stryker-mutator/*)
15:11:47 (28168) DEBUG PluginLoader Loading plugin "/home/brodybits/prettier/node_modules/@stryker-mutator/javascript-mutator" (matched with expression @stryker-mutator/*)
15:11:47 (28168) DEBUG PluginLoader Loading plugin "/home/brodybits/prettier/node_modules/@stryker-mutator/jest-runner" (matched with expression @stryker-mutator/*)
15:11:47 (28168) DEBUG PluginLoader Loading plugins /home/brodybits/prettier/node_modules/@stryker-mutator/instrumenter
15:11:47 (28168) DEBUG PluginLoader Loading plugins /home/brodybits/prettier/node_modules/@stryker-mutator/javascript-mutator
15:11:47 (28168) DEBUG PluginLoader Loading plugins /home/brodybits/prettier/node_modules/@stryker-mutator/jest-runner
15:11:47 (28168) DEBUG PluginLoader Loading plugins /home/brodybits/prettier/node_modules/@stryker-mutator/core/src/reporters/index.js
15:11:47 (28168) DEBUG CustomJestConfigLoader Read Jest config from /home/brodybits/prettier/.stryker-tmp/sandbox4864588/jest.config.js
15:11:47 (28168) DEBUG JestTestRunner Merging file-based config {
  "setupFiles": [
    "<rootDir>/tests_config/run_spec.js"
  ],
  "snapshotSerializers": [
    "jest-snapshot-serializer-raw",
    "jest-snapshot-serializer-ansi"
  ],
  "testRegex": "jsfmt\\.spec\\.js$|__tests__/.*\\.js$",
  "testPathIgnorePatterns": [],
  "collectCoverage": false,
  "collectCoverageFrom": [
    "src/**/*.js",
    "index.js",
    "!<rootDir>/node_modules/"
  ],
  "coveragePathIgnorePatterns": [
    "<rootDir>/standalone.js",
    "<rootDir>/src/document/doc-debug.js",
    "<rootDir>/src/main/massage-ast.js"
  ],
  "coverageReporters": [
    "text",
    "lcov"
  ],
  "moduleNameMapper": {
    "prettier/local": "<rootDir>/tests_config/require_prettier.js",
    "prettier/standalone": "<rootDir>/tests_config/require_standalone.js"
  },
  "testEnvironment": "node",
  "transform": {},
  "watchPlugins": [
    "jest-watch-typeahead/filename",
    "jest-watch-typeahead/testname"
  ]
} 
      with custom config {}
      and default (internal) stryker config [object Object]
15:11:47 (28168) DEBUG JestTestRunner Running jest with --findRelatedTests flag. Set jest.enableFindRelatedTests to false to run all tests on every mutant.
15:11:47 (28168) DEBUG JestTestRunner Project root is /home/brodybits/prettier/.stryker-tmp/sandbox4864588

I did try Stryker v2 in PR #16 last year but did not get so far.

Try the playground for this PR

@brodycj
Copy link
Owner Author

brodycj commented Aug 19, 2020

I have now updated to use commander runner with Stryker 4.0.0-beta.3 & merged a few updates from master.

I encountered a memory issue with npx stryker run on a 32GB cloud instance then tried the following:

node --max-old-space-size=40000 ./node_modules/.bin/stryker run --fileLogLevel trace --logLevel debug

I am now getting errors from the initial test run like this:

FAIL tests_integration/__tests__/file-info.js

  ● Test suite failed to run

    Jest encountered an unexpected token

    This usually means that you are trying to import a file which Jest cannot parse, e.g. it's not plain JavaScript.

    By default, if Jest sees a Babel config, it will use that to transform your files, ignoring "node_modules".

    Here's what you can do:
     • To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.
     • If you need a custom transformation specify a "transform" option in your config.
     • If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option.

    You'll find more details and examples of these config options in the docs:
    https://jestjs.io/docs/en/configuration.html

    Details:

    /home/brodybits/prettier/.stryker-tmp/sandbox2376464/src/language-js/utils.js:1981
            return __global_69fa48.__activeMutant__ === 17201 ? text.slice(start, __global_69fa48.__activeMutant__ === 17205 ? start - 2 : (__global_69fa48.__coverMutant__(17205), start + 2)) === (__global_69fa48.__activeMutant__ === 17206 ? "" : (__global_69fa48.__coverMutant__(17206), "")) : __global_69fa48.__activeMutant__ === 17200 ? false : __global_69fa48.__activeMutant__ === 17199 ? true : (__global_69fa48.__coverMutant__(17199, 17200, 17201), (__global_69fa48.__activeMutant__ === 17204 ? text.slice(start, __global_69fa48.__activeMutant__ === 17205 ? start - 2 : (__global_69fa48.__coverMutant__(17205), start + 2)) !== "")))));
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           ^

    SyntaxError: Unexpected token ')'

      14 |   shouldFlatten,
      15 |   getPrecedence,
    > 16 | } = require("./utils");
         |     ^
      17 | 
      18 | function needsParens(path, options) {
      19 |   const parent = path.getParentNode();

      at Runtime._execModule (../../node_modules/jest-runtime/build/index.js:1179:56)
      at Object.<anonymous> (src/language-js/needs-parens.js:16:5)

P.S. A step after the Instrumenter took a really long time (over 30 minutes), see this:

09:25:19 (2339) INFO Instrumenter Instrumented 115 source file(s) with 23085 mutant(s)
09:58:25 (2339) DEBUG TSConfigPreprocessor Rewriting file File {
  name: '/home/brodybits/prettier/tsconfig.json',
  _content: <Buffer 7b 0a 20 20 22 63 6f 6d 70 69 6c 65 72 4f 70 74 69 6f 6e 73 22 3a 20 7b 0a 20 20 20 20 22 61 6c 6c 6f 77 4a 73 22 3a 20 74 72 75 65 2c 0a 20 20 20 20 ... 1343 more bytes>,
  _textContent: '{\n' +
    '  "compilerOptions": {\n' +
    '    "allowJs": true,\n' +
    '    "checkJs": true,\n' +
    '    "noEmit": true,\n' +
    '    "target": "es2015",\n' +
    '    "module": "commonjs",\n' +
    '    "resolveJsonModule": true,\n' +
    '    // TBD it is desired to enabled strict type checking at some point:\n' +
    '    "strict": false\n' +
    '  },\n' +
    '  "exclude": [\n' +
    '    "coverage/",\n' +
    '    "test*.*",\n' +
    '    // [TBD] JavaScript sources *not* affected by src/language-*:\n' +
    '    "src/main/ast-to-doc.js",\n' +
    '    "src/main/core.js",\n' +
    '    "src/common/create-ignorer.js",\n' +
    '    "src/common/parser-create-error.js",\n' +
    '    "src/config/resolve-config.js",\n' +
    '    "src/main/options-normalizer.js",\n' +
    '    "src/common/get-file-info.js",\n' +
    '    "src/main/multiparser.js",\n' +
    '    "src/main/options.js",\n' +
    '    // [TBD] src/language-* source directory trees with known JSDoc type issues:\n' +
    '    "src/language-html",\n' +
    '    "src/language-js",\n' +
    '    // [TBD] JavaScript sources affected by JSDoc issues in src/language-*:\n' +
    '    "src/common/load-plugins.js",\n' +
    '    "src/cli/index.js",\n' +
    '    "src/cli/expand-patterns.js",\n' +
    '    "src/cli/util.js",\n' +
    '    "src/cli/constant.js",\n' +
    '    "src/cli/prettier-internal.js",\n' +
    '    "src/languages.js",\n' +
    '    // [TBD] top-level JavaScript sources affected by JSDoc issues\n' +
    '    // in other sources:\n' +
    '    "src/index.js",\n' +
    '    "src/standalone.js",\n' +
    '    "index.js",\n' +
    '    "standalone.js",\n' +
    '    "bin/",\n' +
    '    "dist/",\n' +
    '    "docs/",\n' +
    '    "scripts/",\n' +
    '    "tests/",\n' +
    '    "tests_config/",\n' +
    '    "tests_integration/",\n' +
    '    "website/"\n' +
    '  ]\n' +
    '}\n'
}

@brodycj
Copy link
Owner Author

brodycj commented Aug 20, 2020

I replaced stryker.conf.json with stryker.conf.js which seems to be a little more flexible, at least for adding comments, and cleaned up the mutate list. Results seem to still be the same with Stryker 4.0.0-beta.3. I generally use the following command to run Stryker with the extra logging and memory space needed:

node --max-old-space-size=800000 node_modules/.bin/stryker run --fileLogLevel trace --logLevel debug

I will probably rebase the commits to clean out old commits no longer needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant