From de3f548025a8ce86fa984aaed530e6419b92c7f4 Mon Sep 17 00:00:00 2001 From: Alexander Todorov Date: Fri, 1 May 2020 13:06:00 +0300 Subject: [PATCH] tests: Compare blueprints as TOML objects, not strings this is to avoid differences in ordering and white space. The same approach is used on rhel7-extras branch. Cherry-picked from 04bc5e9e86c0f815fefae7efc9491724147bbf70 Related: rhbz#1825190 --- test/vm.install | 8 ++++++++ tests/cli/lib/toml-compare | 13 +++++++++++++ tests/cli/test_blueprints_sanity.sh | 3 ++- 3 files changed, 23 insertions(+), 1 deletion(-) create mode 100755 tests/cli/lib/toml-compare diff --git a/test/vm.install b/test/vm.install index 8c1237ce..cc38769c 100755 --- a/test/vm.install +++ b/test/vm.install @@ -19,6 +19,14 @@ if ! rpm -q beakerlib; then yum install -y beakerlib fi +if ! rpm -q python36; then + yum -y install python36 +fi + +if ! rpm -q python3-pytoml; then + yum -y install python3-pytoml +fi + if ! rpm -q git; then yum install -y git fi diff --git a/tests/cli/lib/toml-compare b/tests/cli/lib/toml-compare new file mode 100755 index 00000000..82223c93 --- /dev/null +++ b/tests/cli/lib/toml-compare @@ -0,0 +1,13 @@ +#!/usr/bin/env python3 + +import sys +import pytoml as toml + +if len(sys.argv) != 3: + print("USAGE: ", __file__, " ") + sys.exit(1) + +blueprint_one = toml.loads(open(sys.argv[1]).read()) +blueprint_two = toml.loads(open(sys.argv[2]).read()) + +assert blueprint_one == blueprint_two diff --git a/tests/cli/test_blueprints_sanity.sh b/tests/cli/test_blueprints_sanity.sh index 2bdf458f..881afe87 100755 --- a/tests/cli/test_blueprints_sanity.sh +++ b/tests/cli/test_blueprints_sanity.sh @@ -52,7 +52,8 @@ __EOF__ rlPhaseEnd rlPhaseStartTest "blueprints show" - rlAssertEquals "show displays blueprint in TOML" "`$CLI blueprints show $BLUEPRINT_NAME`" "`cat $BLUEPRINT_NAME.toml`" + $CLI blueprints show $BLUEPRINT_NAME > shown-$BLUEPRINT_NAME.toml + rlRun -t -c "$(dirname $0)/lib/toml-compare $BLUEPRINT_NAME.toml shown-$BLUEPRINT_NAME.toml" rlPhaseEnd rlPhaseStartTest "SemVer .patch version is incremented automatically"