Skip to content

Commit

Permalink
Merge pull request #3329 from csordasmarton/test_ignore_rmtree_error
Browse files Browse the repository at this point in the history
[test] Ignore errors when removing directories
  • Loading branch information
bruntib authored May 20, 2021
2 parents 176987e + 89e2d70 commit a9cde94
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
10 changes: 5 additions & 5 deletions web/tests/functional/diff_local_remote/test_diff_local_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ def test_diff_gerrit_output(self):
self.assertIn("end_line", range)
self.assertIn("end_character", range)

shutil.rmtree(export_dir)
shutil.rmtree(export_dir, ignore_errors=True)

def test_diff_gerrit_stdout(self):
"""Test gerrit stdout output.
Expand Down Expand Up @@ -446,7 +446,7 @@ def test_set_env_diff_gerrit_output(self):
reports = comments["divide_zero.cpp"]
self.assertEqual(len(reports), 4)

shutil.rmtree(export_dir)
shutil.rmtree(export_dir, ignore_errors=True)

def test_diff_codeclimate_output(self):
""" Test codeclimate output when using diff and set env vars. """
Expand Down Expand Up @@ -493,7 +493,7 @@ def test_diff_codeclimate_output(self):
}
}}])

shutil.rmtree(export_dir)
shutil.rmtree(export_dir, ignore_errors=True)

def test_diff_no_trim_codeclimate_output(self):
""" Test codeclimate output when using diff and don't set env vars. """
Expand All @@ -519,7 +519,7 @@ def test_diff_no_trim_codeclimate_output(self):
self.assertTrue(os.path.isabs(file_path))
self.assertTrue(file_path.endswith(f"/new_delete.cpp"))

shutil.rmtree(export_dir_path)
shutil.rmtree(export_dir_path, ignore_errors=True)

def test_diff_multiple_output(self):
""" Test multiple output type for diff command. """
Expand Down Expand Up @@ -549,7 +549,7 @@ def test_diff_multiple_output(self):
index_html = os.path.join(export_dir, 'index.html')
self.assertTrue(os.path.exists(index_html))

shutil.rmtree(export_dir)
shutil.rmtree(export_dir, ignore_errors=True)

def test_diff_remote_local_resolved_same(self):
""" Test for resolved reports on same list remotely and locally. """
Expand Down
4 changes: 2 additions & 2 deletions web/tests/functional/diff_remote/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,8 @@ def setup_package():
env.export_test_cfg(TEST_WORKSPACE, test_config)

# Remove report directories which are not used anymore.
shutil.rmtree(test_proj_path_base)
shutil.rmtree(test_proj_path_new)
shutil.rmtree(test_proj_path_base, ignore_errors=True)
shutil.rmtree(test_proj_path_new, ignore_errors=True)


def teardown_package():
Expand Down
2 changes: 1 addition & 1 deletion web/tests/functional/products/test_config_db_share.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,4 +232,4 @@ def tearDown(self):
EVENT.set()

print("Removing: " + self.test_workspace_secondary)
shutil.rmtree(self.test_workspace_secondary)
shutil.rmtree(self.test_workspace_secondary, ignore_errors=True)
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ def setUp(self):

# Remove analyzer statistics directory if it exists before store.
if os.path.exists(self._analyzer_stats_dir):
shutil.rmtree(self._analyzer_stats_dir)
shutil.rmtree(self._analyzer_stats_dir, ignore_errors=True)

# Remove reports directory if it exists and create an empty one.
if os.path.exists(self._reports_dir):
shutil.rmtree(self._reports_dir)
shutil.rmtree(self._reports_dir, ignore_errors=True)

# Setup a viewer client to test viewer API calls.
self._cc_client = env.setup_viewer_client(self.test_workspace)
Expand Down
2 changes: 1 addition & 1 deletion web/tests/functional/store/test_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,4 +180,4 @@ def store_multiple_report_dirs(report_dirs):
# Store report directories recursively.
store_multiple_report_dirs([common_report_dir])

shutil.rmtree(common_report_dir)
shutil.rmtree(common_report_dir, ignore_errors=True)
2 changes: 1 addition & 1 deletion web/tests/libtest/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ def get_workspace(test_id='test'):
def clean_wp(workspace):
if os.path.exists(workspace):
print("Removing workspace:" + workspace)
shutil.rmtree(workspace)
shutil.rmtree(workspace, ignore_errors=True)
os.makedirs(workspace)


Expand Down

0 comments on commit a9cde94

Please sign in to comment.