Skip to content

Commit

Permalink
allow some tests (except on CI) to be skipped when svn/hg are unavail…
Browse files Browse the repository at this point in the history
…able (#182)

* FIX: Regression if subversion or mercurial are missing

Split-up test_validate() into two parts:
* test_validate: Part requires only git
* test_validate2: Part requires subversion (svn) and mercurial (hg)
* test_validate2 is skipped if either svn or hg are not installed
* support: FAKE-PROGRAM detection that exist (svn)
  but only states that the program is missing if it is run
  (usecase: macOS for svn that was a former part of Xcode).

* Disable skip-test functionality when CI environment variable is set.

NOTE: All tests should be executed when CI is used.

* refactor / cleanup

Co-authored-by: Dirk Thomas <dirk-thomas@users.noreply.github.com>
  • Loading branch information
jenisys and dirk-thomas authored Nov 2, 2020
1 parent ddd9f1c commit da30c41
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions test/test_commands.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
from shutil import which
import subprocess
import sys
import unittest
Expand All @@ -15,6 +16,17 @@
TEST_WORKSPACE = os.path.join(
os.path.dirname(os.path.dirname(__file__)), 'test_workspace')

CI = os.environ.get('CI') == 'true' # Travis CI / Github actions set: CI=true
svn = which('svn')
hg = which('hg')
if svn:
# check if the svn executable is usable (on macOS)
# and not only exists to state that the program is not installed
try:
subprocess.check_call([svn, '--version'])
except subprocess.CalledProcessError:
svn = False


class TestCommands(unittest.TestCase):

Expand Down Expand Up @@ -292,13 +304,16 @@ def test_validate(self):
self.assertEqual(output, expected)

output = run_command(
'validate', ['--input', REPOS2_FILE])
expected = get_expected_output('validate2')
'validate', ['--hide-empty', '--input', REPOS_FILE])
expected = get_expected_output('validate_hide')
self.assertEqual(output, expected)

@unittest.skipIf(not svn and not CI, '`svn` was not found')
@unittest.skipIf(not hg and not CI, '`hg` was not found')
def test_validate_svn_and_hg(self):
output = run_command(
'validate', ['--hide-empty', '--input', REPOS_FILE])
expected = get_expected_output('validate_hide')
'validate', ['--input', REPOS2_FILE])
expected = get_expected_output('validate2')
self.assertEqual(output, expected)

def test_remote(self):
Expand Down

0 comments on commit da30c41

Please sign in to comment.