Skip to content

Commit

Permalink
对打包后的exe进行基本功能测试
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuukiy committed Jan 7, 2024
1 parent 73eff2a commit 29d56bb
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 7 deletions.
17 changes: 15 additions & 2 deletions .github/workflows/pyinstaller.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ jobs:
build:
# The type of runner that the job will run on
runs-on: windows-latest
env:
PYTEST_ADDOPTS: "-rA --color=yes --tb=long --showlocals"

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
Expand All @@ -40,12 +42,23 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pyinstaller
python -m pip install -r requirements.txt
python -m pip install pyinstaller
- name: Build with PyInstaller for windows
run: cmd.exe /c 'make.bat'

- name: Install pytest
run: |
python -m pip install pytest
- name: Switch code page
run: |
chcp 65001
- name: Test JavSP.exe
run: pytest unittest/test_exe.py

- name: Set VERSION variable for windows
run: |
echo "VERSION=$(python make\gen_ver_hook.py)" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test-basic-funcs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest
pip install -r requirements.txt
python -m pip install flake8 pytest
python -m pip install -r requirements.txt
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/test-web-funcs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
runs-on: windows-latest
env:
PYTHONIOENCODING: "utf-8"
PYTEST_ADDOPTS: "-rA --color=yes"
PYTEST_ADDOPTS: "-rA --color=yes --tb=long --showlocals"

steps:
- uses: actions/checkout@v2
Expand All @@ -35,8 +35,8 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest
pip install -r requirements.txt
python -m pip install pytest
python -m pip install -r requirements.txt
- name: Switch code page
run: |
chcp 65001
Expand Down
2 changes: 2 additions & 0 deletions JavSP.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
from shutil import copyfile
from typing import Dict, List

sys.stdout.reconfigure(encoding='utf-8')

import colorama
import pretty_errors
from colorama import Fore, Style
Expand Down
37 changes: 37 additions & 0 deletions unittest/test_exe.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import os
import sys
import random
import string
import shutil
from glob import glob

sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
from core.config import cfg


def test_javsp_exe():
cwd = os.getcwd()
dist_dir = os.path.normpath(os.path.join(os.path.dirname(__file__) + '/../dist'))
os.chdir(dist_dir)

size = cfg.File.ignore_video_file_less_than
tmp_folder = 'TMP_' + ''.join(random.choices(string.ascii_uppercase, k=6))
FILE = '300MAAN-642.RIP.f4v'
try:
os.system(f"fsutil file createnew {FILE} {size}")
exit_code = os.system(f"JavSP.exe --auto-exit --input . --output {tmp_folder}")
assert exit_code == 0, f"Non-zero exit code: {exit_code}"
# Check generated files
files = glob(tmp_folder + '/**/*.*', recursive=True)
assert all('横宮七海' in i for i in files), "Actress name not found"
assert any(i.endswith('fanart.jpg') for i in files), "fanart not found"
assert any(i.endswith('poster.jpg') for i in files), "poster not found"
assert any(i.endswith('.f4v') for i in files), "video file not found"
assert any(i.endswith('.nfo') for i in files), "nfo file not found"
finally:
if os.path.exists(FILE):
os.remove(FILE)
if os.path.exists(tmp_folder):
shutil.rmtree(tmp_folder)
os.chdir(cwd)

0 comments on commit 29d56bb

Please sign in to comment.