tesseract v5.3.3.20231005
googletest-throw-on-failure-test.ThrowOnFailureTest Class Reference
Inheritance diagram for googletest-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)
 

Detailed Description

Tests the throw-on-failure mode.

Definition at line 77 of file googletest-throw-on-failure-test.py.

Member Function Documentation

◆ RunAndVerify()

def googletest-throw-on-failure-test.ThrowOnFailureTest.RunAndVerify (   self,
  env_var_value,
  flag_value,
  should_fail 
)
Runs googletest-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 if and only if the program is expected to fail.

Definition at line 80 of file googletest-throw-on-failure-test.py.

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

◆ testDefaultBehavior()

def googletest-throw-on-failure-test.ThrowOnFailureTest.testDefaultBehavior (   self)
Tests the behavior of the default mode.

Definition at line 125 of file googletest-throw-on-failure-test.py.

125 def testDefaultBehavior(self):
126 """Tests the behavior of the default mode."""
127
128 self.RunAndVerify(env_var_value=None, flag_value=None, should_fail=False)
129

◆ testThrowOnFailureEnvVar()

def googletest-throw-on-failure-test.ThrowOnFailureTest.testThrowOnFailureEnvVar (   self)
Tests using the GTEST_THROW_ON_FAILURE environment variable.

Definition at line 130 of file googletest-throw-on-failure-test.py.

130 def testThrowOnFailureEnvVar(self):
131 """Tests using the GTEST_THROW_ON_FAILURE environment variable."""
132
133 self.RunAndVerify(env_var_value='0',
134 flag_value=None,
135 should_fail=False)
136 self.RunAndVerify(env_var_value='1',
137 flag_value=None,
138 should_fail=True)
139

◆ testThrowOnFailureFlag()

def googletest-throw-on-failure-test.ThrowOnFailureTest.testThrowOnFailureFlag (   self)
Tests using the --gtest_throw_on_failure flag.

Definition at line 140 of file googletest-throw-on-failure-test.py.

140 def testThrowOnFailureFlag(self):
141 """Tests using the --gtest_throw_on_failure flag."""
142
143 self.RunAndVerify(env_var_value=None,
144 flag_value='0',
145 should_fail=False)
146 self.RunAndVerify(env_var_value=None,
147 flag_value='1',
148 should_fail=True)
149

◆ testThrowOnFailureFlagOverridesEnvVar()

def googletest-throw-on-failure-test.ThrowOnFailureTest.testThrowOnFailureFlagOverridesEnvVar (   self)
Tests that --gtest_throw_on_failure overrides GTEST_THROW_ON_FAILURE.

Definition at line 150 of file googletest-throw-on-failure-test.py.

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

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