Skip to content

Commit

Permalink
Addressing comments
Browse files Browse the repository at this point in the history
  • Loading branch information
agosh01 committed Aug 14, 2024
1 parent 96f03d9 commit b54a0cf
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 30 deletions.
18 changes: 9 additions & 9 deletions scripts/install_dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,15 @@ def main():

os.chdir(os.pardir) # Move back to the root of the cloned repository directory structure

# Check if "python3-tk" is installed
result = subprocess.run(["dpkg", "-s", "python3-tk"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
if result.returncode == 0:
print("Python3-tk is already installed.")
else:
print("Python3-tk is not installed. Installing...")
print("Please enter your sudo password:")
run_command("sudo apt-get install python3-tk")

if sys.platform == "linux" or sys.platform == "linux2" or sys.platform == "darwin":
# Check if "python3-tk" is installed
result = subprocess.run(["dpkg", "-s", "python3-tk"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
if result.returncode == 0:
print("Python3-tk is already installed.")
else:
print("Python3-tk is not installed. Installing...")
print("Please enter your sudo password:")
run_command("sudo apt-get install python3-tk")

run_command(
"python install_cpp_test_agent.py "
Expand Down
4 changes: 4 additions & 0 deletions test_manager/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ With Behave, users can create files called "feature files," within which a test
For testing interoperability between different language test agents, users can create these feature files, specifying which languages are under test.
Specific step definitions for the test manager and test agents are located below.

==== Running BDD Example Test with GUI (Windows/Linux)
1. Go to the Test Manager Folder (cd test_manager)
2. Run "python user_interface.py".

==== Running BDD Example Test

Example scripts for TCK Interoperability are supplied under test_manager/features/tests.
Expand Down
63 changes: 42 additions & 21 deletions test_manager/UI.py → test_manager/user_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
from PIL import Image, ImageTk # Import PIL for image handling
from tkinterweb import HtmlFrame

# PATH Variables
image_path = os.path.join("..", "screenshots", "uprotocol_logo.png")
tests_main_dir = os.path.join("features", "tests")


def list_feature_files(directory):
feature_files = []
Expand Down Expand Up @@ -37,10 +41,14 @@ def run_tests():
return

timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
report_file = f"reports/{fname.replace('/', '_')}_{timestamp}.html"
report_file = os.path.join("reports", f"{fname.replace('/', '_')}_{timestamp}.html")

# Check if fname has \ and replace it with /
if "\\" in fname:
fname = fname.replace("\\", "/")

command = [
"python3",
"python",
"-m",
"behave",
"--define",
Expand All @@ -59,27 +67,41 @@ def run_tests():
report_file,
]

print("Running command:", ' '.join(command))
proc = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
try:
# Clear the output box
output_textbox.delete('1.0', tk.END)

# Clear the output box
output_textbox.delete('1.0', tk.END)
print("Running command:", ' '.join(command))
proc = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)

for line in iter(proc.stdout.readline, ''):
output_textbox.insert(tk.END, line)
output_textbox.see(tk.END)
for line in iter(proc.stderr.readline, ''):
output_textbox.insert(tk.END, line)
# Log to check if the process is running
if proc.poll() is None:
print("Process is running.")
else:
print("Process has failed to start.")

# Wait for the process to complete and get the output
stdout, stderr = proc.communicate()

# Update GUI with process output
output_textbox.insert(tk.END, stdout)
output_textbox.insert(tk.END, stderr)
output_textbox.see(tk.END)

proc.stdout.close()
proc.stderr.close()
proc.wait()
inject_css(report_file)

# Load the HTML report in the HTML viewer
load_html_report(report_file)
messagebox.showinfo("Success", "Test execution completed.")

except Exception as e:
messagebox.showerror("Error", f"An error occurred: {e}")

inject_css(report_file)
# Load the HTML report in the HTML viewer
load_html_report(report_file)
messagebox.showinfo("Success", "Test execution completed.")
finally:
if proc:
proc.stdout.close()
proc.stderr.close()
proc.wait()


def start_tests():
Expand Down Expand Up @@ -162,7 +184,7 @@ def show_feature_file_content():
return

try:
with open(os.path.join("features/tests", fname), 'r') as file:
with open(os.path.join(tests_main_dir, fname), 'r') as file:
content = file.read()
except Exception as e:
messagebox.showerror("Error", f"Failed to open feature file: {e}")
Expand All @@ -186,7 +208,6 @@ def show_feature_file_content():
root.title("UP-TCK Test Runner")

# Load and display the image
image_path = "../screenshots/uprotocol_logo.png"
image = Image.open(image_path)
photo = ImageTk.PhotoImage(image)

Expand All @@ -195,7 +216,7 @@ def show_feature_file_content():
image_label.grid(column=0, row=0, columnspan=2, padx=10, pady=5)

# Fetch feature files and set options
feature_files = list_feature_files("features/tests")
feature_files = list_feature_files(tests_main_dir)
languages = ["python", "java", "rust", "cpp"]
transports = ["socket", "zenoh", "someip"]
languages_with_blank = languages + ["_blank_"]
Expand Down

0 comments on commit b54a0cf

Please sign in to comment.