Skip to content
Snippets Groups Projects
Unverified Commit be518cde authored by Johannes Linke's avatar Johannes Linke Committed by GitHub
Browse files

Make typescript commands fail properly on test failures (#1709)

parent df4cfea6
No related branches found
No related tags found
No related merge requests found
import argparse import argparse
import os import os
import subprocess # nosec import subprocess # nosec
import sys
import unittest import unittest
from django.conf import settings from django.conf import settings
from django.core.management import call_command from django.core.management import call_command
from django.core.management.base import BaseCommand from django.core.management.base import BaseCommand, CommandError
from django.test.runner import DiscoverRunner from django.test.runner import DiscoverRunner
...@@ -59,8 +58,8 @@ class Command(BaseCommand): ...@@ -59,8 +58,8 @@ class Command(BaseCommand):
print(f"Could not find {command[0]} command", file=self.stderr) print(f"Could not find {command[0]} command", file=self.stderr)
except KeyboardInterrupt: except KeyboardInterrupt:
pass pass
except subprocess.CalledProcessError as error: except subprocess.CalledProcessError as e:
sys.exit(error.returncode) raise CommandError("Error during command execution", returncode=e.returncode) from e
def compile(self, watch=False, fresh=False, **_options): def compile(self, watch=False, fresh=False, **_options):
static_directory = settings.STATICFILES_DIRS[0] static_directory = settings.STATICFILES_DIRS[0]
...@@ -93,4 +92,6 @@ class Command(BaseCommand): ...@@ -93,4 +92,6 @@ class Command(BaseCommand):
# Enable debug mode as otherwise a collectstatic beforehand would be necessary, # Enable debug mode as otherwise a collectstatic beforehand would be necessary,
# as missing static files would result into an error. # as missing static files would result into an error.
test_runner = RenderPagesRunner(debug_mode=True) test_runner = RenderPagesRunner(debug_mode=True)
test_runner.run_tests([]) failed_tests = test_runner.run_tests([])
if failed_tests > 0:
raise CommandError("Failures during render_pages")
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment