Selftest fails to start on Windows

Bug #492561 reported by John A Meinel on 2009-12-04
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Bazaar
Critical
Vincent Ladeuil

Bug Description

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Vincent's recent patch to use "termios" breaks the test suite on
Windows. Trying to run "bzr selftest" results in:

bzr: ERROR: No module named termios
You may need to install this Python library separately.

Reverting to bzr 4862 gets the test suite to run again.

The full traceback ends in:
  File "d:\bzr\bzr.dev\bzrlib\tests\test_dirstate.py", line 31, in <module>
    from bzrlib.tests import test_osutils
  File "d:\bzr\bzr.dev\bzrlib\tests\test_osutils.py", line 26, in <module>
    import termios
ImportError: No module named termios

Looking here:
http://docs.python.org/library/termios.html#module-termios

It says the module is only available on Unix. I don't know what that
means for Mac, but it definitely isn't available on Windows.

John
=:->

 affects bzr
 status confirmed
 importance critical
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAksZTbUACgkQJdeBCYSNAAPTFACgiJVVQblGuQ/Gi9v0A6kKkJlB
+b8AoJk9Ayr6s5jJPT/F9LEpVqE6XeoE
=BCTL
-----END PGP SIGNATURE-----

Related branches

John A Meinel (jameinel) wrote :

A possible fix is:
=== modified file 'bzrlib/tests/test_osutils.py'
--- bzrlib/tests/test_osutils.py 2009-12-04 10:09:11 +0000
+++ bzrlib/tests/test_osutils.py 2009-12-04 17:59:07 +0000
@@ -23,7 +23,10 @@
 import socket
 import stat
 import sys
-import termios
+try:
+ import termios
+except ImportError:
+ termios = None
 import time

 from bzrlib import (
@@ -1962,6 +1965,8 @@
         self.assertEquals(None, osutils.terminal_width())

     def test_TIOCGWINSZ(self):
+ if termios is None:
+ raise tests.TestSkipped('termios is not available')
         # bug 63539 is about a termios without TIOCGWINSZ attribute
         exist = True
         try:

But it would be probably better to use a Feature for the test.

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

John A Meinel wrote:
> A possible fix is:
> === modified file 'bzrlib/tests/test_osutils.py'
> --- bzrlib/tests/test_osutils.py 2009-12-04 10:09:11 +0000
> +++ bzrlib/tests/test_osutils.py 2009-12-04 17:59:07 +0000
> @@ -23,7 +23,10 @@
> import socket
> import stat
> import sys
> -import termios
> +try:
> + import termios
> +except ImportError:
> + termios = None
> import time
>
> from bzrlib import (
> @@ -1962,6 +1965,8 @@
> self.assertEquals(None, osutils.terminal_width())
>
> def test_TIOCGWINSZ(self):
> + if termios is None:
> + raise tests.TestSkipped('termios is not available')
> # bug 63539 is about a termios without TIOCGWINSZ attribute
> exist = True
> try:
>
> But it would be probably better to use a Feature for the test.
>

Even with this patch I still get:
======================================================================
FAIL: test_tty_default_without_columns
(bzrlib.tests.test_osutils.TestTerminalWidth)
- ----------------------------------------------------------------------
Traceback (most recent call last):
  File "d:\bzr\bzr.dev\bzrlib\tests\test_osutils.py", line 1955, in
test_tty_default_without_columns

    self.assertEquals(None, osutils.terminal_width())
AssertionError: not equal:
a = None
b = 100

I assume the issue is that Windows is always returning a value even
though we expect it not to? (100 is the correct column width in my case.)

John
=:->

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAksZcBUACgkQJdeBCYSNAAMn9QCgnv64UrwChqHED8qpVPwLdht3
pIMAnA8+fENCi1XVSlzzIFoPgmmaOMSE
=DUZ2
-----END PGP SIGNATURE-----

> I assume the issue is that Windows is always returning a value even though we expect it not to? (100 is the correct column width in my case.)

This is a bug in the test. Vincent assumes that replacing stdout is enough to isolate the test from the real terminal but on win32 the api isn't called with a file handle.

>>>>> "martin" == Martin Pool <email address hidden> writes:

    >> I assume the issue is that Windows is always returning a value even
    martin> though we expect it not to? (100 is the correct column width in my
    martin> case.)

    martin> This is a bug in the test. Vincent assumes that replacing stdout is
    martin> enough to isolate the test from the real terminal but on win32 the api
    martin> isn't called with a file handle.

Yes, the test is bogus and I've tried to submit a fix for that
only to fail twice at making another test pass on pqm.

I'm working on it.

Changed in bzr:
assignee: nobody → Vincent Ladeuil (vila)
John A Meinel (jameinel) wrote :

Note that for the failing 'terminal_width()' test, there is one more bit of intrigue. Namely doing:
  bzr selftest --subunit | tee ,,text-file.txt

Makes the test pass, because then it *doesn't* have a stdout to check. However just running
 bzr selftest

Without redirecting the output fails.

This will mean that buildbots, etc won't catch this sort of failure, since they will always be redirecting the output to a file.

summary: - Seftest fails to start on Windows
+ Selftest fails to start on Windows
Alexander Belchenko (bialix) wrote :

on Windows terminal_width() using file handle of stderr to get the real terminal size, because stdout is very often redirected (e.g. to pager programs).

Vincent Ladeuil (vila) on 2009-12-09
Changed in bzr:
status: Confirmed → Fix Committed
John A Meinel (jameinel) wrote :

bug was introduced and fixed between b3 and b4

Changed in bzr:
milestone: none → 2.1.0b4
John A Meinel (jameinel) on 2009-12-15
Changed in bzr:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers