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

Fix webpack sourcemap tests #358

Merged
merged 7 commits into from
Mar 26, 2024

Conversation

hbenl
Copy link
Collaborator

@hbenl hbenl commented Mar 10, 2024

Most of the tests that verify sourcemap support for webpack bundles have been broken for a while, this PR fixes them.

@nchevobbe
Copy link
Member

So I ran npm run test src/test/testWebpackSourceMaps.ts and I'm still seeing errors:

145 passing (3m)
  8 pending
  6 failing

  1) Webpack sourcemaps: The debugger
       should map webpack-bundled modules with devtool "cheap-eval-source-map" to their original sources:
     ValidationError: Invalid configuration object. Webpack has been initialized using a configuration object that does not match the API schema.
 - configuration.devtool should match pattern "^(inline-|hidden-|eval-)?(nosources-)?(cheap-(module-)?)?source-map$".
   BREAKING CHANGE since webpack 5: The devtool option is more strict.
   Please strictly follow the order of the keywords in the pattern.
      at validate (node_modules/webpack/node_modules/schema-utils/dist/validate.js:191:11)
      at validateSchema (node_modules/webpack/lib/validateSchema.js:78:2)
      at create (node_modules/webpack/lib/webpack.js:119:24)
      at webpack (node_modules/webpack/lib/webpack.js:151:47)
      at f (node_modules/webpack/lib/index.js:72:16)
      at /Users/nchevobbe/Projects/vscode-firefox-debug/src/test/testWebpackSourceMaps.ts:85:10
      at new Promise (<anonymous>)
      at build (src/test/testWebpackSourceMaps.ts:84:9)
      at Context.<anonymous> (src/test/testWebpackSourceMaps.ts:46:10)
      at Generator.next (<anonymous>)
      at fulfilled (src/test/testWebpackSourceMaps.ts:28:58)

  2) Webpack sourcemaps: The debugger
       should map webpack-bundled modules with devtool "cheap-module-eval-source-map" to their original sources:
     ValidationError: Invalid configuration object. Webpack has been initialized using a configuration object that does not match the API schema.
 - configuration.devtool should match pattern "^(inline-|hidden-|eval-)?(nosources-)?(cheap-(module-)?)?source-map$".
   BREAKING CHANGE since webpack 5: The devtool option is more strict.
   Please strictly follow the order of the keywords in the pattern.
      at validate (node_modules/webpack/node_modules/schema-utils/dist/validate.js:191:11)
      at validateSchema (node_modules/webpack/lib/validateSchema.js:78:2)
      at create (node_modules/webpack/lib/webpack.js:119:24)
      at webpack (node_modules/webpack/lib/webpack.js:151:47)
      at f (node_modules/webpack/lib/index.js:72:16)
      at /Users/nchevobbe/Projects/vscode-firefox-debug/src/test/testWebpackSourceMaps.ts:85:10
      at new Promise (<anonymous>)
      at build (src/test/testWebpackSourceMaps.ts:84:9)
      at Context.<anonymous> (src/test/testWebpackSourceMaps.ts:46:10)
      at Generator.next (<anonymous>)
      at fulfilled (src/test/testWebpackSourceMaps.ts:28:58)

  3) Webpack sourcemaps: The debugger
       should map webpack-bundled modules with devtool "eval-source-map" to their original sources:

      AssertionError [ERR_ASSERTION]: Expected values to be strictly deep-equal:
+ actual - expected

+ []
- [
-   {
-     column: 1,
-     line: 7
-   },
-   {
-     column: 6,
-     line: 7
-   }
- ]
      + expected - actual

      -[]
      +[
      +  {
      +    "column": 1
      +    "line": 7
      +  }
      +  {
      +    "column": 6
      +    "line": 7
      +  }
      +]
      
      at Context.<anonymous> (src/test/testWebpackSourceMaps.ts:59:12)
      at Generator.next (<anonymous>)
      at fulfilled (src/test/testWebpackSourceMaps.ts:28:58)
      at processTicksAndRejections (node:internal/process/task_queues:95:5)

  4) The configuration parser
       should not allow "reAttach" to be false while "keepProfileChanges" is true on MacOS:
     Error: This configuration should have been rejected
      at Context.<anonymous> (src/test/testConfigurationParser.ts:328:9)
      at Generator.next (<anonymous>)
      at fulfilled (src/test/testConfigurationParser.ts:28:58)

  5) The configuration parser
       should copy "profileDir" to "profileDir" if "keepProfileChanges" is true:
     Error: the string "On MacOS, \"keepProfileChanges\" is only allowed with \"reAttach\" because your profile may get damaged otherwise" was thrown, throw an Error :)
  

  6) Data breakpoints: The debug adapter
       "after each" hook for "should add a data breakpoint and hit it":
     TypeError: Cannot read properties of undefined (reading 'stop')
      at Context.<anonymous> (src/test/testDataBreakpoints.ts:13:12)
      at Generator.next (<anonymous>)
      at /Users/nchevobbe/Projects/vscode-firefox-debug/src/test/testDataBreakpoints.ts:31:71
      at new Promise (<anonymous>)
      at __awaiter (src/test/testDataBreakpoints.ts:27:12)
      at Context.<anonymous> (src/test/testDataBreakpoints.ts:42:16)
      at processImmediate (node:internal/timers:478:21)

is this expected?

@nchevobbe
Copy link
Member

So I ran npm run test src/test/testWebpackSourceMaps.ts and I'm still seeing errors:
is this expected?

so I actually forgot to checkout the PR's branch, but now, I'm getting even more failure, so I'm questioning if I'm running them properly?

@hbenl
Copy link
Collaborator Author

hbenl commented Mar 18, 2024

So I ran npm run test src/test/testWebpackSourceMaps.ts and I'm still seeing errors:

That's not expected, some of the failures seem mac-specific, I'll have a look at them later.

now, I'm getting even more failure, so I'm questioning if I'm running them properly?

npm run test should work. Adding an argument to restrict which tests should run doesn't work though. I usually use a VS Code extension to run them: https://marketplace.visualstudio.com/items?itemName=hbenl.vscode-mocha-test-adapter
Also it sometimes happened to me that one of the Firefox processes started for the tests is not terminated and then all subsequent tests fail because the debugger port is blocked.

Edit: just saw your message that npm run test doesn't work. I'll fix that later.

@hbenl hbenl force-pushed the fix-webpack-tests branch from 0590917 to 9d33a4d Compare March 24, 2024 17:50
@hbenl
Copy link
Collaborator Author

hbenl commented Mar 24, 2024

I've fixed the tests on MacOS:

  • 2 configuration parser tests were broken by Fix #220 #224
  • the webpack sourcemap tests were broken because on MacOS os.tmpdir() returns a path containing a symlink, which confused webpack

I have also made some further updates to the test setup:

  • run the tests using tsx instead of ts-node (because it's faster)
  • consolidate the mocha configuration (ensuring that we get the same results on the command line and in the Test Explorer)
  • remove an old environment variable that was used for running the tests against Firefox <70
  • add an extension recommendation for the Mocha Test Explorer

To run the tests you may have to add FIREFOX_EXECUTABLE=stable to src/test/.env because the adapter doesn't work with the latest developer edition (see #360, I'll look into this soon)

@hbenl hbenl requested a review from nchevobbe March 24, 2024 17:59
@nchevobbe
Copy link
Member

The changes look good to me, but I must be doing something wrong, I get Could not establish connection. Receiving end does not exist, from receivePageLoadedEvent

@hbenl
Copy link
Collaborator Author

hbenl commented Mar 25, 2024

Hmm, I've never seen that error. Did you rebuild before trying to run the tests?
Also I noticed that on MacOS it seems to happen more often that the Firefox instance started for a test does not get terminated. Try commenting out HEADLESS=true in src/test/.env so that you can close these instances manually if necessary.

@nchevobbe
Copy link
Member

Hmm, I've never seen that error. Did you rebuild before trying to run the tests?

yes I did

Also I noticed that on MacOS it seems to happen more often that the Firefox instance started for a test does not get terminated. Try commenting out HEADLESS=true in src/test/.env so that you can close these instances manually if necessary.

indeed, I was able to see that yesterday, the instance are kept alive for some reason.
Let's go ahead with the patch since this works for you, and I'll try to figure out what's the issue with my setup

@nchevobbe nchevobbe merged commit 8d40e30 into firefox-devtools:master Mar 26, 2024
@hbenl hbenl deleted the fix-webpack-tests branch March 26, 2024 09:54
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.

None yet

2 participants