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

Re-write test generator with templates and unit tests #663

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mk-mxp
Copy link
Contributor

@mk-mxp mk-mxp commented Mar 25, 2024

I decided to re-write the test generator based on template files instead of nikic/php-parser. It had too many limitations. And I didn't want to dig into another huge PHP generation library. Producing the code is not the main problem here.

While learning about the data structure behind the canonical data, I understood that the basic problem is not writing the PHP code but interpreting the data. Based on that idea, showing everything unknown to the user of the generator is key to informed usage.

So I developed a tree of data structures for the known data using TDD. Rendering these structures using templates simplified the process of dumping the code to the file. I documented all that in contribution/documentation/generator.

It now works for all remaining practice exercises, but does not produce the students file, yet.

What do you think about this approach, @homersimpsons @tomasnorre ?

@mk-mxp mk-mxp mentioned this pull request Mar 25, 2024
19 tasks
@mk-mxp mk-mxp self-assigned this Mar 25, 2024
@homersimpsons
Copy link
Contributor

I won't get time to review this before this weekend (31st March).

I know nothing about plantuml files though.

I really think it would be more test-able using twig templating and flysystem memory storage for tests.

@mk-mxp
Copy link
Contributor Author

mk-mxp commented Mar 25, 2024

@homersimpsons Don't worry about PlantUML, it is only some Code-To-Diagram application I know. The SVGs in the documentation are made from those files, there is nothing more to it.

I chose plain text files for templates and PHP sprintf() to fill in stuff. It's very basic.

@homersimpsons
Copy link
Contributor

@homersimpsons Don't worry about PlantUML, it is only some Code-To-Diagram application I know. The SVGs in the documentation are made from those files, there is nothing more to it.

Wouldn't mermaid diagram works?

I chose plain text files for templates and PHP sprintf() to fill in stuff. It's very basic.

Okay, but we may be limited to use some loops or conditions.

@mk-mxp mk-mxp added x:action/improve Improve existing functionality/content x:knowledge/intermediate Quite a bit of Exercism knowledge required x:module/generator Work on Exercise generators x:type/coding Write code that is not student-facing content (e.g. test-runners, generators, but not exercises) x:size/large Large amount of work x:rep/large Large amount of reputation labels Mar 25, 2024
@tomasnorre
Copy link
Contributor

I'll not find time to read this before after Easter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
x:action/improve Improve existing functionality/content x:knowledge/intermediate Quite a bit of Exercism knowledge required x:module/generator Work on Exercise generators x:rep/large Large amount of reputation x:size/large Large amount of work x:type/coding Write code that is not student-facing content (e.g. test-runners, generators, but not exercises)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants