Skip to content

Commit

Permalink
tests: normalize path separators in tests for Windows CI
Browse files Browse the repository at this point in the history
  • Loading branch information
rhysd committed Jan 30, 2020
1 parent c4aab3b commit 8008a17
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
from os.path import normpath
import signal
import subprocess
from subprocess import call
Expand Down Expand Up @@ -221,7 +222,7 @@ def test_cli_run_can_skip_writing_data(with_append, runner, tmpdir):
'Parsing profile file %s.' % profile_file,
'Name Stmts Miss Cover',
'----------------------------------------------------------------',
'tests/test_plugin/conditional_function.vim 13 5 62%']
normpath('tests/test_plugin/conditional_function.vim') + ' 13 5 62%']
assert not tmpdir.join(DEFAULT_COVERAGE_DATA_FILE).exists()


Expand Down Expand Up @@ -267,7 +268,7 @@ def test_cli_run_report_fd(capfd, tmpdir, devnull):
assert out.splitlines() == [
'Name Stmts Miss Cover',
'----------------------------------------------------------------',
'tests/test_plugin/conditional_function.vim 13 5 62%']
normpath('tests/test_plugin/conditional_function.vim') + ' 13 5 62%']
assert err.splitlines() == [
'Running cmd: true (in %s)' % str(os.getcwd()),
'Parsing profile file %s.' % tmp_profile_fname,
Expand All @@ -286,7 +287,7 @@ def test_cli_run_report_fd(capfd, tmpdir, devnull):
assert open(ofname).read().splitlines() == [
'Name Stmts Miss Cover',
'----------------------------------------------------------------',
'tests/test_plugin/conditional_function.vim 13 5 62%']
normpath('tests/test_plugin/conditional_function.vim') + ' 13 5 62%']


def test_cli_call(capfd):
Expand Down Expand Up @@ -511,7 +512,7 @@ def test_report_profile_or_data_file(runner, tmpdir):
assert result.output.splitlines() == [
'Name Stmts Miss Cover',
'---------------------------------------------------------------',
'tests/test_plugin/merged_conditionals.vim 19 12 37%']
normpath('tests/test_plugin/merged_conditionals.vim') + ' 19 12 37%']
assert result.exit_code == 0


Expand Down Expand Up @@ -553,7 +554,7 @@ def test_report_source(runner, tmpdir, devnull):
)
assert result.exit_code == 2

fname = "foo/bar/test.vim"
fname = normpath("foo/bar/test.vim")
tmpdir.join(fname).ensure().write("echom 1")
tmpdir.join("foo/bar/test2.vim").ensure().write("echom 2")
result = runner.invoke(cli.main, ["report", "--source", ".", devnull.name])
Expand Down Expand Up @@ -591,7 +592,7 @@ def test_report_source(runner, tmpdir, devnull):
== [
"Name Stmts Miss Cover",
"---------------------------------------------------------------",
"tests/test_plugin/merged_conditionals.vim 19 12 37%",
normpath("tests/test_plugin/merged_conditionals.vim") + " 19 12 37%",
]
)
assert result.exit_code == 0
Expand All @@ -609,8 +610,8 @@ def test_cli_xml(runner, tmpdir):

with open('coverage.xml') as f:
xml = f.read()
assert 'filename="%s/tests/test_plugin/merged_conditionals.vim' % (
old_cwd) in xml
assert 'filename="%s' % (
old_cwd.join('/tests/test_plugin/merged_conditionals.vim')) in xml

# --rcfile is used.
coveragerc = 'customrc'
Expand All @@ -624,8 +625,8 @@ def test_cli_xml(runner, tmpdir):
assert result.exit_code == 0
with open('custom.xml') as f:
xml = f.read()
assert 'filename="%s/tests/test_plugin/merged_conditionals.vim' % (
old_cwd) in xml
assert 'filename="%s' % (
old_cwd.join('/tests/test_plugin/merged_conditionals.vim')) in xml

# --rcfile is used.
coveragerc = 'customrc'
Expand Down Expand Up @@ -722,7 +723,7 @@ def run_args(profile_file):
'Writing coverage file .coverage_covimerage.',
'Name Stmts Miss Cover',
'----------------------------------------------------------------',
'tests/test_plugin/conditional_function.vim 13 5 62%']
normpath('tests/test_plugin/conditional_function.vim') + ' 13 5 62%']
assert result.exit_code == 0

assert open('.coverage_covimerage').read().startswith(covdata_header)
Expand All @@ -735,7 +736,7 @@ def run_args(profile_file):
'Writing coverage file .coverage_covimerage.',
'Name Stmts Miss Cover',
'----------------------------------------------------------------',
'tests/test_plugin/conditional_function.vim 13 5 62%']
normpath('tests/test_plugin/conditional_function.vim') + ' 13 5 62%']
assert result.exit_code == 0

# Append another profile.
Expand All @@ -753,8 +754,8 @@ def run_args(profile_file):
'Writing coverage file .coverage_covimerage.',
'Name Stmts Miss Cover',
'----------------------------------------------------------------',
'tests/test_plugin/conditional_function.vim 13 5 62%',
'tests/test_plugin/merged_conditionals.vim 19 12 37%',
normpath('tests/test_plugin/conditional_function.vim') + ' 13 5 62%',
normpath('tests/test_plugin/merged_conditionals.vim') + ' 19 12 37%',
'----------------------------------------------------------------',
'TOTAL 32 17 47%']
assert result.exit_code == 0
Expand Down

0 comments on commit 8008a17

Please sign in to comment.