Skip to content

Commit bb4d8ff

Browse files
committed
Delete unnecessary fix_db2_mac make target (Yelp#254)
1 parent 99cfcf0 commit bb4d8ff

File tree

4 files changed

+39
-14
lines changed

4 files changed

+39
-14
lines changed

Diff for: .travis.yml

+1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ install:
5353
- pip install tox
5454
# normal script supports multiple line syntax
5555
script: |
56+
set -e
5657
make test
5758
./build-dockerfiles.sh
5859

Diff for: Makefile

-10
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,3 @@ clean:
2424
super-clean: clean
2525
rm -rf .tox
2626
rm -rf venv
27-
28-
.PHONY: fix-db2-mac
29-
fix-db2-mac:
30-
# comment out lines for any interpreters that aren't installed on your machine
31-
install_name_tool -change libdb2.dylib $(PROJECT_DIR)/.tox/py27/lib/python2.7/site-packages/clidriver/lib/libdb2.dylib $(PROJECT_DIR)/.tox/py27/lib/python2.7/site-packages/ibm_db.so
32-
install_name_tool -change libbd2.dylib $(PROJECT_DIR)/.tox/py35/lib/python3.5/site-packages/clidriver/lib/libdb2.dylib $(PROJECT_DIR)/.tox/py35/lib/python3.5/site-packages/ibm_db.cpython-35m-darwin.so
33-
install_name_tool -change libbd2.dylib $(PROJECT_DIR)/.tox/py36/lib/python3.6/site-packages/clidriver/lib/libdb2.dylib $(PROJECT_DIR)/.tox/py36/lib/python3.6/site-packages/ibm_db.cpython-36m-darwin.so
34-
install_name_tool -change libdb2.dylib $(PROJECT_DIR)/.tox/py37/lib/python3.7/site-packages/clidriver/lib/libdb2.dylib $(PROJECT_DIR)/.tox/py37/lib/python3.7/site-packages/ibm_db.cpython-37m-darwin.so
35-
install_name_tool -change libdb2.dylib $(PROJECT_DIR)/.tox/pypy/site-packages/clidriver/lib/libdb2.dylib $(PROJECT_DIR)/.tox/pypy/site-packages/ibm_db.pypy-41.so
36-
install_name_tool -change libdb2.dylib $(PROJECT_DIR)/.tox/pypy3/site-packages/clidriver/lib/libdb2.dylib $(PROJECT_DIR)/.tox/pypy3/site-packages/ibm_db.pypy3-71-darwin.so

Diff for: detect_secrets/main.py

+16-3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@
1111
from detect_secrets.util import build_automaton
1212

1313

14+
try:
15+
FileNotFoundError
16+
except NameError: # pragma: no cover
17+
# support python 2.x
18+
FileNotFoundError = IOError
19+
20+
1421
def parse_args(argv):
1522
return ParserBuilder()\
1623
.add_console_use_arguments()\
@@ -198,9 +205,15 @@ def _get_existing_baseline(import_filename):
198205
if import_filename:
199206
try:
200207
return _read_from_file(import_filename[0])
201-
except FileNotFoundError:
202-
# create new baseline if not existed
203-
return None
208+
except FileNotFoundError as fnf_error:
209+
if fnf_error.errno == 2: # create new baseline if not existed
210+
return None
211+
else: # throw exception for other cases
212+
print(
213+
'Error reading from existing baseline ' + import_filename[0],
214+
file=sys.stderr,
215+
)
216+
raise fnf_error
204217
if not sys.stdin.isatty():
205218
stdin = sys.stdin.read().strip()
206219
if stdin:

Diff for: tests/main_test.py

+22-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@
1616
from testing.util import wrap_detect_secrets_main
1717

1818

19+
try:
20+
FileNotFoundError
21+
except NameError: # pragma: no cover
22+
# support python 2.x
23+
FileNotFoundError = IOError
24+
25+
1926
def get_list_of_plugins(include=None, exclude=None):
2027
"""
2128
:type include: List[Dict[str, Any]]
@@ -258,9 +265,11 @@ def test_reads_non_existed_baseline_from_file(
258265
mock_merge_baseline,
259266
mock_baseline_initialize,
260267
):
268+
fnf_error = FileNotFoundError()
269+
fnf_error.errno = 2
261270
with mock_stdin(), mock.patch(
262271
'detect_secrets.main._read_from_file',
263-
side_effect=FileNotFoundError,
272+
side_effect=fnf_error,
264273
) as m_read, mock.patch(
265274
'detect_secrets.main.write_baseline_to_file',
266275
) as m_write:
@@ -282,6 +291,18 @@ def test_reads_non_existed_baseline_from_file(
282291
)
283292
mock_merge_baseline.assert_not_called()
284293

294+
def test_reads_baseline_from_file_with_other_ioerror(
295+
self,
296+
):
297+
io_error = IOError()
298+
with mock_stdin(), mock.patch(
299+
'detect_secrets.main._read_from_file',
300+
side_effect=io_error,
301+
) as m_read:
302+
with pytest.raises(IOError):
303+
main('scan --update non_existed_baseline_file'.split()) == 0
304+
assert m_read.call_args[0][0] == 'non_existed_baseline_file'
305+
285306
@pytest.mark.parametrize(
286307
'exclude_files_arg, expected_regex',
287308
[

0 commit comments

Comments
 (0)