ostinelli / SublimErl

An Erlang Plugin for Sublime Text 2, which enables code completion and allows you to run tests within the editor itself.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

EUnit Test only run once - Unicode handling

jwedel opened this issue · comments

Hi,

I just had a problem, where I could run the EUnit tests only once, and actually, the output was not complete:

Starting tests (SublimErl v0.5.1).
Running test "device_consumer_test:all_tests_test_/0" for target module  "device_consumer_test.erl".

/Users/janwedel/Development/erlang/erlactive$ /Users/janwedel/Development/erlang/rebar/rebar eunit suites=device_consumer_test tests=all_tests_test_ apps=erlactive skip_deps=true

==> erlactive (eunit)

Only quitting sublime and restarting it was recovering the issue but as soon as I ran the tests again, it was stuck again. At first I thought the test itself was stuck in a dead lock, but there was no beam.smp process. Then I checked the source code ([https://github.com/ostinelli/SublimErl/blob/master/sublimerl_tests_integration.py]) and did the following trick within the Sublime console:

>>> from sublimerl_core import SUBLIMERL
>>> SUBLIMERL.test_in_progress = False

Then I was able to rerun the tests, but with the same result.

While have the Sublime console open, I saw the following exception:

Exception in thread Thread-26:
Traceback (most recent call last):
  File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/threading.py", line 532, in __bootstrap_inner
    self.run()

  File "./sublimerl_tests_integration.py", line 221, in run
  File "./sublimerl_tests_integration.py", line 250, in eunit_test
  File "./sublimerl_tests_integration.py", line 260, in compile_eunit_run_suite
  File "./sublimerl_core.py", line 315, in execute_os_command
  File "./sublimerl_tests_integration.py", line 76, in log
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 49: ordinal  not in range(128)

Then I used CMD-B to build a file that I had last edited before the problem occurred, and I got the following from the python console:

device_producer.erl:3: can't find include lib "amqp_client/include/amqp_client.hrl"
[Decode error - output not utf-8]
device_producer.erl:10: function init/1 undefined

Then I compiled it from the command line:

1> c(device_producer).
device_producer.erl:3: can't find include lib "amqp_client/include/amqp_client.hrl"
device_producer.erl:28: syntax error before: Â
device_producer.erl:10: function init/1 undefined

Ok, at least I knew in which line I had to look. Actually, I copied some text from the web (yeah, not a good idea) and it was not an A with some accent, at least not visible in sublime. It was displayed as if it was a space character, but when selecting it, it did not show the grey dot. So I erased it and it at least did compile again.

Then again, setting test_in_progress to False, ran the complete tests without a problem.

Long story short, there should be some proper handling for utf-8 character or at least removing them. Plus, if the test runner crashes (as it did), it should be possible to run them again.