~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/blackbox/test_script.py

  • Committer: Andrew Bennetts
  • Date: 2010-10-08 08:15:14 UTC
  • mto: This revision was merged to the branch mainline in revision 5498.
  • Revision ID: andrew.bennetts@canonical.com-20101008081514-dviqzrdfwyzsqbz2
Split NEWS into per-release doc/en/release-notes/bzr-*.txt

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2010, 2016 Canonical Ltd
2
 
#
3
 
# This program is free software; you can redistribute it and/or modify
4
 
# it under the terms of the GNU General Public License as published by
5
 
# the Free Software Foundation; either version 2 of the License, or
6
 
# (at your option) any later version.
7
 
#
8
 
# This program is distributed in the hope that it will be useful,
9
 
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
 
# GNU General Public License for more details.
12
 
#
13
 
# You should have received a copy of the GNU General Public License
14
 
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
 
 
17
 
"""Blacbox tests for the test-script command."""
18
 
 
19
 
import os
20
 
 
21
 
from bzrlib import (
22
 
    tests,
23
 
    )
24
 
from bzrlib.tests import (
25
 
    script,
26
 
    )
27
 
 
28
 
 
29
 
class TestTestScript(tests.TestCaseInTempDir):
30
 
 
31
 
    def test_unknnown_file(self):
32
 
        self.run_bzr(['test-script', 'I-do-not-exist'], retcode=3)
33
 
 
34
 
    def test_empty_file(self):
35
 
        self.build_tree_contents([('script', '')])
36
 
        out, err = self.run_bzr(['test-script', 'script'])
37
 
        out_lines = out.splitlines()
38
 
        self.assertStartsWith(out_lines[-3], 'Ran 1 test in ')
39
 
        self.assertEqual('OK', out_lines[-1])
40
 
        self.assertEqual('', err)
41
 
 
42
 
    def test_simple_file(self):
43
 
        self.build_tree_contents([('script', '''
44
 
$ echo hello world
45
 
hello world
46
 
''')])
47
 
        out, err = self.run_bzr(['test-script', 'script'])
48
 
        out_lines = out.splitlines()
49
 
        self.assertStartsWith(out_lines[-3], 'Ran 1 test in ')
50
 
        self.assertEqual('OK', out_lines[-1])
51
 
        self.assertEqual('', err)
52
 
 
53
 
    def test_null_output(self):
54
 
        self.build_tree_contents([('script', '''
55
 
$ echo hello world
56
 
''')])
57
 
        out, err = self.run_bzr(['test-script', 'script', '--null-output'])
58
 
        out_lines = out.splitlines()
59
 
        self.assertStartsWith(out_lines[-3], 'Ran 1 test in ')
60
 
        self.assertEqual('OK', out_lines[-1])
61
 
        self.assertEqual('', err)
62
 
 
63
 
    def test_failing_script(self):
64
 
        self.build_tree_contents([('script', '''
65
 
$ echo hello foo
66
 
hello bar
67
 
''')])
68
 
        out, err = self.run_bzr(['test-script', 'script'], retcode=1)
69
 
        out_lines = out.splitlines()
70
 
        self.assertStartsWith(out_lines[-3], 'Ran 1 test in ')
71
 
        self.assertEqual('FAILED (failures=1)', out_lines[-1])
72
 
        self.assertEqual('', err)