From 8a4ec493c0736d38aba204fa455036b4160494de Mon Sep 17 00:00:00 2001 From: Calum Lind Date: Mon, 22 Feb 2021 11:00:17 +0000 Subject: [CI/CD] Add Travis windows build * Added APPDATA to tox passenv so it is available to common module. * Fixed windows path issue in httpdownloader tests * Skipped torrentmanager test due to the following error from loading a Linux pickled state file with a different line ending. ModuleNotFoundError: No module named 'deluge.core.torrentmanager\r' * Removed appveyor build --- .travis.yml | 11 ++++++++ appveyor.yml | 53 ------------------------------------- deluge/tests/test_httpdownloader.py | 16 ++--------- deluge/tests/test_torrentmanager.py | 7 +++++ tox.ini | 2 +- 5 files changed, 21 insertions(+), 68 deletions(-) delete mode 100644 appveyor.yml diff --git a/.travis.yml b/.travis.yml index ac4c79b1c..dd4a8f36e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -39,6 +39,17 @@ jobs: env: TOX_ENV=gtkui - name: Plugins unit tests env: TOX_ENV=plugins + - name: Windows Unit tests + os: windows + language: shell + before_install: + - choco install python --version 3.6.8 + - python --version + - python -m pip install --upgrade pip + - python -m pip install deluge-libtorrent + env: + - PATH=/c/Python36:/c/Python36/Scripts:$PATH + - TOX_ENV=py3 addons: apt: diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index def7990bd..000000000 --- a/appveyor.yml +++ /dev/null @@ -1,53 +0,0 @@ -environment: - PYTHON_VERSION: 3.6 - PYTHON_ARCH: 64 - PYTHON: "C:\\Python36-x64" - APPVEYOR_SAVE_CACHE_ON_ERROR: true - - matrix: - - TOXENV: py36 - -pull_requests: - do_not_increment_build_number: true - -install: - # If there is a newer build queued for same PR, cancel this one. Credit: JuliaLang devs - - ps: - if ($env:APPVEYOR_PULL_REQUEST_NUMBER -and $env:APPVEYOR_BUILD_NUMBER -ne ((Invoke-RestMethod ` - https://ci.appveyor.com/api/projects/$env:APPVEYOR_ACCOUNT_NAME/$env:APPVEYOR_PROJECT_SLUG/history?recordsNumber=50).builds | ` - Where-Object pullRequestId -eq $env:APPVEYOR_PULL_REQUEST_NUMBER)[0].buildNumber) { ` - throw "There are newer queued builds for this pull request, failing early." } - - "SET PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH%" - - "python -VV" - - if defined TOXENV ( - python -m pip install tox tox_venv - ) else ( - python -m pip install -rrequirements.txt pygame bbfreeze pefile - ) - - "SET PATH=C:\\OpenSSL-v11-Win64\\bin;%PATH%" - - openssl version -v - - python -m pip install deluge-libtorrent - - 'python -c "import libtorrent; print(libtorrent.__version__)"' - -cache: - - '%LOCALAPPDATA%\pip\cache' - -build: false - -test_script: - - if defined TOXENV tox -# Commented out as require GTK3 to create package. -# after_test: -# - if not defined TOXENV python setup.py build && python setup.py install -# - cd %APPVEYOR_BUILD_FOLDER%\\packaging\\win32 -# - if not defined TOXENV deluge-bbfreeze.py debug -# - "SET PATH=C:\\Program Files (x86)\\NSIS;%PATH%" -# - if not defined TOXENV makensis deluge-win32-installer.nsi -# - if not defined TOXENV 7z a deluge-win32.zip build-win32 "-x!*.exe" - -# artifacts: -# - path: packaging\win32\deluge-win32.zip -# - path: packaging\win32\build-win32\*.exe - -#on_success: -# diff --git a/deluge/tests/test_httpdownloader.py b/deluge/tests/test_httpdownloader.py index 2a52744e1..ad947a422 100644 --- a/deluge/tests/test_httpdownloader.py +++ b/deluge/tests/test_httpdownloader.py @@ -7,6 +7,7 @@ from __future__ import unicode_literals +import os import tempfile from email.utils import formatdate from io import open @@ -21,7 +22,6 @@ from twisted.web.resource import EncodingResourceWrapper, Resource from twisted.web.server import GzipEncoderFactory, Site from twisted.web.util import redirectTo -from deluge.common import windows_check from deluge.httpdownloader import download_file from deluge.log import setup_logger @@ -29,7 +29,7 @@ temp_dir = tempfile.mkdtemp() def fname(name): - return '%s/%s' % (temp_dir, name) + return os.path.join(temp_dir, name) class RedirectResource(Resource): @@ -198,10 +198,6 @@ class DownloadFileTestCase(unittest.TestCase): return d def test_download_with_rename(self): - - if windows_check(): - raise unittest.SkipTest('on windows \\ != / for path names') - url = self.get_url('rename?filename=renamed') d = download_file(url, fname('original')) d.addCallback(self.assertEqual, fname('renamed')) @@ -209,10 +205,6 @@ class DownloadFileTestCase(unittest.TestCase): return d def test_download_with_rename_exists(self): - - if windows_check(): - raise unittest.SkipTest('on windows \\ != / for path names') - open(fname('renamed'), 'w').close() url = self.get_url('rename?filename=renamed') d = download_file(url, fname('original')) @@ -221,10 +213,6 @@ class DownloadFileTestCase(unittest.TestCase): return d def test_download_with_rename_sanitised(self): - - if windows_check(): - raise unittest.SkipTest('on windows \\ != / for path names') - url = self.get_url('rename?filename=/etc/passwd') d = download_file(url, fname('original')) d.addCallback(self.assertEqual, fname('passwd')) diff --git a/deluge/tests/test_torrentmanager.py b/deluge/tests/test_torrentmanager.py index 20f824eb7..e0ff09efc 100644 --- a/deluge/tests/test_torrentmanager.py +++ b/deluge/tests/test_torrentmanager.py @@ -15,8 +15,10 @@ from base64 import b64encode import mock import pytest from twisted.internet import defer, task +from twisted.trial import unittest from deluge import component +from deluge.common import windows_check from deluge.core.core import Core from deluge.core.rpcserver import RPCServer from deluge.error import InvalidTorrentError @@ -137,5 +139,10 @@ class TorrentmanagerTestCase(BaseTestCase): common.get_test_data_file('utf8_filename_torrents.state'), os.path.join(self.config_dir, 'state', 'torrents.state'), ) + if windows_check(): + raise unittest.SkipTest( + 'Windows ModuleNotFoundError due to Linux line ending' + ) + state = self.tm.open_state() self.assertEqual(len(state.torrents), 1) diff --git a/tox.ini b/tox.ini index 41ff1fbc0..5b9152978 100644 --- a/tox.ini +++ b/tox.ini @@ -56,7 +56,7 @@ deps = [testenv] install_command = python -m pip install --ignore-installed {opts} {packages} -passenv = DISPLAY PYTHONPATH +passenv = DISPLAY PYTHONPATH APPDATA setenv = PYTHONPATH = {toxinidir} PYTEST_ADDOPTS = --verbose --capture=no -- cgit