Open trungtruong1 opened 1 month ago
Passed all tests. Yay.
https://pygments.org/docs/lexerdevelopment/#how-to-test-your-lexer this is link the repo owner gave us. Everyone should read it.
Guys, I updated the build.yml
file to run CI for every new commit push.
The original build.yml
requires you to push to the master branch to run CI (or run for pull requests)
It seems that our fix also affects some C/Cpp based language (see pygments/lexers/c_like.py) and we will have to update the outputs of these lexers as part of the PR. But before adding them to the PR, we need to check whether these outputs are correct or not. An ideal process that I would suggest is: --update-goldens everything in tests folder -> use git to identify changed output files -> if the output file is not from a c/cpp based lexer, undo the change and consider it a failed test case. If it is -> check these output files whether they are lexed correctly. If not, undo the change and consider it a failed test case.
Hello, everyone. I found a problem that our previous fixing change something from Keyword/Type/Name into Name.Function, which is not correct. Shown below:
tests/examplefiles/cpp/functions.cpp tests/examplefiles/cpp/functions.cpp.output , these files are for checking this problem
And more:
Here, we shouldn't combine AnsiGenerator:: together
Same changes happend in: tests/examplefiles/mql/example.mqh.output
Should it keep the same as before?
getNextProgramCharDistance in example.cpp. Should it be a Name.Function?
tests/examplefiles/nesc/IPDispatchP.nc
Here, one ":" should be seen as Punctuation rather than Operator
tests/examplefiles/promela/sample.pml, who knows promela's syntax
tests/examplefiles/swig/swig_java.swg.output is full of these problems like above mentioned:
It seems that our fix also affects some C/Cpp based language (see pygments/lexers/c_like.py) and we will have to update the outputs of these lexers as part of the PR. But before adding them to the PR, we need to check whether these outputs are correct or not. An ideal process that I would suggest is: --update-goldens everything in tests folder -> use git to identify changed output files -> if the output file is not from a c/cpp based lexer, undo the change and consider it a failed test case. If it is -> check these output files whether they are lexed correctly. If not, undo the change and consider it a failed test case.
The author has explained us a method to run test for only the lexer we have modified. I believe we should be doing that.
But if we do that, it will fail CI. For example, our C++ lexer will create an output for tests/examplefiles/swig/swig_java.swg
. This output will be compared with tests/examplefiles/swig/swig_java.swg.output
and will return fail. tests/examplefiles/swig/swig_java.swg
is using the C++ lexer.
The author has explained us a method to run test for only the lexer we have modified. I believe we should be doing that.
I think lexer in "working on a lexer" means new lexer, not the one we are modifying. Instead, this is what we should follow:
Isn't it the same are running tests for individual code files? Or is filename.txt a random file in the root directory? I'll check.
Hello, everyone. I found a problem that our previous fixing change something from Keyword/Type/Name into Name.Function, which is not correct. Shown below:
tests/examplefiles/cpp/functions.cpp tests/examplefiles/cpp/functions.cpp.output , these files are for checking this problem
And more:
Let's try doing this commit: https://github.com/ZuxingGit/pygments/commit/e8c3be799c580eabf2a332c3e3cfc1e342bf2444 in a different manner. Instead of including functions on CFamilyLexers, we should be placing it in CPPLexer and CLexer.
Isn't it the same are running tests for individual code files? Or is filename.txt a random file in the root directory? I'll check.
filename.txt is file we need to add in which we put sample CPP/C code
Isn't it the same are running tests for individual code files? Or is filename.txt a random file in the root directory? I'll check.
filename.txt is file we need to add in which we put sample CPP/C code
No no, that I know, what I was wanting to know was if this file is in the root directory or we have to supply the command with a path to that file.
No no, that I know, what I was wanting to know was if this file is in the root directory or we have to supply the command with a path to that file.
Follow its tutorial, I put it under: tests/snippets/cpp/1729.txt
if it's a big file, we need to put it under: tests/examplefiles/cpp
but if run: tox -- --update-goldens
in root dir, it will update all test files
1. If i change code like this:
Now int type is not recognized:
2. If i put type above it:
now some normal functions are not recognized:
all above bugs are fixed, and I informed the repo owner. Pull Request
Link to the issue: #1729