From 323ef3623bcd29ae8872ed3afe9961c93b7e2026 Mon Sep 17 00:00:00 2001 From: Cameron Hummels Date: Sat, 2 May 2020 14:44:53 -0700 Subject: [PATCH 1/6] Fixing gold standard script to work with circle ci --- tests/gold_standard_versions.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/tests/gold_standard_versions.py b/tests/gold_standard_versions.py index a2e3bd657b..a7b766bdf6 100644 --- a/tests/gold_standard_versions.py +++ b/tests/gold_standard_versions.py @@ -13,22 +13,25 @@ from trident import path as trident_path import os +import re def get_gold_standard_version(): - f = open(os.path.join(trident_path, '../.travis.yml'), 'r') + f = open(os.path.join(trident_path, '../.circleci/config.yml'), 'r') for line in f: line = line.lstrip() - if line.startswith('YT_GOLD'): - line_list = line.split('=') - yt_gold = line_list[1] - if line.startswith('TRIDENT_GOLD'): - line_list = line.split('=') - trident_gold = line_list[1] + pattern_YT = "echo 'YT_GOLD=(\S+)'" + pattern_trident = "echo 'TRIDENT_GOLD=(\S+)'" + match_YT = re.search(pattern_YT, line) + match_trident = re.search(pattern_trident, line) + if match_YT: + yt_gold = match_YT.group(1) + if match_trident: + trident_gold = match_trident.group(1) f.close() print() print('Latest Gold Standard Commit Tags\n') - print('yt = %s' % yt_gold, end='') - print('Trident = %s' % trident_gold) + print('yt = %s' % yt_gold) + print('Trident = %s\n' % trident_gold) print('To update to them, `git checkout ` in appropriate repository') From 1e2e809c89c0d023d793d8db96e65f449225cf77 Mon Sep 17 00:00:00 2001 From: Cameron Hummels Date: Wed, 6 May 2020 15:41:53 -0700 Subject: [PATCH 2/6] Adding assertions to test success of gold standard versions. --- tests/gold_standard_versions.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/gold_standard_versions.py b/tests/gold_standard_versions.py index a7b766bdf6..3bdc45e58e 100644 --- a/tests/gold_standard_versions.py +++ b/tests/gold_standard_versions.py @@ -17,6 +17,8 @@ def get_gold_standard_version(): f = open(os.path.join(trident_path, '../.circleci/config.yml'), 'r') + yt_gold = None + trident_gold = None for line in f: line = line.lstrip() pattern_YT = "echo 'YT_GOLD=(\S+)'" @@ -33,7 +35,8 @@ def get_gold_standard_version(): print('yt = %s' % yt_gold) print('Trident = %s\n' % trident_gold) print('To update to them, `git checkout ` in appropriate repository') - + assert(yt_gold is not None) + assert(trident_gold is not None) if __name__ == "__main__": get_gold_standard_version() From a9c38223e7d358d457d6f6c7a458626e8d66462a Mon Sep 17 00:00:00 2001 From: Cameron Hummels Date: Wed, 6 May 2020 15:43:02 -0700 Subject: [PATCH 3/6] Making regex raw strings to avoid problems. --- tests/gold_standard_versions.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/gold_standard_versions.py b/tests/gold_standard_versions.py index 3bdc45e58e..5e92c9a050 100644 --- a/tests/gold_standard_versions.py +++ b/tests/gold_standard_versions.py @@ -21,8 +21,8 @@ def get_gold_standard_version(): trident_gold = None for line in f: line = line.lstrip() - pattern_YT = "echo 'YT_GOLD=(\S+)'" - pattern_trident = "echo 'TRIDENT_GOLD=(\S+)'" + pattern_YT = r"echo 'YT_GOLD=(\S+)'" + pattern_trident = r"echo 'TRIDENT_GOLD=(\S+)'" match_YT = re.search(pattern_YT, line) match_trident = re.search(pattern_trident, line) if match_YT: From 560583771c1f9bcd0a038b45cbc626da08825325 Mon Sep 17 00:00:00 2001 From: Cameron Hummels Date: Wed, 6 May 2020 15:45:43 -0700 Subject: [PATCH 4/6] Adding test for gold standard code. --- tests/test_gold.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 tests/test_gold.py diff --git a/tests/test_gold.py b/tests/test_gold.py new file mode 100644 index 0000000000..7c298e56e5 --- /dev/null +++ b/tests/test_gold.py @@ -0,0 +1,19 @@ +""" +Unit test for download_file function +""" + +#----------------------------------------------------------------------------- +# Copyright (c) 2017, Trident Development Team. +# +# Distributed under the terms of the Modified BSD License. +# +# The full license is in the file LICENSE, distributed with this software. +#----------------------------------------------------------------------------- + +import os + +from gold_standard_versions import \ + get_gold_standard_version + +def test_gold_standard_versions(): + get_gold_standard_version() From 7a7b3b3c2191e4ada78539455a955d2141488d28 Mon Sep 17 00:00:00 2001 From: Cameron Hummels Date: Wed, 6 May 2020 15:46:50 -0700 Subject: [PATCH 5/6] Fixing header --- tests/test_gold.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_gold.py b/tests/test_gold.py index 7c298e56e5..60915f690b 100644 --- a/tests/test_gold.py +++ b/tests/test_gold.py @@ -1,5 +1,5 @@ """ -Unit test for download_file function +Unit test for get_gold_standard_version function """ #----------------------------------------------------------------------------- From 28596c17f2756d5fcf76a9985d6db88390df23fe Mon Sep 17 00:00:00 2001 From: Cameron Hummels Date: Wed, 6 May 2020 16:35:50 -0700 Subject: [PATCH 6/6] Fixing flake tests. --- tests/gold_standard_versions.py | 1 + tests/test_gold.py | 2 -- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/gold_standard_versions.py b/tests/gold_standard_versions.py index 5e92c9a050..d1618c133c 100644 --- a/tests/gold_standard_versions.py +++ b/tests/gold_standard_versions.py @@ -38,5 +38,6 @@ def get_gold_standard_version(): assert(yt_gold is not None) assert(trident_gold is not None) + if __name__ == "__main__": get_gold_standard_version() diff --git a/tests/test_gold.py b/tests/test_gold.py index 60915f690b..ff72b72db6 100644 --- a/tests/test_gold.py +++ b/tests/test_gold.py @@ -10,8 +10,6 @@ # The full license is in the file LICENSE, distributed with this software. #----------------------------------------------------------------------------- -import os - from gold_standard_versions import \ get_gold_standard_version