There are some problems with 'run_tor()' and line-endings. It doesn't forsee any '\r\n' from 'Popen()' and since 'lines()' only splits on '\n', most of the tests fails.
With this little patch:
@@ -64,7 +64,7 @@ yield fp[i:i+4]
def lines(s): - out = s.split("\n") + out = s.splitlines()
I only get 2 errors in that script. The others like: self.assertTrue(out_verif.endswith("Configuration was valid\n"))
needs another patch which is beyond my Python knowledge.
Nice catch Gisle!
This is actually the first I've heard about test_cmdline_args.py. Interesting. These would be a good fit for our stem.process integ tests...
https://gitweb.torproject.org/stem.git/tree/test/integ/process.py
I'd be up for adding them, then tor could use them to exercise itself. But that said I've been trying to persuade Nick to use Stem's tests for years, so maybe not worthwhile.
On Mon, Jan 5, 2015 at 7:52 AM, Gisle Vanem gvanem@yahoo.no wrote:
There are some problems with 'run_tor()' and line-endings. It doesn't forsee any '\r\n' from 'Popen()' and since 'lines()' only splits on '\n', most of the tests fails.
With this little patch:
@@ -64,7 +64,7 @@ yield fp[i:i+4]
def lines(s):
- out = s.split("\n")
- out = s.splitlines()
I only get 2 errors in that script. The others like: self.assertTrue(out_verif.endswith("Configuration was valid\n"))
needs another patch which is beyond my Python knowledge.
-- --gv _______________________________________________ tor-dev mailing list tor-dev@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-dev
Gisle Vanem wrote:
I only get 2 errors in that script. The others like: self.assertTrue(out_verif.endswith("Configuration was valid\n"))
needs another patch which is beyond my Python knowledge.
I think it's fine now with this change:
@@ -57,14 +57,14 @@ raise UnexpectedFailure() elif not result and failure: raise UnexpectedSuccess() - return b2s(output) + return b2s(output.replace('\r\n','\n'))
Won't hurt on non-Windows, no?
Another problem was checking the SHA1 digest on main.c: main_line = [ l for l in lines(out) if l.endswith("/main.c") ]
Since the makefiles for MSVC doesn't specify "src/or/main.c", this won't work. From my 'tor.exe --digests': ... d17c7886ad4a021eb95caf56919e8a2fa84affe4 tor_main.c 7004e3f521b284d95a5baee52c8ddca24901e85d main.c
I suggest to patch that line like so:
@@ -151,7 +151,7 @@ if os.stat(TOR).st_mtime < os.stat(main_c).st_mtime: self.skipTest(TOR+" not up to date") out = run_tor(["--digests"]) - main_line = [ l for l in lines(out) if l.endswith("/main.c") ] + main_line = [ l for l in lines(out) if l.endswith("/main.c") or l.endswith(" main.c") ] digest, name = main_line[0].split()
On 01/05/2015 09:26 AM, Gisle Vanem wrote:
Gisle Vanem wrote:
I only get 2 errors in that script. The others like: self.assertTrue(out_verif.endswith("Configuration was valid\n"))
needs another patch which is beyond my Python knowledge.
I think it's fine now with this change:
@@ -57,14 +57,14 @@ raise UnexpectedFailure() elif not result and failure: raise UnexpectedSuccess()
- return b2s(output)
- return b2s(output.replace('\r\n','\n'))
Or even better, try to handle line endings in a platform agnostic manner. Perhaps you could do instead
- self.assertTrue(out_verif.endswith("Configuration was valid\n")) + self.assertTrue(out_verif.rstrip().endswith("Configuration was valid"))
since there are more line endings than POSIX and windows.
Justin
On Mon, Jan 5, 2015 at 1:08 PM, Justin Findlay jfindlay@gmail.com wrote:
On 01/05/2015 09:26 AM, Gisle Vanem wrote:
Gisle Vanem wrote:
I only get 2 errors in that script. The others like: self.assertTrue(out_verif.endswith("Configuration was valid\n"))
needs another patch which is beyond my Python knowledge.
I think it's fine now with this change:
@@ -57,14 +57,14 @@ raise UnexpectedFailure() elif not result and failure: raise UnexpectedSuccess()
- return b2s(output)
- return b2s(output.replace('\r\n','\n'))
Or even better, try to handle line endings in a platform agnostic manner. Perhaps you could do instead
self.assertTrue(out_verif.endswith("Configuration was valid\n"))
self.assertTrue(out_verif.rstrip().endswith("Configuration was
valid"))
since there are more line endings than POSIX and windows.
Thanks for working on this, everybody!
If possible, it would be handy to have a patch as an attachment, or a complete diff, or something I could apply? Applying this kind of thing by hand is kind of error-prone.
yrs,
Thanks; applied!
On Mon, Jan 5, 2015 at 1:08 PM, Justin Findlay jfindlay@gmail.com wrote:
On 01/05/2015 09:26 AM, Gisle Vanem wrote:
Gisle Vanem wrote:
I only get 2 errors in that script. The others like: self.assertTrue(out_verif.endswith("Configuration was valid\n"))
needs another patch which is beyond my Python knowledge.
I think it's fine now with this change:
@@ -57,14 +57,14 @@ raise UnexpectedFailure() elif not result and failure: raise UnexpectedSuccess()
- return b2s(output)
- return b2s(output.replace('\r\n','\n'))
Or even better, try to handle line endings in a platform agnostic manner. Perhaps you could do instead
self.assertTrue(out_verif.endswith("Configuration was valid\n"))
self.assertTrue(out_verif.rstrip().endswith("Configuration was
valid"))
since there are more line endings than POSIX and windows.
Justin _______________________________________________ tor-dev mailing list tor-dev@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-dev