AstuteSource / chasten

:dizzy: Chasten Uses XML and XPATH to Check a Python Program's AST for Specified Patterns!
https://pypi.org/project/chasten/
GNU General Public License v2.0
7 stars 8 forks source link

Implement All XPath Patterns Described in the Referenced Journal Paper #6

Open gkapfham opened 1 year ago

gkapfham commented 1 year ago

The following paper:

https://www.researchgate.net/publication/347335615_How_to_kill_them_all_An_exploratory_study_on_the_impact_of_code_observability_on_mutation_testing

describes a number of "mutation score anti-patterns" that limit the achievement of a high mutation score for a test suite.

This project should come with XPath expressions that can scan a Python project for all of the anti-patterns mentioned in this paper. The project should also:

MilesF25 commented 1 year ago

So far I think I have found a few of the xpath patterns in the journal, but I have some questions on which xpath pattern we want to use. this is an xpath for a double nested for loop in a function. : //FunctionDef//For[.//For] this is just for a double nested for loop: //For[.//For] and this is for a for loop that is nested directly underneath a for loop: //For/For which one's should we use?

MilesF25 commented 1 year ago

Things TODO

-Find examples, to test our xpaths expressions on. -Have Kapfhammer make a public repo that has projects -Add our programs to repos for testing -Add comment to functions to let user know what pattern should match -Catch everyone one up on our progress -We Need a macOS user to test the xpaths -try to add xpaths for the things in https://github.com/simonw/symbex

MilesF25 commented 1 year ago

I have finished finding most of the patterns from the pdf, but they need testing. Chatgpt sometimes gives me two different answers.

MilesF25 commented 1 year ago

More descriptive TODO -We need to test our XPATHS on small python samples.(This could be a small function that iterates through a word)

VitalJoseph commented 1 year ago

@MilesF25 hey miles can you send the command to access the xml document of subject data?

MilesF25 commented 1 year ago

@VitalJoseph it's pyastdump filename

VitalJoseph commented 1 year ago

@MilesF25 thanks

MilesF25 commented 1 year ago

We don't need to add count to the XPATH patterns, Chasten already does the counting. We also don't need the function name for now. So instead of doing count(//FunctionDef[@name='my_function']//If/descendant::If). You can do something like this instead //FunctionDef//If/descendant::If). (This is not a proper XPATH)

MilesF25 commented 1 year ago

I was able to get one XPATH pattern to work. '//FunctionDef//If/following-sibling::If'. This looks for nested if statements.

boulais01 commented 12 months ago

@VitalJoseph @Finley8 @MilesF25 Was this completed in a merged PR?

simojo commented 12 months ago

@VitalJoseph @MilesF25 just confirmed that work is actively happening on this issue, but in a Google doc rather than in a branch. The plan is to get this documented on our GitHub wiki by 2023-11-05. If this is not done in time, we will set this issue to the side.

MilesF25 commented 12 months ago

Google doc to hopefully working xpaths. https://docs.google.com/document/d/12OVwJkJBG0KB90UbGjfpXwtau2iXV_cV_7-KlGkPfKo/edit

VitalJoseph commented 11 months ago

@MilesF25 here is the xpath pattern for the (assertion_density) check that i have tried. Im having trouble with this one if ypu want to take a look at it.

"count(//FunctionDef[@type='str']/body/Asserts) idiv count(//FunctionDef[@type='str']/body/*)"
VitalJoseph commented 11 months ago

Also having trouble with the (direct_test_no) check. Here is the pattern I used.

//FunctionDef[@type='str' and starts-with(@name, 'test_')]/body//Call/Name[@id='test_function']
Finley8 commented 11 months ago

@VitalJoseph The following are some solutions that do not immediately break the program when run.

- name: "assertion-density" code: "ASD" id: "ASD001" pattern: "/testSuite/directTest[assertions div linesOfCode > 0.2]" count: min: null max: null

- name: "direct-test-no" code: "DTN" id: "DTN001" pattern: "//FunctionDef[@type='str' and starts-with(@name, 'test_')]/body//Call/Name[@id='test_function']" count: min: null max: null

Finley8 commented 11 months ago

123

simojo commented 11 months ago

@VitalJoseph does PR #125 close this issue? @gkapfham was asking if it implements all of the checks.

VitalJoseph commented 11 months ago

@simojo yes