Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception for filename= with coverage 4.4 #10

Closed
dmulter opened this issue May 10, 2017 · 11 comments
Closed

Exception for filename= with coverage 4.4 #10

dmulter opened this issue May 10, 2017 · 11 comments

Comments

@dmulter
Copy link

dmulter commented May 10, 2017

The latest version of coverage has changed how they output the XML file and this has broken the ability to read the file in this tool. More details in their repo here:

https://bitbucket.org/ned/coveragepy/issues/578/incomplete-file-path-in-xml-report

@tumb1er
Copy link
Owner

tumb1er commented May 11, 2017

Well, travis autotests does not show this error: https://travis-ci.org/tumb1er/coverage2clover/builds/231042026
How can I reproduce it?

@dmulter
Copy link
Author

dmulter commented May 11, 2017

@tumb1er
Copy link
Owner

tumb1er commented May 11, 2017 via email

tumb1er added a commit that referenced this issue May 12, 2017
tumb1er added a commit that referenced this issue May 12, 2017
tumb1er added a commit that referenced this issue May 12, 2017
#10 count missing file as 0 loc
@tumb1er
Copy link
Owner

tumb1er commented May 12, 2017

fixed in #13

@tumb1er tumb1er closed this as completed May 12, 2017
@dmulter
Copy link
Author

dmulter commented May 12, 2017

After seeing your fix and working with the coverage maintainer, I see that my repo actually exposed another bug first. This was no output for two files with the same name in two modules. Thanks for fixing that, but the real problem I was trying to show was an incomplete filespec output by coverage for two different files in two modules. I've altered the repo to run two tests, the original and one for this other case. Please check the repo again to see what I mean. I hope the second test fails also for you and you'll see what I mean.

@tumb1er
Copy link
Owner

tumb1er commented May 12, 2017

When I run latest version, I got:

=== test session starts 
platform linux2 -- Python 2.7.12, pytest-3.0.7, py-1.4.33, pluggy-0.4.0
rootdir: /home/tumbler/PycharmProjects/coverage2clover_bug-master, inifile:
plugins: cov-2.5.0
collected 2 items 

tests/test.py ..Coverage.py warning: No data was collected. (no-data-collected)


---------- coverage: platform linux2, python 2.7.12-final-0 ----------
Coverage XML written to file coverage1.xml


=== 2 passed in 0.01 seconds

Traceback (most recent call last):
  File "/data/cc/virtualenv/bin/py.test", line 11, in <module>
    sys.exit(main())

...

  File "/data/cc/virtualenv/local/lib/python2.7/site-packages/coverage/config.py", line 427, in read_coverage_config
    raise CoverageException("Couldn't read '%s' as a config file" % fname)
coverage.misc.CoverageException: Couldn't read '.coveragerc_noinitfiles' as a config file
==== Running coverage2clover with two __init__.py files...

Is it correct?

@dmulter
Copy link
Author

dmulter commented May 12, 2017

sorry, pull again

@tumb1er
Copy link
Owner

tumb1er commented May 12, 2017

Running coverage2clover with two init.py files...

<?xml version='1.0' encoding='utf-8'?>
<coverage clover="4.4" generated="12-05-17">
    <project timestamp="12-05-17">
        <metrics classes="3" conditionals="0" coveredconditionals="0"
                 coveredelements="0" coveredstatements="0" elements="4"
                 files="3" loc="3" ncloc="4" packages="1" statements="4"/>
        <package name="">
            <metrics classes="3" conditionals="0" coveredconditionals="0"
                     coveredelements="0" coveredstatements="0" elements="4"
                     files="3" loc="3" ncloc="4" statements="4"/>
            <class filename="__init__.py" name="__init__.py">
                <metrics conditionals="0" coveredconditionals="0"
                         coveredelements="0" coveredstatements="0" elements="0"
                         files="1" loc="1" ncloc="0" statements="0"/>
            </class>
            <class filename="bar.py" name="bar.py">
                <metrics conditionals="0" coveredconditionals="0"
                         coveredelements="0" coveredstatements="0" elements="2"
                         files="1" loc="1" ncloc="2" statements="2"/>
            </class>
            <class filename="foo.py" name="foo.py">
                <metrics conditionals="0" coveredconditionals="0"
                         coveredelements="0" coveredstatements="0" elements="2"
                         files="1" loc="1" ncloc="2" statements="2"/>
            </class>
        </package>
    </project>
</coverage>

Running coverage2clover for foo.py and bar.py...

<?xml version='1.0' encoding='utf-8'?>
<coverage clover="4.4" generated="12-05-17">
    <project timestamp="12-05-17">
        <metrics classes="2" conditionals="0" coveredconditionals="0"
                 coveredelements="0" coveredstatements="0" elements="4"
                 files="2" loc="2" ncloc="4" packages="1" statements="4"/>
        <package name="">
            <metrics classes="2" conditionals="0" coveredconditionals="0"
                     coveredelements="0" coveredstatements="0" elements="4"
                     files="2" loc="2" ncloc="4" statements="4"/>
            <class filename="bar.py" name="bar.py">
                <metrics conditionals="0" coveredconditionals="0"
                         coveredelements="0" coveredstatements="0" elements="2"
                         files="1" loc="1" ncloc="2" statements="2"/>
            </class>
            <class filename="foo.py" name="foo.py">
                <metrics conditionals="0" coveredconditionals="0"
                         coveredelements="0" coveredstatements="0" elements="2"
                         files="1" loc="1" ncloc="2" statements="2"/>
            </class>
        </package>
    </project>
</coverage>

I'm not sure if there is any bug...

@dmulter
Copy link
Author

dmulter commented May 12, 2017

So maybe your fix solved both problems? I get the following output from showbug.sh for the second (foo/bar) test:

==== Running coverage2clover for foo.py and bar.py...
wc: bar.py: open: No such file or directory
Traceback (most recent call last):
  File "/Users/dmulter/Documents/xxx/projects/github/coverage2clover_bug/.virtualenv/bin/coverage2clover", line 27, in <module>
    cov.open(inputfile)
  File "/Users/dmulter/Documents/xxx/projects/github/coverage2clover_bug/.virtualenv/lib/python2.7/site-packages/clover/__init__.py", line 138, in open
    c.count_loc()
  File "/Users/dmulter/Documents/xxx/projects/github/coverage2clover_bug/.virtualenv/lib/python2.7/site-packages/clover/__init__.py", line 80, in count_loc
    output = subprocess.check_output(['wc', '-l', self.filename])
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 573, in check_output
    raise CalledProcessError(retcode, cmd, output=output)
subprocess.CalledProcessError: Command '['wc', '-l', 'bar.py']' returned non-zero exit status 1

@tumb1er
Copy link
Owner

tumb1er commented May 13, 2017

In #12 I merged to version 1.3 complete removal of 'wc' call. Also, your bug repo requirements.txt still contains c2c==1.2, not the last version.

@dmulter
Copy link
Author

dmulter commented May 15, 2017

Confirmed the bug is fixed for me, thanks for the quick turnaround!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants