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

Automatically computing the regex for indeterministic properties #323

Merged
merged 9 commits into from
Feb 27, 2024

Conversation

tylergu
Copy link
Member

@tylergu tylergu commented Feb 18, 2024

Automate the process of figuring out the regex for the indeterministic properties. The algorithm is slightly complex:

Iterate on the original trials, in principle they should be the same
If they are not, the diffs should be the indeterministic fields
to be skipped when doing the comparison.
Naively, we can just append all the indeterministic fields and return
them, however, there are cases where the field path itself is not
deterministic (e.g. the name of the secret could be randomly generated)
To handle this randomness in the name, we can use the first two
original trials to compare the system state to get the initial
regex for skipping.
If we do not have random names, the subsequent trials should not
have additional indeterministic fields.

Then, we keep iterating on the rest of the original results, and
check if we have additional indeterministic fields. If we do, we
collect them and try to figure out the proper regex to skip them.

To come up with minimum regex for the paths with indeterministic names,
(e.g. root['secret']['my-secret-vczvds']),
without having an overly-general regex, we take the following approach:

  1. First sort the indeterministic paths
  2. Iterate over the sorted list:
    2.1 If we currently don't have a proposed regex, or the current proposed regex does not match the current path, then try to propose a new regex. First generate a tentative regex by looking ahead the next item, and use difflib to get the matched substrings. Then use this tentative regex to check with the next next item to see if it matches. If matched, then we have a proposed regex, if not, then we give up and use the absolute path to be skipped.
    2.2 If we already have a regex and the current path matches with it, we just continue

@tylergu tylergu changed the title Automate figuring out the indeterministic properties regex Automatically computing the regex for indeterministic properties Feb 18, 2024
Copy link
Contributor

github-actions bot commented Feb 18, 2024

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  acto
  reproduce.py 3, 17-18, 25-26, 87, 111-172
  acto/input
  input.py
  acto/post_process
  post_diff_test.py 556-557, 592, 683, 710-712, 725-742, 954-975, 984-996, 1010-1011
  post_diff_test_test.py 105
  post_process.py
  acto/schema
  boolean.py
  object.py
Project Total  

This report was generated by python-coverage-comment-action

@tylergu tylergu force-pushed the diff-skip--regex-automation branch from fc8ee09 to 296970e Compare February 22, 2024 22:14
@tylergu tylergu force-pushed the diff-skip--regex-automation branch 6 times, most recently from 3dd3546 to 277858f Compare February 27, 2024 19:27
@tylergu tylergu force-pushed the diff-skip--regex-automation branch from 277858f to cf8ab94 Compare February 27, 2024 19:49
@tylergu tylergu merged commit 3074b98 into main Feb 27, 2024
3 of 4 checks passed
@tylergu tylergu deleted the diff-skip--regex-automation branch February 29, 2024 22:45
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