]> Nutra Git (v1) - gamesguru/ffpass.git/commitdiff
test on Windows & macOS with GH Runner/Action
authorShane Jaroch <chown_tee@proton.me>
Thu, 25 Dec 2025 22:26:33 +0000 (17:26 -0500)
committerShane Jaroch <chown_tee@proton.me>
Thu, 25 Dec 2025 23:21:31 +0000 (18:21 -0500)
.github/workflows/testing.yaml
.github/workflows/windows-and-mac.yaml [new file with mode: 0644]
Makefile
setup.py
tests/test_run.py

index 24ddd974ffd828f6dfc07ecc43cb5b338ffde1ad..7b2bff4890a77b48359fa61761f53a10184c7801 100644 (file)
@@ -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 (file)
index 0000000..29f3b2f
--- /dev/null
@@ -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
index b2ddd00164b8df9163e47c7937fcd792c140b2c0..18d587a3bc81d808416b908dc490d88d4f22e93d 100644 (file)
--- 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/*"
 
 
index 211d2658be0e6c7c4687caec804aea4c939ae310..57fb9a8f50435265864ca70d07f8a71c2337fe9a 100755 (executable)
--- 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(
index ee6d5eec5a9582c328bdeb66b5c8123445af6f96..18dcc372e241e0f0cf86c4d5be6500bc4eb91756 100644 (file)
@@ -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