proxygen
gtest_throw_on_failure_test.ThrowOnFailureTest Class Reference
Inheritance diagram for gtest_throw_on_failure_test.ThrowOnFailureTest:

Public Member Functions

def RunAndVerify (self, env_var_value, flag_value, should_fail)
 
def testDefaultBehavior (self)
 
def testThrowOnFailureEnvVar (self)
 
def testThrowOnFailureFlag (self)
 
def testThrowOnFailureFlagOverridesEnvVar (self)
 
def RunAndVerify (self, env_var_value, flag_value, should_fail)
 
def testDefaultBehavior (self)
 
def testThrowOnFailureEnvVar (self)
 
def testThrowOnFailureFlag (self)
 
def testThrowOnFailureFlagOverridesEnvVar (self)
 
def RunAndVerify (self, env_var_value, flag_value, should_fail)
 
def testDefaultBehavior (self)
 
def testThrowOnFailureEnvVar (self)
 
def testThrowOnFailureFlag (self)
 
def testThrowOnFailureFlagOverridesEnvVar (self)
 

Detailed Description

Tests the throw-on-failure mode.

Definition at line 80 of file gtest_throw_on_failure_test.py.

Member Function Documentation

def gtest_throw_on_failure_test.ThrowOnFailureTest.RunAndVerify (   self,
  env_var_value,
  flag_value,
  should_fail 
)
Runs gtest_throw_on_failure_test_ and verifies that it does
(or does not) exit with a non-zero code.

Args:
  env_var_value:    value of the GTEST_BREAK_ON_FAILURE environment
                variable; None if the variable should be unset.
  flag_value:       value of the --gtest_break_on_failure flag;
                None if the flag should not be present.
  should_fail:      True iff the program is expected to fail.

Definition at line 83 of file gtest_throw_on_failure_test.py.

References join, gtest_throw_on_failure_test.Run(), and gtest_throw_on_failure_test.SetEnvVar().

Referenced by gtest_throw_on_failure_test.ThrowOnFailureTest.RunAndVerify(), gtest_throw_on_failure_test.ThrowOnFailureTest.testDefaultBehavior(), gtest_throw_on_failure_test.ThrowOnFailureTest.testThrowOnFailureEnvVar(), gtest_throw_on_failure_test.ThrowOnFailureTest.testThrowOnFailureFlag(), and gtest_throw_on_failure_test.ThrowOnFailureTest.testThrowOnFailureFlagOverridesEnvVar().

83  def RunAndVerify(self, env_var_value, flag_value, should_fail):
84  """Runs gtest_throw_on_failure_test_ and verifies that it does
85  (or does not) exit with a non-zero code.
86 
87  Args:
88  env_var_value: value of the GTEST_BREAK_ON_FAILURE environment
89  variable; None if the variable should be unset.
90  flag_value: value of the --gtest_break_on_failure flag;
91  None if the flag should not be present.
92  should_fail: True iff the program is expected to fail.
93  """
94 
95  SetEnvVar(THROW_ON_FAILURE, env_var_value)
96 
97  if env_var_value is None:
98  env_var_value_msg = ' is not set'
99  else:
100  env_var_value_msg = '=' + env_var_value
101 
102  if flag_value is None:
103  flag = ''
104  elif flag_value == '0':
105  flag = '--%s=0' % THROW_ON_FAILURE
106  else:
107  flag = '--%s' % THROW_ON_FAILURE
108 
109  command = [EXE_PATH]
110  if flag:
111  command.append(flag)
112 
113  if should_fail:
114  should_or_not = 'should'
115  else:
116  should_or_not = 'should not'
117 
118  failed = not Run(command)
119 
120  SetEnvVar(THROW_ON_FAILURE, None)
121 
122  msg = ('when %s%s, an assertion failure in "%s" %s cause a non-zero '
123  'exit code.' %
124  (THROW_ON_FAILURE, env_var_value_msg, ' '.join(command),
125  should_or_not))
126  self.assert_(failed == should_fail, msg)
127 
def RunAndVerify(self, env_var_value, flag_value, should_fail)
#define join
def gtest_throw_on_failure_test.ThrowOnFailureTest.RunAndVerify (   self,
  env_var_value,
  flag_value,
  should_fail 
)
Runs gtest_throw_on_failure_test_ and verifies that it does
(or does not) exit with a non-zero code.

Args:
  env_var_value:    value of the GTEST_BREAK_ON_FAILURE environment
                variable; None if the variable should be unset.
  flag_value:       value of the --gtest_break_on_failure flag;
                None if the flag should not be present.
  should_fail:      True iff the program is expected to fail.

Definition at line 83 of file gtest_throw_on_failure_test.py.

References join, gtest_throw_on_failure_test.Run(), gtest_throw_on_failure_test.ThrowOnFailureTest.RunAndVerify(), and gtest_throw_on_failure_test.SetEnvVar().

83  def RunAndVerify(self, env_var_value, flag_value, should_fail):
84  """Runs gtest_throw_on_failure_test_ and verifies that it does
85  (or does not) exit with a non-zero code.
86 
87  Args:
88  env_var_value: value of the GTEST_BREAK_ON_FAILURE environment
89  variable; None if the variable should be unset.
90  flag_value: value of the --gtest_break_on_failure flag;
91  None if the flag should not be present.
92  should_fail: True iff the program is expected to fail.
93  """
94 
95  SetEnvVar(THROW_ON_FAILURE, env_var_value)
96 
97  if env_var_value is None:
98  env_var_value_msg = ' is not set'
99  else:
100  env_var_value_msg = '=' + env_var_value
101 
102  if flag_value is None:
103  flag = ''
104  elif flag_value == '0':
105  flag = '--%s=0' % THROW_ON_FAILURE
106  else:
107  flag = '--%s' % THROW_ON_FAILURE
108 
109  command = [EXE_PATH]
110  if flag:
111  command.append(flag)
112 
113  if should_fail:
114  should_or_not = 'should'
115  else:
116  should_or_not = 'should not'
117 
118  failed = not Run(command)
119 
120  SetEnvVar(THROW_ON_FAILURE, None)
121 
122  msg = ('when %s%s, an assertion failure in "%s" %s cause a non-zero '
123  'exit code.' %
124  (THROW_ON_FAILURE, env_var_value_msg, ' '.join(command),
125  should_or_not))
126  self.assert_(failed == should_fail, msg)
127 
def RunAndVerify(self, env_var_value, flag_value, should_fail)
#define join
def gtest_throw_on_failure_test.ThrowOnFailureTest.RunAndVerify (   self,
  env_var_value,
  flag_value,
  should_fail 
)
Runs gtest_throw_on_failure_test_ and verifies that it does
(or does not) exit with a non-zero code.

Args:
  env_var_value:    value of the GTEST_BREAK_ON_FAILURE environment
                variable; None if the variable should be unset.
  flag_value:       value of the --gtest_break_on_failure flag;
                None if the flag should not be present.
  should_fail:      True iff the program is expected to fail.

Definition at line 83 of file gtest_throw_on_failure_test.py.

References join, gtest_throw_on_failure_test.Run(), gtest_throw_on_failure_test.ThrowOnFailureTest.RunAndVerify(), and gtest_throw_on_failure_test.SetEnvVar().

83  def RunAndVerify(self, env_var_value, flag_value, should_fail):
84  """Runs gtest_throw_on_failure_test_ and verifies that it does
85  (or does not) exit with a non-zero code.
86 
87  Args:
88  env_var_value: value of the GTEST_BREAK_ON_FAILURE environment
89  variable; None if the variable should be unset.
90  flag_value: value of the --gtest_break_on_failure flag;
91  None if the flag should not be present.
92  should_fail: True iff the program is expected to fail.
93  """
94 
95  SetEnvVar(THROW_ON_FAILURE, env_var_value)
96 
97  if env_var_value is None:
98  env_var_value_msg = ' is not set'
99  else:
100  env_var_value_msg = '=' + env_var_value
101 
102  if flag_value is None:
103  flag = ''
104  elif flag_value == '0':
105  flag = '--%s=0' % THROW_ON_FAILURE
106  else:
107  flag = '--%s' % THROW_ON_FAILURE
108 
109  command = [EXE_PATH]
110  if flag:
111  command.append(flag)
112 
113  if should_fail:
114  should_or_not = 'should'
115  else:
116  should_or_not = 'should not'
117 
118  failed = not Run(command)
119 
120  SetEnvVar(THROW_ON_FAILURE, None)
121 
122  msg = ('when %s%s, an assertion failure in "%s" %s cause a non-zero '
123  'exit code.' %
124  (THROW_ON_FAILURE, env_var_value_msg, ' '.join(command),
125  should_or_not))
126  self.assert_(failed == should_fail, msg)
127 
def RunAndVerify(self, env_var_value, flag_value, should_fail)
#define join
def gtest_throw_on_failure_test.ThrowOnFailureTest.testDefaultBehavior (   self)
def gtest_throw_on_failure_test.ThrowOnFailureTest.testDefaultBehavior (   self)
def gtest_throw_on_failure_test.ThrowOnFailureTest.testDefaultBehavior (   self)
def gtest_throw_on_failure_test.ThrowOnFailureTest.testThrowOnFailureEnvVar (   self)
Tests using the GTEST_THROW_ON_FAILURE environment variable.

Definition at line 133 of file gtest_throw_on_failure_test.py.

References gtest_throw_on_failure_test.ThrowOnFailureTest.RunAndVerify(), gtest_break_on_failure_unittest.GTestBreakOnFailureUnitTest.RunAndVerify(), gtest_list_tests_unittest.GTestListTestsUnitTest.RunAndVerify(), gtest_filter_unittest.GTestFilterUnitTest.RunAndVerify(), and gtest_throw_on_failure_test.ThrowOnFailureTest.testThrowOnFailureEnvVar().

134  """Tests using the GTEST_THROW_ON_FAILURE environment variable."""
135 
136  self.RunAndVerify(env_var_value='0',
137  flag_value=None,
138  should_fail=False)
139  self.RunAndVerify(env_var_value='1',
140  flag_value=None,
141  should_fail=True)
142 
def RunAndVerify(self, env_var_value, flag_value, should_fail)
def gtest_throw_on_failure_test.ThrowOnFailureTest.testThrowOnFailureEnvVar (   self)
Tests using the GTEST_THROW_ON_FAILURE environment variable.

Definition at line 133 of file gtest_throw_on_failure_test.py.

References gtest_throw_on_failure_test.ThrowOnFailureTest.RunAndVerify(), gtest_break_on_failure_unittest.GTestBreakOnFailureUnitTest.RunAndVerify(), gtest_list_tests_unittest.GTestListTestsUnitTest.RunAndVerify(), gtest_filter_unittest.GTestFilterUnitTest.RunAndVerify(), and gtest_throw_on_failure_test.ThrowOnFailureTest.testThrowOnFailureEnvVar().

134  """Tests using the GTEST_THROW_ON_FAILURE environment variable."""
135 
136  self.RunAndVerify(env_var_value='0',
137  flag_value=None,
138  should_fail=False)
139  self.RunAndVerify(env_var_value='1',
140  flag_value=None,
141  should_fail=True)
142 
def RunAndVerify(self, env_var_value, flag_value, should_fail)
def gtest_throw_on_failure_test.ThrowOnFailureTest.testThrowOnFailureEnvVar (   self)
Tests using the GTEST_THROW_ON_FAILURE environment variable.

Definition at line 133 of file gtest_throw_on_failure_test.py.

References gtest_throw_on_failure_test.ThrowOnFailureTest.RunAndVerify(), gtest_break_on_failure_unittest.GTestBreakOnFailureUnitTest.RunAndVerify(), gtest_list_tests_unittest.GTestListTestsUnitTest.RunAndVerify(), and gtest_filter_unittest.GTestFilterUnitTest.RunAndVerify().

Referenced by gtest_throw_on_failure_test.ThrowOnFailureTest.testThrowOnFailureEnvVar().

134  """Tests using the GTEST_THROW_ON_FAILURE environment variable."""
135 
136  self.RunAndVerify(env_var_value='0',
137  flag_value=None,
138  should_fail=False)
139  self.RunAndVerify(env_var_value='1',
140  flag_value=None,
141  should_fail=True)
142 
def RunAndVerify(self, env_var_value, flag_value, should_fail)
def gtest_throw_on_failure_test.ThrowOnFailureTest.testThrowOnFailureFlag (   self)
Tests using the --gtest_throw_on_failure flag.

Definition at line 143 of file gtest_throw_on_failure_test.py.

References gtest_throw_on_failure_test.ThrowOnFailureTest.RunAndVerify(), gtest_break_on_failure_unittest.GTestBreakOnFailureUnitTest.RunAndVerify(), gtest_list_tests_unittest.GTestListTestsUnitTest.RunAndVerify(), gtest_filter_unittest.GTestFilterUnitTest.RunAndVerify(), and gtest_throw_on_failure_test.ThrowOnFailureTest.testThrowOnFailureFlag().

144  """Tests using the --gtest_throw_on_failure flag."""
145 
146  self.RunAndVerify(env_var_value=None,
147  flag_value='0',
148  should_fail=False)
149  self.RunAndVerify(env_var_value=None,
150  flag_value='1',
151  should_fail=True)
152 
def RunAndVerify(self, env_var_value, flag_value, should_fail)
def gtest_throw_on_failure_test.ThrowOnFailureTest.testThrowOnFailureFlag (   self)
Tests using the --gtest_throw_on_failure flag.

Definition at line 143 of file gtest_throw_on_failure_test.py.

References gtest_throw_on_failure_test.ThrowOnFailureTest.RunAndVerify(), gtest_break_on_failure_unittest.GTestBreakOnFailureUnitTest.RunAndVerify(), gtest_list_tests_unittest.GTestListTestsUnitTest.RunAndVerify(), and gtest_filter_unittest.GTestFilterUnitTest.RunAndVerify().

Referenced by gtest_throw_on_failure_test.ThrowOnFailureTest.testThrowOnFailureFlag().

144  """Tests using the --gtest_throw_on_failure flag."""
145 
146  self.RunAndVerify(env_var_value=None,
147  flag_value='0',
148  should_fail=False)
149  self.RunAndVerify(env_var_value=None,
150  flag_value='1',
151  should_fail=True)
152 
def RunAndVerify(self, env_var_value, flag_value, should_fail)
def gtest_throw_on_failure_test.ThrowOnFailureTest.testThrowOnFailureFlag (   self)
Tests using the --gtest_throw_on_failure flag.

Definition at line 143 of file gtest_throw_on_failure_test.py.

References gtest_throw_on_failure_test.ThrowOnFailureTest.RunAndVerify(), gtest_break_on_failure_unittest.GTestBreakOnFailureUnitTest.RunAndVerify(), gtest_list_tests_unittest.GTestListTestsUnitTest.RunAndVerify(), gtest_filter_unittest.GTestFilterUnitTest.RunAndVerify(), and gtest_throw_on_failure_test.ThrowOnFailureTest.testThrowOnFailureFlag().

144  """Tests using the --gtest_throw_on_failure flag."""
145 
146  self.RunAndVerify(env_var_value=None,
147  flag_value='0',
148  should_fail=False)
149  self.RunAndVerify(env_var_value=None,
150  flag_value='1',
151  should_fail=True)
152 
def RunAndVerify(self, env_var_value, flag_value, should_fail)
def gtest_throw_on_failure_test.ThrowOnFailureTest.testThrowOnFailureFlagOverridesEnvVar (   self)
Tests that --gtest_throw_on_failure overrides GTEST_THROW_ON_FAILURE.

Definition at line 153 of file gtest_throw_on_failure_test.py.

References gtest_test_utils.Main(), gtest_throw_on_failure_test.ThrowOnFailureTest.RunAndVerify(), gtest_break_on_failure_unittest.GTestBreakOnFailureUnitTest.RunAndVerify(), gtest_list_tests_unittest.GTestListTestsUnitTest.RunAndVerify(), gtest_filter_unittest.GTestFilterUnitTest.RunAndVerify(), and gtest_throw_on_failure_test.ThrowOnFailureTest.testThrowOnFailureFlagOverridesEnvVar().

154  """Tests that --gtest_throw_on_failure overrides GTEST_THROW_ON_FAILURE."""
155 
156  self.RunAndVerify(env_var_value='0',
157  flag_value='0',
158  should_fail=False)
159  self.RunAndVerify(env_var_value='0',
160  flag_value='1',
161  should_fail=True)
162  self.RunAndVerify(env_var_value='1',
163  flag_value='0',
164  should_fail=False)
165  self.RunAndVerify(env_var_value='1',
166  flag_value='1',
167  should_fail=True)
168 
169 
def RunAndVerify(self, env_var_value, flag_value, should_fail)
def gtest_throw_on_failure_test.ThrowOnFailureTest.testThrowOnFailureFlagOverridesEnvVar (   self)
Tests that --gtest_throw_on_failure overrides GTEST_THROW_ON_FAILURE.

Definition at line 153 of file gtest_throw_on_failure_test.py.

References gtest_test_utils.Main(), gtest_throw_on_failure_test.ThrowOnFailureTest.RunAndVerify(), gtest_break_on_failure_unittest.GTestBreakOnFailureUnitTest.RunAndVerify(), gtest_list_tests_unittest.GTestListTestsUnitTest.RunAndVerify(), gtest_filter_unittest.GTestFilterUnitTest.RunAndVerify(), and gtest_throw_on_failure_test.ThrowOnFailureTest.testThrowOnFailureFlagOverridesEnvVar().

154  """Tests that --gtest_throw_on_failure overrides GTEST_THROW_ON_FAILURE."""
155 
156  self.RunAndVerify(env_var_value='0',
157  flag_value='0',
158  should_fail=False)
159  self.RunAndVerify(env_var_value='0',
160  flag_value='1',
161  should_fail=True)
162  self.RunAndVerify(env_var_value='1',
163  flag_value='0',
164  should_fail=False)
165  self.RunAndVerify(env_var_value='1',
166  flag_value='1',
167  should_fail=True)
168 
169 
def RunAndVerify(self, env_var_value, flag_value, should_fail)
def gtest_throw_on_failure_test.ThrowOnFailureTest.testThrowOnFailureFlagOverridesEnvVar (   self)
Tests that --gtest_throw_on_failure overrides GTEST_THROW_ON_FAILURE.

Definition at line 153 of file gtest_throw_on_failure_test.py.

References gtest_test_utils.Main(), gtest_throw_on_failure_test.ThrowOnFailureTest.RunAndVerify(), gtest_break_on_failure_unittest.GTestBreakOnFailureUnitTest.RunAndVerify(), gtest_list_tests_unittest.GTestListTestsUnitTest.RunAndVerify(), and gtest_filter_unittest.GTestFilterUnitTest.RunAndVerify().

Referenced by gtest_throw_on_failure_test.ThrowOnFailureTest.testThrowOnFailureFlagOverridesEnvVar().

154  """Tests that --gtest_throw_on_failure overrides GTEST_THROW_ON_FAILURE."""
155 
156  self.RunAndVerify(env_var_value='0',
157  flag_value='0',
158  should_fail=False)
159  self.RunAndVerify(env_var_value='0',
160  flag_value='1',
161  should_fail=True)
162  self.RunAndVerify(env_var_value='1',
163  flag_value='0',
164  should_fail=False)
165  self.RunAndVerify(env_var_value='1',
166  flag_value='1',
167  should_fail=True)
168 
169 
def RunAndVerify(self, env_var_value, flag_value, should_fail)

The documentation for this class was generated from the following file: