Skip to content

Commit

Permalink
FIxed conditional commit log compare (#26)
Browse files Browse the repository at this point in the history
* fixed missing line bug

* added missing entry guard for file1 too

* comments

* Bump version: 1.9.0 → 1.9.1

* removed status initialization to catch more false positives

* updated CHANGELOG

* fixed sys_command_file function

* updated CHANGELOG

* Bump version: 1.9.1 → 1.9.2

* catch all command run errors

* use errcode
  • Loading branch information
edwin7026 authored Aug 24, 2024
1 parent 039beec commit 4c6e180
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 20 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.9.1] - 2024-07-20
## [1.9.2] - 2024-08-24
- fixed compare_dump to conditionally compare commit dump sections

## [1.9.1] - 2024-08-20
- fixed compare_dump functions to take care of missing entries in dumps

## [1.9.0] - 2024-07-10
Expand Down
2 changes: 1 addition & 1 deletion river_core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@

__author__ = """InCore Semiconductors"""
__email__ = '[email protected]'
__version__ = '1.9.1'
__version__ = '1.9.2'
49 changes: 33 additions & 16 deletions river_core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,28 @@ def compare_dumps(file1, file2, start_hex=''):
if start_hex == '':
cmd = f'diff -iw {file1} {file2}'
else:
cmd = f"diff -iw <(sed -n '/{start_hex}/,$p' {file1}) <(sed -n '/{start_hex}/,$p' {file2})"
trim_cmd = "sed -n \'/{start_hex} (/,$p\' {file}"

file1_trimmed = file1 + '_trimmed'
file2_trimmed = file2 + '_trimmed'

cmd1 = trim_cmd.format(start_hex = start_hex, file=file1)
code = sys_command_file(cmd1, filename=file1_trimmed)
if code[0]:
assert False, f"{cmd1} has failed with code {code}"

cmd2 = trim_cmd.format(start_hex = start_hex, file=file2)
code = sys_command_file(cmd2, filename=file2_trimmed)
if code[0]:
assert False, f"{cmd2} has failed with code {code}"

cmd = f'diff -iw {file1_trimmed} {file2_trimmed}'

errcode, rout, rerr = sys_command(cmd, logging=False)

if errcode:
assert False, f"{cmd} has failed with\n{rerr}"

if errcode != 0 and rout!='':

rout += '\nMismatch infos:'
Expand Down Expand Up @@ -464,22 +483,20 @@ def sys_command_file(command, filename, timeout=500):
:rtype: list
'''
cmd = command.split(' ')
cmd = [x.strip(' ') for x in cmd]
cmd = [i for i in cmd if i]
logger.warning('$ {0} > {1}'.format(' '.join(cmd), filename))
fp = open(filename, 'w')
x = subprocess.Popen(cmd, stdout=fp, stderr=fp)
timer = Timer(timeout, x.kill)
try:
timer.start()
stdout, stderr = x.communicate()
finally:
timer.cancel()

fp.close()
cmd = shlex.split(command)

logger.debug('$ {0} > {1}'.format(' '.join(cmd), filename))

with open(filename, 'w') as fp:
with subprocess.Popen(cmd, stdout=fp, stderr=fp) as process:
timer = Timer(timeout, process.kill)
try:
timer.start()
stdout, stderr = process.communicate()
finally:
timer.cancel()

return (x.returncode, None, None)
return (process.returncode, None, None)


class makeUtil():
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 1.9.1
current_version = 1.9.2
commit = True
tag = True

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,6 @@ def read_requires():
tests_require=test_requirements,
url=
'https://github.com/incoresemi/river_core',
version='1.9.1',
version='1.9.2',
zip_safe=False,
)

0 comments on commit 4c6e180

Please sign in to comment.