coverage
coverage copied to clipboard
results lookup against .resultset.json is case sensitive (windows)
Hi, thanks for a great plugin!
I had an issue where SimpleCov is generating .resultset.json
with capital letter for drive ("C:
") but coverage.el
expects a lower-case value ("c:
"). The case of all other characters in the file-path match, and I am able to rectify the situation by lower-casing the letter in the .resultset.json
file.
I spent some time trying to patch SimpleCov so that it would generate the filenames in the expected format, but then I realised that the problem wasn't with the generated, or expected typecase, but with the means of comparison.
I modified coverage.el
as follows. I don't know if you want to add this directly to your code since it may not be desired on other platforms but I provide here in case others are having similar issue.
I'm not very experienced with lisp, so there may be a neater way to do this, but for now rather than performing a straight associative lookup, it will iterate the keys and perform a case-insensitive comparison returning the first that matches.
Best, Rob
(defun coverage-get-results-for-file (target-path result-path)
"Return coverage for the file at TARGET-PATH from RESULT-PATH."
(cl-coerce (cdr
(car
(cl-remove-if-not 'identity
(mapcar (lambda (l)
;; === Begin New ===
(seq-find
(lambda (x)
(string-equal
(downcase target-path)
(downcase (symbol-name (car x)))))
(cdr (assoc 'coverage l)))
;; === End New ===
;; (assoc-string target-path
;; (assoc 'coverage l))
)
(coverage-get-json-from-file result-path)))))
'list))
Hi Rob,
Thanks so much for raising the issue and suggesting a solution! I'll take a look at this tonight and get back to you.
Kieran
I had a quick look at this, and didn't manage to get a failing test case that reproduces your problem written. I'll continue working on that tomorrow - I want to properly understand the cross-platform implications before merging a solution.
Okay well maybe to provide a little bit more context:
- I'm using jruby 1.16.0 as my main ruby interpreter
- Windows 10
- Emacs for Windows
- running under Powershell with Mingw/Msys on the path
- Msys bash set as the shell
- Project is in CVS (😢)
- Working one one of a number of custom gems stored in the project
Also perhaps relevant is I'm running in a custom $HOME
so that I can have a custom emacs environment for working on ruby ..
I might suggest that rather than trying to figure out how all this happens it might be more straightforward to detect that the OS is one that uses case-insensitive filenames and go from there!
Hope this helps!