bashcov: Invalid byte sequence in UTF-8 (ArgumentError)

Hello, I’ve just upgraded to the latest (1.5.1) and I’m getting “invalid byte sequence in UTF-8 (ArgumentError)” when running bashcov against a very large legacy project. I don’t think I saw that error when using version 1.2.1. With that version, I had 18 files listed in the coverage report and now I have only 7.

When all tests have been run, I see the following:

/home/aclark/workspace/bashcov/lib/bashcov/lexer.rb:65:in `match': invalid byte sequence in UTF-8 (ArgumentError)
        from /home/aclark/workspace/bashcov/lib/bashcov/lexer.rb:65:in `match'
        from /home/aclark/workspace/bashcov/lib/bashcov/lexer.rb:65:in `mark_multiline'
        from /home/aclark/workspace/bashcov/lib/bashcov/lexer.rb:37:in `block in complete_coverage'
        from /home/aclark/workspace/bashcov/lib/bashcov/lexer.rb:35:in `each'
        from /home/aclark/workspace/bashcov/lib/bashcov/lexer.rb:35:in `each_with_index'
        from /home/aclark/workspace/bashcov/lib/bashcov/lexer.rb:35:in `complete_coverage'
        from /home/aclark/workspace/bashcov/lib/bashcov/runner.rb:149:in `block in mark_relevant_lines!'
        from /home/aclark/workspace/bashcov/lib/bashcov/runner.rb:147:in `each_pair'
        from /home/aclark/workspace/bashcov/lib/bashcov/runner.rb:147:in `mark_relevant_lines!'
        from /home/aclark/workspace/bashcov/lib/bashcov/runner.rb:68:in `result'
        from /home/aclark/workspace/bashcov/bin/bashcov:13:in `<main>'

and, when handling the exception in mark_multiline,

/home/aclark/workspace/bashcov/lib/bashcov/lexer.rb:87:in `sub!': invalid byte sequence in UTF-8 (ArgumentError)
        from /home/aclark/workspace/bashcov/lib/bashcov/lexer.rb:87:in `relevant?'
        from /home/aclark/workspace/bashcov/lib/bashcov/lexer.rb:83:in `mark_line'
        from /home/aclark/workspace/bashcov/lib/bashcov/lexer.rb:57:in `block in complete_coverage'
[...]

This code is likely riddled with invalid characters vis-a-vis UTF-8.

Anyone have any ideas how to get around this and report the true coverage? If it matters, I’m running bashcov 1.5.1 on Cygwin/Windows 8.1. Thanks in advance!

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 15 (5 by maintainers)

Most upvoted comments

Thanks, and sorry for the late reply! This does indeed fix the problem I was having.