[tor-bugs] #5472 [Stem]: Stem version parser matches git hash too

Tor Bug Tracker & Wiki torproject-admin at torproject.org
Thu Mar 29 12:23:30 UTC 2012


#5472: Stem version parser matches git hash too
--------------------+-------------------------------------------------------
 Reporter:  neena   |          Owner:  neena       
     Type:  defect  |         Status:  needs_review
 Priority:  normal  |      Milestone:              
Component:  Stem    |        Version:              
 Keywords:          |         Parent:              
   Points:          |   Actualpoints:              
--------------------+-------------------------------------------------------
Changes (by neena):

  * status:  needs_revision => needs_review


Comment:

 Replying to [comment:2 atagar]:
 > At present the regex won't match spaces but it will match other
 whitespace. Maybe replace "(-[^ ]*)" with "(-\S*)"?
 Done.

 > Nice catch. Would you mind adding a unit test for this (maybe something
 like "1a2a3a4")?
 Done.

 > > Returns a function that passes calls on to the stem.util.system.call()
 > > function if it's argument doesn't begin one of the keys in outputdict
 >
 > This is almost perfect, my only suggestion here would be to change the
 behavior when the system call isn't in outputdict. This is a unit test so,
 if we're making system calls from it, we're already doing something wrong
 (since we're making the test os dependent). Instead of passing through to
 system.call lets fail the test instead. This could look like...
 >
 Completely missed this, fixed.

 > {{{
 > VERSION_CALL_OUTPUT = """\
 > Mar 22 23:09:37.088 [notice] Tor v0.2.2.35 (git-73ff13ab3cc9570d). \
 > This is experimental software. Do not rely on it for \
 > strong anonymity. (Running on Linux i686)
 > Tor version 0.2.2.35 (git-73ff13ab3cc9570d)."""
 >
 > class system_call_mocker:
 >   def __init__(self, current_test, responses):
 >     self.current_test = current_test
 >     self.responses = responses
 >
 >   def call(self, command):
 >     if command in responses:
 >       return responses[command].splitlines()
 >     else:
 >       self.current_test.fail()
 >

 I've raised an Exception instead of using current_test.fail.
 I also did not seperate VERSION_CALL_OUTPUT because it will be
 straightforward to add more cases to test_get_system_tor_version later
 without putting too much variables in the file's global namespace.

 I modified branch history. I'm not sure if this is the best way to make
 changes.
 pull -f should work.

-- 
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/5472#comment:4>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online


More information about the tor-bugs mailing list