Skip to content
New issue

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

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

Already on GitHub? # to your account

DEBUG=1 yarn test does not work anymore #559

Closed
fflorent opened this issue Jul 6, 2023 · 2 comments
Closed

DEBUG=1 yarn test does not work anymore #559

fflorent opened this issue Jul 6, 2023 · 2 comments
Labels

Comments

@fflorent
Copy link
Collaborator

fflorent commented Jul 6, 2023

If you try to run this command:

$ DEBUG=1 yarn test 

You get this error:

TypeError: arg.split is not a function
    at /home/florentpro/projects/grist-core/node_modules/mocha/lib/cli/options.js:113:24
    at Array.reduce (<anonymous>)
    at parse (/home/florentpro/projects/grist-core/node_modules/mocha/lib/cli/options.js:111:67)
    at loadOptions (/home/florentpro/projects/grist-core/node_modules/mocha/lib/cli/options.js:246:10)
    at Object.<anonymous> (/home/florentpro/projects/grist-core/node_modules/mocha/bin/mocha.js:27:14)
    at Module._compile (node:internal/modules/cjs/loader:1254:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1308:10)
    at Module.load (node:internal/modules/cjs/loader:1117:32)
    at Module._load (node:internal/modules/cjs/loader:958:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)

The bisection points to this commit: bcbf57d

And it sounds like it relates to this bug: mochajs/mocha#3861 (TL;DR : process.argv should be a string).

It took me a while to understand that changing DEBUG=1 to DEBUG=whatever does the trick. It sounds like the DEBUG var is passed as some argument to mocha.

What do you think of renaming the DEBUG variable used to run the tests to something different to avoid the confusion? I can work on this

@dsagal
Copy link
Member

dsagal commented Jul 6, 2023

I don't think the issue is with the name of the variable, I think it's a bash difficulty. I see this bit in the command for test (and for another variant): ${DEBUG:---forbid-only}. The intent is that when DEBUG is unset, it should include --forbid-only in the command-line; if set, it should omit it. The problem is that it's wrong: when DEBUG is set, this expression includes its value. Why exactly the 1 leads to the error you see is a separate question (I am not seeing the same one), but the point is that the 1 should not be included in the command line at all.

I think the following may work correctly in place of the bit above: $([[ -z $DEBUG ]] && echo --forbid-only). Would you like to check if this solves the issue?

fflorent pushed a commit to incubateur-territoires/grist-core that referenced this issue Jul 7, 2023
fflorent pushed a commit to incubateur-territoires/grist-core that referenced this issue Jul 7, 2023
@fflorent
Copy link
Collaborator Author

fflorent commented Jul 7, 2023

You're right, I just opened a PR with the fix. Thanks @dsagal!

dsagal pushed a commit that referenced this issue Jul 7, 2023
Co-authored-by: Florent FAYOLLE <florent.fayolle@beta.gouv.fr>
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
Archived in project
Development

No branches or pull requests

2 participants