nlohmann / mutate_cpp

C++ Mutation Test Environment
MIT License
171 stars 22 forks source link

Division by zero error #29

Closed AlexisWilke closed 1 year ago

AlexisWilke commented 1 year ago

When I create a brand new project, setup one file, then go to the queue before generating the mutation patches, we end up with zero patches. At that point, if you try to go the queue, you get a division by zero error. Although it could be considered user error (I forgot to generate the patches), I still think that the queue page should not generate such an error. Just report that it is empty.

AlexisWilke commented 1 year ago

I've found the instance showing that error:

127.0.0.1 - - [12/Aug/2023 07:03:53] "GET /queue HTTP/1.1" 500 -
Traceback (most recent call last):
  File "/home/alexis/tools/mutate_cpp/venv/lib/python3.10/site-packages/flask/app.py", line 2091, in __call__
    return self.wsgi_app(environ, start_response)
  File "/home/alexis/tools/mutate_cpp/venv/lib/python3.10/site-packages/flask/app.py", line 2076, in wsgi_app
    response = self.handle_exception(e)
  File "/home/alexis/tools/mutate_cpp/venv/lib/python3.10/site-packages/flask/app.py", line 2073, in wsgi_app
    response = self.full_dispatch_request()
  File "/home/alexis/tools/mutate_cpp/venv/lib/python3.10/site-packages/flask/app.py", line 1518, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/home/alexis/tools/mutate_cpp/venv/lib/python3.10/site-packages/flask/app.py", line 1516, in full_dispatch_request
    rv = self.dispatch_request()
  File "/home/alexis/tools/mutate_cpp/venv/lib/python3.10/site-packages/flask/app.py", line 1502, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
  File "/home/alexis/tools/mutate_cpp/app/views.py", line 85, in route_v2_queue
    return render_template('v2_queue.html', patches=patches)
  File "/home/alexis/tools/mutate_cpp/venv/lib/python3.10/site-packages/flask/templating.py", line 147, in render_template
    return _render(
  File "/home/alexis/tools/mutate_cpp/venv/lib/python3.10/site-packages/flask/templating.py", line 128, in _render
    rv = template.render(context)
  File "/home/alexis/tools/mutate_cpp/venv/lib/python3.10/site-packages/jinja2/environment.py", line 1291, in render
    self.environment.handle_exception()
  File "/home/alexis/tools/mutate_cpp/venv/lib/python3.10/site-packages/jinja2/environment.py", line 925, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "/home/alexis/tools/mutate_cpp/app/templates/v2_queue.html", line 2, in top-level template code
    {% set title='Queue' %}
  File "/home/alexis/tools/mutate_cpp/app/templates/v2_base.html", line 175, in top-level template code
    {% block content %}{% endblock %}
  File "/home/alexis/tools/mutate_cpp/app/templates/v2_queue.html", line 34, in block 'content'
    {% set patch_finished_percentage = 100.0 * ((stats.patch.count._all_ - stats.patch.count.incomplete) / stats.patch.count._all_) %}
ZeroDivisionError: division by zero
AlexisWilke commented 1 year ago

I actually created PR #33

AlexisWilke commented 1 year ago

PR was accepted so we're done here. Thank you.