ZuxingGit / pygments

Pygments is a generic syntax highlighter written in Python
http://pygments.org/
BSD 2-Clause "Simplified" License
0 stars 0 forks source link

#1729 - Testing #4

Open trungtruong1 opened 1 month ago

trungtruong1 commented 1 month ago

Link to the issue: #1729

IshaanVerma1130 commented 1 month ago

Passed all tests. Yay. image image image

ZuxingGit commented 1 month ago

https://pygments.org/docs/lexerdevelopment/#how-to-test-your-lexer this is link the repo owner gave us. Everyone should read it.

trungtruong1 commented 1 month ago

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)

adluu2k1 commented 3 weeks ago

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.

ZuxingGit commented 3 weeks ago

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:

image image image image

tests/examplefiles/cpp/functions.cpp tests/examplefiles/cpp/functions.cpp.output , these files are for checking this problem

And more:

image
ZuxingGit commented 3 weeks ago

Here, we shouldn't combine AnsiGenerator:: together

image

Same changes happend in: tests/examplefiles/mql/example.mqh.output

ZuxingGit commented 3 weeks ago

Should it keep the same as before?

image
ZuxingGit commented 3 weeks ago

getNextProgramCharDistance in example.cpp. Should it be a Name.Function?

Screen Shot 2024-06-10 at 12 50 23 pm image
ZuxingGit commented 3 weeks ago

tests/examplefiles/nesc/IPDispatchP.nc

image image
ZuxingGit commented 3 weeks ago
image

Here, one ":" should be seen as Punctuation rather than Operator

image
ZuxingGit commented 3 weeks ago

tests/examplefiles/promela/sample.pml, who knows promela's syntax

image image
ZuxingGit commented 3 weeks ago

tests/examplefiles/swig/swig_java.swg.output is full of these problems like above mentioned:

image
IshaanVerma1130 commented 3 weeks ago

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. image

trungtruong1 commented 3 weeks ago

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.

adluu2k1 commented 3 weeks ago

The author has explained us a method to run test for only the lexer we have modified. I believe we should be doing that. image

I think lexer in "working on a lexer" means new lexer, not the one we are modifying. Instead, this is what we should follow:

image
IshaanVerma1130 commented 3 weeks ago

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.

IshaanVerma1130 commented 3 weeks ago

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: image

image image image tests/examplefiles/cpp/functions.cpp tests/examplefiles/cpp/functions.cpp.output , these files are for checking this problem

And more: image

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.

ZuxingGit commented 3 weeks ago

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

IshaanVerma1130 commented 3 weeks ago

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.

ZuxingGit commented 3 weeks ago

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

adluu2k1 commented 3 weeks ago

image

This problem has been fixed in the latest commit in issuefix

ZuxingGit commented 3 weeks ago

How can make them both work?

1. If i change code like this:

image

Now int type is not recognized:

image

2. If i put type above it:

image

now some normal functions are not recognized:

image
ZuxingGit commented 3 weeks ago

all above bugs are fixed, and I informed the repo owner. Pull Request