From f6919caacfd6901fed1c91d5590faf31c12c39a5 Mon Sep 17 00:00:00 2001 From: Shane Jaroch Date: Thu, 25 Dec 2025 17:26:33 -0500 Subject: [PATCH] test on Windows & macOS with GH Runner/Action --- .github/workflows/testing.yaml | 2 +- .github/workflows/windows-and-mac.yaml | 50 ++++++++++++++++++++++++++ Makefile | 2 +- setup.py | 2 +- tests/test_run.py | 29 +++++++++------ 5 files changed, 71 insertions(+), 14 deletions(-) create mode 100644 .github/workflows/windows-and-mac.yaml diff --git a/.github/workflows/testing.yaml b/.github/workflows/testing.yaml index 24ddd97..7b2bff4 100644 --- a/.github/workflows/testing.yaml +++ b/.github/workflows/testing.yaml @@ -5,7 +5,7 @@ on: [push, pull_request_target] jobs: test: name: Test - runs-on: ubuntu-latest + runs-on: [ubuntu-latest] steps: - name: Checkout uses: actions/checkout@v4 diff --git a/.github/workflows/windows-and-mac.yaml b/.github/workflows/windows-and-mac.yaml new file mode 100644 index 0000000..29f3b2f --- /dev/null +++ b/.github/workflows/windows-and-mac.yaml @@ -0,0 +1,50 @@ +name: windows-and-mac + +on: [push, pull_request_target] + +jobs: + windows: + name: windows + runs-on: [windows-latest] + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.x' + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install . + + - name: Test with pytest + run: | + pip install pytest + pip install pytest-cov + python -m pytest tests --junit-xml pytest.xml + + macOS: + name: macOS + runs-on: [macos-latest] + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.x' + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install . + + - name: Test with pytest + run: | + pip install pytest + pip install pytest-cov + python -m pytest tests --junit-xml pytest.xml \ No newline at end of file diff --git a/Makefile b/Makefile index b2ddd00..18d587a 100644 --- a/Makefile +++ b/Makefile @@ -20,7 +20,7 @@ install: .PHONY: test test: @echo 'Remember to run make install to test against the latest :)' - coverage run -m pytest -s tests/ + coverage run -m pytest -svv tests/ coverage report -m --omit="tests/*" diff --git a/setup.py b/setup.py index 211d265..57fb9a8 100755 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ from setuptools import setup def read(fname): - return open(os.path.join(os.path.dirname(__file__), fname)).read() + return open(os.path.join(os.path.dirname(__file__), fname), encoding="utf-8").read() setup( diff --git a/tests/test_run.py b/tests/test_run.py index ee6d5ee..18dcc37 100644 --- a/tests/test_run.py +++ b/tests/test_run.py @@ -1,15 +1,18 @@ #!/usr/bin/env python3 +import os import subprocess import shutil import pytest from pathlib import Path +OS_NEWLINE = os.linesep + MASTER_PASSWORD = 'test' -HEADER = 'url,username,password\n' -IMPORT_CREDENTIAL = 'http://www.example.com,foo,bar\n' -EXPECTED_EXPORT_OUTPUT = f'{HEADER}http://www.stealmylogin.com,test,test\n' -EXPECTED_IMPORT_OUTPUT = EXPECTED_EXPORT_OUTPUT + IMPORT_CREDENTIAL +HEADER = 'url,username,password' +IMPORT_CREDENTIAL = 'http://www.example.com,foo,bar' +EXPECTED_EXPORT_OUTPUT = [HEADER, 'http://www.stealmylogin.com,test,test'] +EXPECTED_IMPORT_OUTPUT = EXPECTED_EXPORT_OUTPUT + [IMPORT_CREDENTIAL] @pytest.fixture @@ -30,23 +33,28 @@ def run_ffpass(mode, path): command = ["ffpass", mode, "-d", str(path)] if mode == 'import': - ffpass_input = HEADER + IMPORT_CREDENTIAL + ffpass_input = OS_NEWLINE.join([HEADER, IMPORT_CREDENTIAL]) else: ffpass_input = None return subprocess.run(command, stdout=subprocess.PIPE, input=ffpass_input, encoding='utf-8') +def stdout_splitter(input_text): + return [x for x in input_text.splitlines() if x != ""] + + def test_legacy_firefox_export(clean_profile): r = run_ffpass('export', clean_profile('firefox-70')) r.check_returncode() - assert r.stdout == EXPECTED_EXPORT_OUTPUT + actual_export_output = stdout_splitter(r.stdout) + assert actual_export_output == EXPECTED_EXPORT_OUTPUT def test_firefox_export(clean_profile): r = run_ffpass('export', clean_profile('firefox-84')) r.check_returncode() - assert r.stdout == EXPECTED_EXPORT_OUTPUT + assert stdout_splitter(r.stdout) == EXPECTED_EXPORT_OUTPUT def test_firefox_aes_export(clean_profile): @@ -54,7 +62,7 @@ def test_firefox_aes_export(clean_profile): profile_path = clean_profile('firefox-146-aes') r = run_ffpass('export', profile_path) r.check_returncode() - assert r.stdout == EXPECTED_EXPORT_OUTPUT + assert stdout_splitter(r.stdout) == EXPECTED_EXPORT_OUTPUT def test_legacy_firefox(clean_profile): @@ -66,7 +74,7 @@ def test_legacy_firefox(clean_profile): r = run_ffpass('export', profile_path) r.check_returncode() - assert r.stdout == EXPECTED_IMPORT_OUTPUT + assert stdout_splitter(r.stdout) == EXPECTED_IMPORT_OUTPUT def test_firefox(clean_profile): @@ -77,5 +85,4 @@ def test_firefox(clean_profile): r = run_ffpass('export', profile_path) r.check_returncode() - assert r.stdout == EXPECTED_IMPORT_OUTPUT - + assert stdout_splitter(r.stdout) == EXPECTED_IMPORT_OUTPUT -- 2.52.0