mc-imperial / dredd

Framework for evaluating C/C++ compiler testing tools
Apache License 2.0
11 stars 3 forks source link

query_mutant_info for largest mutant id crash with ValueError when no mutants are present #261

Closed JonathanFoo0523 closed 1 month ago

JonathanFoo0523 commented 1 month ago

When dredd is applied to a file where no mutations are possible, querying the mutation-info-file for the largest mutant ID results in an error. The following statement at line 326 in query_mutant_info.py:

print(max(list(mapping)))

fails with the error message ValueError: max() arg is an empty sequence.

Can we return something like -1 or just print a message to indicate that no mutants are present?

afd commented 1 month ago

Thanks for this report!

I think it makes more sense to return 0 to indicate that no mutants are present. That's what I have done in #269.

JonathanFoo0523 commented 1 month ago

Thanks for this report!

I think it makes more sense to return 0 to indicate that no mutants are present. That's what I have done in #269.

I thought that we start counting mutant id from 0, and that the script returns the largest mutant id instead of number of mutants.

JonathanFoo0523 commented 1 month ago

As an example, this should return 0:

int main() {
  printf("foo\n");
}

But this shouldn't:

int main() {}
afd commented 1 month ago

You're right - #271 opened to fix this; I think returning -1 is a reasonable solution.