Skip to content

Commit

Permalink
feat: optimize report name
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoweii committed Jan 9, 2024
1 parent 2c1e338 commit 71da69a
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions integrationtest/devicefarm/automate_device_farm.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import yaml
import zipfile
import shutil
import re

# The following script runs a test through Device Farm
client = boto3.client('devicefarm')
Expand Down Expand Up @@ -156,9 +157,16 @@ def unzip_and_copy(zip_path):
with zipfile.ZipFile(zip_path, 'r') as zip_ref:
zip_ref.extractall(os.path.dirname(zip_path))
origin_path = os.path.dirname(zip_path) + "/Host_Machine_Files/$DEVICEFARM_LOG_DIR/junitreport.xml"
rename_path = os.path.dirname(origin_path) + "/" + os.path.basename(
os.path.dirname(zip_path)) + " appium junitreport.xml"
device_name = os.path.basename(os.path.dirname(zip_path))
rename_path = os.path.dirname(origin_path) + "/" + device_name + " appium junitreport.xml"
os.rename(origin_path, rename_path)
report_path = os.path.dirname(os.path.dirname(os.path.dirname(zip_path))) + "/report/"
os.makedirs(report_path, exist_ok=True)
shutil.copy(rename_path, report_path)
result_path = shutil.copy(rename_path, report_path)

# rename test name
with open(result_path, 'r', encoding='utf-8') as file:
content = file.read()
modified_content = re.sub(r'\bTestShopping\b', "AppiumTest " + device_name, content)
with open(result_path, 'w', encoding='utf-8') as file:
file.write(modified_content)

0 comments on commit 71da69a

Please sign in to comment.