mirror of
https://git.launchpad.net/~ubuntu-release/britney/+git/britney2-ubuntu
synced 2025-03-12 11:51:09 +00:00
Merge branch 'feat/cloud-policy/handle-test-errors' of git+ssh://git.launchpad.net/~aleksa-svitlica/cloudware/+git/britney2-ubuntu into sil2100/security-britney
This commit is contained in:
commit
a1c4b0a78b
@ -1,6 +1,5 @@
|
|||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
from pathlib import PurePath
|
|
||||||
import re
|
import re
|
||||||
import shutil
|
import shutil
|
||||||
import smtplib
|
import smtplib
|
||||||
@ -288,7 +287,7 @@ class CloudPolicy(BasePolicy):
|
|||||||
|
|
||||||
result = None
|
result = None
|
||||||
try:
|
try:
|
||||||
with open(PurePath(self.work_dir, self.TEST_LOG_FILE), "w") as file:
|
with open(os.path.join(self.work_dir, self.TEST_LOG_FILE), "w") as file:
|
||||||
result = subprocess.run(
|
result = subprocess.run(
|
||||||
params,
|
params,
|
||||||
cwd=self.work_dir,
|
cwd=self.work_dir,
|
||||||
@ -328,7 +327,7 @@ class CloudPolicy(BasePolicy):
|
|||||||
file_paths = []
|
file_paths = []
|
||||||
for file in os.listdir(self.work_dir):
|
for file in os.listdir(self.work_dir):
|
||||||
if re.fullmatch(file_regex, file):
|
if re.fullmatch(file_regex, file):
|
||||||
file_paths.append(PurePath(self.work_dir, file))
|
file_paths.append(os.path.join(self.work_dir, file))
|
||||||
|
|
||||||
return file_paths
|
return file_paths
|
||||||
|
|
||||||
@ -428,7 +427,7 @@ class CloudPolicy(BasePolicy):
|
|||||||
:param package The name of the package to test
|
:param package The name of the package to test
|
||||||
"""
|
"""
|
||||||
possible_locations = []
|
possible_locations = []
|
||||||
with open(PurePath(self.work_dir, self.TEST_LOG_FILE), "r") as file:
|
with open(os.path.join(self.work_dir, self.TEST_LOG_FILE), "r") as file:
|
||||||
for line in file:
|
for line in file:
|
||||||
if package not in line:
|
if package not in line:
|
||||||
continue
|
continue
|
||||||
|
@ -8,7 +8,6 @@
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import json
|
import json
|
||||||
import pathlib
|
|
||||||
import sys
|
import sys
|
||||||
from types import SimpleNamespace
|
from types import SimpleNamespace
|
||||||
import unittest
|
import unittest
|
||||||
@ -181,8 +180,8 @@ class T(unittest.TestCase):
|
|||||||
|
|
||||||
def test_finding_results_file(self):
|
def test_finding_results_file(self):
|
||||||
"""Ensure result file output from Cloud Test Framework can be found"""
|
"""Ensure result file output from Cloud Test Framework can be found"""
|
||||||
path = pathlib.PurePath(self.policy.work_dir, "TEST-FakeTests-20230101010101.xml")
|
path = os.path.join(self.policy.work_dir, "TEST-FakeTests-20230101010101.xml")
|
||||||
path2 = pathlib.PurePath(self.policy.work_dir, "Test-OtherTests-20230101010101.xml")
|
path2 = os.path.join(self.policy.work_dir, "Test-OtherTests-20230101010101.xml")
|
||||||
with open(path, "a"): pass
|
with open(path, "a"): pass
|
||||||
with open(path2, "a"): pass
|
with open(path2, "a"): pass
|
||||||
|
|
||||||
@ -329,14 +328,14 @@ class T(unittest.TestCase):
|
|||||||
"""
|
"""
|
||||||
package = "tmux"
|
package = "tmux"
|
||||||
|
|
||||||
with open(pathlib.PurePath(self.policy.work_dir, self.policy.TEST_LOG_FILE), "w") as file:
|
with open(os.path.join(self.policy.work_dir, self.policy.TEST_LOG_FILE), "w") as file:
|
||||||
file.write("Get: something \n".format(package))
|
file.write("Get: something \n".format(package))
|
||||||
file.write("Get: lib-{} \n".format(package))
|
file.write("Get: lib-{} \n".format(package))
|
||||||
|
|
||||||
install_source = self.policy._retrieve_package_install_source_from_test_output(package)
|
install_source = self.policy._retrieve_package_install_source_from_test_output(package)
|
||||||
self.assertIsNone(install_source)
|
self.assertIsNone(install_source)
|
||||||
|
|
||||||
with open(pathlib.PurePath(self.policy.work_dir, self.policy.TEST_LOG_FILE), "a") as file:
|
with open(os.path.join(self.policy.work_dir, self.policy.TEST_LOG_FILE), "a") as file:
|
||||||
file.write("Get: {} \n".format(package))
|
file.write("Get: {} \n".format(package))
|
||||||
|
|
||||||
install_source = self.policy._retrieve_package_install_source_from_test_output(package)
|
install_source = self.policy._retrieve_package_install_source_from_test_output(package)
|
||||||
@ -368,7 +367,7 @@ class T(unittest.TestCase):
|
|||||||
Returns the path to the created file.
|
Returns the path to the created file.
|
||||||
"""
|
"""
|
||||||
os.makedirs(self.policy.work_dir, exist_ok=True)
|
os.makedirs(self.policy.work_dir, exist_ok=True)
|
||||||
path = pathlib.PurePath(self.policy.work_dir, "TEST-FakeTests-20230101010101.xml")
|
path = os.path.join(self.policy.work_dir, "TEST-FakeTests-20230101010101.xml")
|
||||||
|
|
||||||
root = ET.Element("testsuite", attrib={"name": "FakeTests-1234567890"})
|
root = ET.Element("testsuite", attrib={"name": "FakeTests-1234567890"})
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user