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

console output helper in Cakefile for test case selection and parser generation statistics #5473

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

cosmicexplorer
Copy link
Contributor

@cosmicexplorer cosmicexplorer commented Nov 15, 2024

This PR purely modifies the Cakefile in this repo and should not affect any users of the language.

Problem

I was playing around with changes to the parser and language semantics in e.g. #5471 (comment). During the process I found it somewhat difficult to test my changes:

  1. It's not possible to select a subset of tests to run with cake test.
  • Some of them fail on main for example--I'll fix that in a separate change, but it's why I wanted to select specific tests.
  1. It takes a while to build the parser, and it's not easy to distinguish from a hang.
  2. There's no mechanism to select what output should be logged when performing a console task with cake.

Solution

  • Add -f/--file, -d/--desc flags to select which tests to run.
  • Add -l/--level flag to select which console outputs to display.
    • This requires subclassing console.Console, which requires some hijinx.
  • Using the new log levels to make it ignorable, add some console output for the parser build process:
# By default, we still print nothing:
> cake build
# With 'debug', we print more, including parser build statistics.
> cake -l debug build
log level = debug
parser created (206 symbols, 107 terminals, 406 productions)
loading grammar: 11127.603219999999 ms
parser generation: 27.266960000000836 ms
full parser build time: 11154.87018 ms
{
  files: [
    'src/browser.coffee',
    'src/cake.coffee',
    'src/coffeescript.coffee',
    'src/command.coffee',
    'src/grammar.coffee',
    'src/helpers.coffee',
    'src/index.coffee',
    'src/lexer.coffee',
    'src/nodes.coffee',
    'src/optparse.coffee',
    'src/register.coffee',
    'src/repl.coffee',
    'src/rewriter.coffee',
    'src/scope.litcoffee',
    'src/sourcemap.litcoffee'
  ]
}

Notes

I have a jison branch which brings the parser build time down to <3 seconds (vs the ~12 seconds it takes now), which I will probably try to merge into upstream jison first if that sounds reasonable. Until then, I should be able to use my local jison along with these changes to more quickly iterate on changes to the language.

@cosmicexplorer
Copy link
Contributor Author

Proposed a small and focused fix to jison at zaach/jison#408 which improves parser build time by 3x!

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