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

AssertionError if initial run is not interesting #36

Open
Technius opened this issue Aug 18, 2023 · 1 comment
Open

AssertionError if initial run is not interesting #36

Technius opened this issue Aug 18, 2023 · 1 comment

Comments

@Technius
Copy link

Technius commented Aug 18, 2023

When I try to run picire with an uninteresting initial run, it crashes with an assertion failure:

Initial test contains 4 lines
Iteration #0
Run #0
	Config size: 4
Traceback (most recent call last):
  File "REDACTED/picire/.venv/bin/picire", line 8, in <module>
    sys.exit(execute())
  File "REDACTED/picire/picire/cli.py", line 286, in execute
    out_src = reduce(args.src,
  File "REDACTED/picire/picire/cli.py", line 249, in reduce
    min_set = dd(list(range(len(src))))
  File "REDACTED/picire/picire/dd.py", line 63, in __call__
    assert self._test_config(config, (f'r{run}', 'assert')) is Outcome.FAIL
AssertionError

I expected picire to exit and state that the initial run is uninteresting.

Steps to reproduce

Here is the example I used:

(.venv) picire % cat foo.txt
a
b
c
d
(.venv) picire % cat dumb_tester.sh
#!/usr/bin/env bash

exit 1
(.venv) picire % picire -i foo.txt --test ./dumb_tester.sh

I'm using commit 63668bb0409f4078ff84564065d161661bd388ae

Misc

I'm currently using the following patch as a workaround:

diff --git a/picire/dd.py b/picire/dd.py
index 888679d..ffeef28 100644
--- a/picire/dd.py
+++ b/picire/dd.py
@@ -60,7 +60,12 @@ class DD(object):
             for run in itertools.count():
                 logger.info('Run #%d', run)
                 logger.info('\tConfig size: %d', len(config))
-                assert self._test_config(config, (f'r{run}', 'assert')) is Outcome.FAIL
+                outcome = self._test_config(config, (f'r{run}', 'assert'))
+                if run == 0 and outcome is Outcome.PASS:
+                    # Initial run is not interesting, so we can't expect any
+                    # reductions or subsets to be interesting either.
+                    break
+                assert outcome is Outcome.FAIL

                 # Minimization ends if the configuration is already reduced to a single unit.
                 if len(config) < 2:

but it cannot distinguish between an uninteresting initial run and an interesting run that requires all inputs.

P.S. This tool is great! It's saved me a lot of debugging time.

EDIT: updated the patch

@renatahodovan
Copy link
Owner

Hi @Technius !

I'm glad to hear the you use and like picire! :)

The assert you hit is a sanity check at the beginning of every run to see if the config aimed to be reduced (still) reproduces the expected behaviour. If it doesn't, then there is no point to continue. This assert usually fires if the original input doesn't repro or if the input is flaky test case.

If picire is integrated in some framework and the assertion failure breaks the workflow, then I suggest to validate the input and the tester to see if they reproduce the expected behaviour and run picire afterwards only. Or, if you would like to run picire anyhow, simply disable the asserts with PYTHONOPTIMIZE=1.

@Technius Technius changed the title AssertionFailure if initial run is not interesting AssertionError if initial run is not interesting Aug 18, 2023
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

No branches or pull requests

2 participants