Commit c00201c6 authored by Jérome Perrin's avatar Jérome Perrin

testing/testcase: only snapshot if requested

Once testnodes are updated and always set SLAPOS_TEST_LOG_DIRECTORY, we
no longer need to have a default case of creating a snapshot folder
automatically, which was causing difficulties when running tests locally
as we had to remove this folder manually between test executions.
parent c13ab2bd
Pipeline #9255 canceled with stage
in 0 seconds
...@@ -33,6 +33,7 @@ import re ...@@ -33,6 +33,7 @@ import re
import glob import glob
import logging import logging
import shutil import shutil
import warnings
from six.moves.urllib.parse import urlparse from six.moves.urllib.parse import urlparse
try: try:
...@@ -124,8 +125,6 @@ def makeModuleSetUpAndTestCaseClass( ...@@ -124,8 +125,6 @@ def makeModuleSetUpAndTestCaseClass(
'base directory ( {} ) is too deep, try setting ' 'base directory ( {} ) is too deep, try setting '
'SLAPOS_TEST_WORKING_DIR to a shallow enough directory'.format( 'SLAPOS_TEST_WORKING_DIR to a shallow enough directory'.format(
base_directory)) base_directory))
if not snapshot_directory:
snapshot_directory = os.path.join(base_directory, "snapshots")
cls = type( cls = type(
'SlapOSInstanceTestCase for {}'.format(software_url), 'SlapOSInstanceTestCase for {}'.format(software_url),
...@@ -600,6 +599,9 @@ class SlapOSInstanceTestCase(unittest.TestCase): ...@@ -600,6 +599,9 @@ class SlapOSInstanceTestCase(unittest.TestCase):
The path are made relative to slapos root directory and The path are made relative to slapos root directory and
we keep the same directory structure. we keep the same directory structure.
""" """
if not cls._test_file_snapshot_directory:
warnings.warn("No snapshot directory configured, skipping snapshot")
return
# we cannot use os.path.commonpath on python2, so implement something similar # we cannot use os.path.commonpath on python2, so implement something similar
common_path = os.path.commonprefix((source_file_name, cls._base_directory)) common_path = os.path.commonprefix((source_file_name, cls._base_directory))
if not os.path.isdir(common_path): if not os.path.isdir(common_path):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment