diff --git a/CHANGELOG.md b/CHANGELOG.md index 9bcdca4..ea73e8f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/river_core/__init__.py b/river_core/__init__.py index 5a3f36e..34da561 100644 --- a/river_core/__init__.py +++ b/river_core/__init__.py @@ -4,4 +4,4 @@ __author__ = """InCore Semiconductors""" __email__ = 'info@incoresemi.com' -__version__ = '1.9.1' +__version__ = '1.9.2' diff --git a/river_core/utils.py b/river_core/utils.py index 605ca37..0a80492 100644 --- a/river_core/utils.py +++ b/river_core/utils.py @@ -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:' @@ -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(): diff --git a/setup.cfg b/setup.cfg index 2fd6298..54cabab 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 1.9.1 +current_version = 1.9.2 commit = True tag = True diff --git a/setup.py b/setup.py index 0bf70d9..92de2f5 100644 --- a/setup.py +++ b/setup.py @@ -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, )