se2p / pynguin

The PYthoN General UnIt Test geNerator is a test-generation tool for Python
https://www.pynguin.eu
MIT License
1.24k stars 75 forks source link

pynguin takes long time even when specifying timeout options #46

Open exKAZUu opened 1 year ago

exKAZUu commented 1 year ago

Describe the bug When pynguin generates test cases for a program that may occur an infinite loop, pynguin takes long time (even when specifying timeout options).

To Reproduce

  1. Create loop.py with the following content:
    def func(n: int):
    while n == 0:
        pass
    return n
  2. Run pynguin with the following command: PYNGUIN_DANGER_AWARE=1 pynguin --project-path . --output-path output --module-name loop --maximum-search-time 1 --maximum-slicing-time 1 --maximum-test-execution-timeout 1 --maximum-test-execution-timeout 1 --test-execution-time-per-statement 1 --max-size 1 --max-length-test-case 1 --max-int 10 --assertion_generation SIMPLE --algorithm MOSA
  3. pynguin takes about 30 seconds

Expected behavior I can imagine there are various mandatory processes where it is difficult to limit execution times, but, I'd like pynguin stop until 5 seconds when specifying the above options.

Screenshots

image

Software Version:

stephanlukasczyk commented 1 year ago

Dear @exKAZUu ,

Thank you for your interest in Pynguin and reporting this bug. I agree that this is definitely a bug and a behaviour that should be fixed. The problem seems to be in the execution, where one of the generated inputs triggers an infinite loop. The thread used for execution is then killed, which causes the RuntimeError.

Unfortunately, I am very busy with other things, thus I cannot promise when I can work on a fix for this. I'll keep this bug open and refer to it whenever I find the time.