diff options
author | Benjamin Schubert <ben.c.schubert@gmail.com> | 2019-06-28 17:01:23 +0100 |
---|---|---|
committer | bst-marge-bot <marge-bot@buildstream.build> | 2019-07-15 14:14:03 +0000 |
commit | f7b461220ec2f1af3966ace12c21334f1f3b6457 (patch) | |
tree | 2a3bb23cb1f26aa55fac6d5df2f95fb862755685 /tests/format | |
parent | 9e5facfab87268a80cb02f2de87897764a416c8a (diff) | |
download | buildstream-f7b461220ec2f1af3966ace12c21334f1f3b6457.tar.gz |
tests: Change all calls to _yaml.dump to _yaml.rountrip_dump
Now that both are equivalent, we can skip the sanitization part before
the yaml call.
Diffstat (limited to 'tests/format')
-rw-r--r-- | tests/format/include.py | 4 | ||||
-rw-r--r-- | tests/format/include_composition.py | 87 | ||||
-rw-r--r-- | tests/format/junctions.py | 8 | ||||
-rw-r--r-- | tests/format/project.py | 2 | ||||
-rw-r--r-- | tests/format/variables.py | 10 |
5 files changed, 51 insertions, 60 deletions
diff --git a/tests/format/include.py b/tests/format/include.py index e2e16c34a..3bb4e4d51 100644 --- a/tests/format/include.py +++ b/tests/format/include.py @@ -126,7 +126,7 @@ def test_junction_element_partial_project_project(cli, tmpdir, datafiles): repo.source_config(ref=ref) ] } - _yaml.dump(element, junction_path) + _yaml.roundtrip_dump(element, junction_path) result = cli.run(project=project, args=[ 'show', @@ -159,7 +159,7 @@ def test_junction_element_not_partial_project_file(cli, tmpdir, datafiles): repo.source_config(ref=ref) ] } - _yaml.dump(element, junction_path) + _yaml.roundtrip_dump(element, junction_path) result = cli.run(project=project, args=[ 'show', diff --git a/tests/format/include_composition.py b/tests/format/include_composition.py index b922c7a0e..f764b16a6 100644 --- a/tests/format/include_composition.py +++ b/tests/format/include_composition.py @@ -6,8 +6,7 @@ from buildstream import _yaml def make_includes(basedir): - _yaml.dump({'name': 'test'}, - os.path.join(basedir, 'project.conf')) + _yaml.roundtrip_dump({'name': 'test'}, os.path.join(basedir, 'project.conf')) context = Context() project = Project(basedir, context) loader = project.loader @@ -17,14 +16,12 @@ def make_includes(basedir): def test_main_has_priority(tmpdir): includes = make_includes(str(tmpdir)) - _yaml.dump({'(@)': ['a.yml'], - 'test': ['main']}, - str(tmpdir.join('main.yml'))) + _yaml.roundtrip_dump({'(@)': ['a.yml'], 'test': ['main']}, + str(tmpdir.join('main.yml'))) main = _yaml.load(str(tmpdir.join('main.yml'))) - _yaml.dump({'test': ['a']}, - str(tmpdir.join('a.yml'))) + _yaml.roundtrip_dump({'test': ['a']}, str(tmpdir.join('a.yml'))) includes.process(main) @@ -34,13 +31,12 @@ def test_main_has_priority(tmpdir): def test_include_cannot_append(tmpdir): includes = make_includes(str(tmpdir)) - _yaml.dump({'(@)': ['a.yml'], - 'test': ['main']}, - str(tmpdir.join('main.yml'))) + _yaml.roundtrip_dump({'(@)': ['a.yml'], 'test': ['main']}, + str(tmpdir.join('main.yml'))) main = _yaml.load(str(tmpdir.join('main.yml'))) - _yaml.dump({'test': {'(>)': ['a']}}, - str(tmpdir.join('a.yml'))) + _yaml.roundtrip_dump({'test': {'(>)': ['a']}}, + str(tmpdir.join('a.yml'))) includes.process(main) @@ -50,13 +46,11 @@ def test_include_cannot_append(tmpdir): def test_main_can_append(tmpdir): includes = make_includes(str(tmpdir)) - _yaml.dump({'(@)': ['a.yml'], - 'test': {'(>)': ['main']}}, - str(tmpdir.join('main.yml'))) + _yaml.roundtrip_dump({'(@)': ['a.yml'], 'test': {'(>)': ['main']}}, + str(tmpdir.join('main.yml'))) main = _yaml.load(str(tmpdir.join('main.yml'))) - _yaml.dump({'test': ['a']}, - str(tmpdir.join('a.yml'))) + _yaml.roundtrip_dump({'test': ['a']}, str(tmpdir.join('a.yml'))) includes.process(main) @@ -66,14 +60,14 @@ def test_main_can_append(tmpdir): def test_sibling_cannot_append_backward(tmpdir): includes = make_includes(str(tmpdir)) - _yaml.dump({'(@)': ['a.yml', 'b.yml']}, - str(tmpdir.join('main.yml'))) + _yaml.roundtrip_dump({'(@)': ['a.yml', 'b.yml']}, + str(tmpdir.join('main.yml'))) main = _yaml.load(str(tmpdir.join('main.yml'))) - _yaml.dump({'test': {'(>)': ['a']}}, - str(tmpdir.join('a.yml'))) - _yaml.dump({'test': ['b']}, - str(tmpdir.join('b.yml'))) + _yaml.roundtrip_dump({'test': {'(>)': ['a']}}, + str(tmpdir.join('a.yml'))) + _yaml.roundtrip_dump({'test': ['b']}, + str(tmpdir.join('b.yml'))) includes.process(main) @@ -83,14 +77,14 @@ def test_sibling_cannot_append_backward(tmpdir): def test_sibling_can_append_forward(tmpdir): includes = make_includes(str(tmpdir)) - _yaml.dump({'(@)': ['a.yml', 'b.yml']}, - str(tmpdir.join('main.yml'))) + _yaml.roundtrip_dump({'(@)': ['a.yml', 'b.yml']}, + str(tmpdir.join('main.yml'))) main = _yaml.load(str(tmpdir.join('main.yml'))) - _yaml.dump({'test': ['a']}, - str(tmpdir.join('a.yml'))) - _yaml.dump({'test': {'(>)': ['b']}}, - str(tmpdir.join('b.yml'))) + _yaml.roundtrip_dump({'test': ['a']}, + str(tmpdir.join('a.yml'))) + _yaml.roundtrip_dump({'test': {'(>)': ['b']}}, + str(tmpdir.join('b.yml'))) includes.process(main) @@ -100,14 +94,14 @@ def test_sibling_can_append_forward(tmpdir): def test_lastest_sibling_has_priority(tmpdir): includes = make_includes(str(tmpdir)) - _yaml.dump({'(@)': ['a.yml', 'b.yml']}, - str(tmpdir.join('main.yml'))) + _yaml.roundtrip_dump({'(@)': ['a.yml', 'b.yml']}, + str(tmpdir.join('main.yml'))) main = _yaml.load(str(tmpdir.join('main.yml'))) - _yaml.dump({'test': ['a']}, - str(tmpdir.join('a.yml'))) - _yaml.dump({'test': ['b']}, - str(tmpdir.join('b.yml'))) + _yaml.roundtrip_dump({'test': ['a']}, + str(tmpdir.join('a.yml'))) + _yaml.roundtrip_dump({'test': ['b']}, + str(tmpdir.join('b.yml'))) includes.process(main) @@ -117,13 +111,11 @@ def test_lastest_sibling_has_priority(tmpdir): def test_main_keeps_keys(tmpdir): includes = make_includes(str(tmpdir)) - _yaml.dump({'(@)': ['a.yml'], - 'something': 'else'}, - str(tmpdir.join('main.yml'))) + _yaml.roundtrip_dump({'(@)': ['a.yml'], 'something': 'else'}, + str(tmpdir.join('main.yml'))) main = _yaml.load(str(tmpdir.join('main.yml'))) - _yaml.dump({'test': ['a']}, - str(tmpdir.join('a.yml'))) + _yaml.roundtrip_dump({'test': ['a']}, str(tmpdir.join('a.yml'))) includes.process(main) @@ -134,20 +126,19 @@ def test_main_keeps_keys(tmpdir): def test_overwrite_directive_on_later_composite(tmpdir): includes = make_includes(str(tmpdir)) - _yaml.dump({'(@)': ['a.yml', 'b.yml'], - 'test': {'(=)': ['Overwritten']}}, - str(tmpdir.join('main.yml'))) + _yaml.roundtrip_dump({'(@)': ['a.yml', 'b.yml'], 'test': {'(=)': ['Overwritten']}}, + str(tmpdir.join('main.yml'))) main = _yaml.load(str(tmpdir.join('main.yml'))) # a.yml - _yaml.dump({'test': ['some useless', 'list', 'to be overwritten'], - 'foo': 'should not be present'}, - str(tmpdir.join('a.yml'))) + _yaml.roundtrip_dump({'test': ['some useless', 'list', 'to be overwritten'], + 'foo': 'should not be present'}, + str(tmpdir.join('a.yml'))) # b.yaml isn't going to have a 'test' node to overwrite - _yaml.dump({'foo': 'should be present'}, - str(tmpdir.join('b.yml'))) + _yaml.roundtrip_dump({'foo': 'should be present'}, + str(tmpdir.join('b.yml'))) includes.process(main) diff --git a/tests/format/junctions.py b/tests/format/junctions.py index 8842bc617..b810c55a3 100644 --- a/tests/format/junctions.py +++ b/tests/format/junctions.py @@ -331,7 +331,7 @@ def test_git_show(cli, tmpdir, datafiles): repo.source_config(ref=ref) ] } - _yaml.dump(element, os.path.join(project, 'base.bst')) + _yaml.roundtrip_dump(element, os.path.join(project, 'base.bst')) # Check that bst show succeeds with implicit subproject fetching and the # pipeline includes the subproject element @@ -356,7 +356,7 @@ def test_git_build(cli, tmpdir, datafiles): repo.source_config(ref=ref) ] } - _yaml.dump(element, os.path.join(project, 'base.bst')) + _yaml.roundtrip_dump(element, os.path.join(project, 'base.bst')) # Build (with implicit fetch of subproject), checkout result = cli.run(project=project, args=['build', 'target.bst']) @@ -389,7 +389,7 @@ def test_git_missing_project_conf(cli, tmpdir, datafiles): repo.source_config(ref=ref) ] } - _yaml.dump(element, str(project / 'base.bst')) + _yaml.roundtrip_dump(element, str(project / 'base.bst')) result = cli.run(project=project, args=['build', 'app.bst']) result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.INVALID_JUNCTION) @@ -423,7 +423,7 @@ def test_build_git_cross_junction_names(cli, tmpdir, datafiles): repo.source_config(ref=ref) ] } - _yaml.dump(element, os.path.join(project, 'base.bst')) + _yaml.roundtrip_dump(element, os.path.join(project, 'base.bst')) print(element) print(cli.get_pipeline(project, ['base.bst'])) diff --git a/tests/format/project.py b/tests/format/project.py index 697fe7e3d..2e0a729dc 100644 --- a/tests/format/project.py +++ b/tests/format/project.py @@ -200,7 +200,7 @@ def test_plugin_no_load_ref(cli, datafiles, ref_storage): } ] } - _yaml.dump(config, os.path.join(project, 'project.conf')) + _yaml.roundtrip_dump(config, os.path.join(project, 'project.conf')) result = cli.run(project=project, silent=True, args=['show', 'noloadref.bst']) diff --git a/tests/format/variables.py b/tests/format/variables.py index ed5407b83..93814279a 100644 --- a/tests/format/variables.py +++ b/tests/format/variables.py @@ -110,7 +110,7 @@ def test_use_of_protected_var_project_conf(cli, datafiles, protected_var): protected_var: 'some-value' } } - _yaml.dump(conf, os.path.join(project, 'project.conf')) + _yaml.roundtrip_dump(conf, os.path.join(project, 'project.conf')) element = { 'kind': 'import', @@ -121,7 +121,7 @@ def test_use_of_protected_var_project_conf(cli, datafiles, protected_var): } ], } - _yaml.dump(element, os.path.join(project, 'target.bst')) + _yaml.roundtrip_dump(element, os.path.join(project, 'target.bst')) result = cli.run(project=project, args=['build', 'target.bst']) result.assert_main_error(ErrorDomain.LOAD, @@ -142,7 +142,7 @@ def test_use_of_protected_var_element_overrides(cli, datafiles, protected_var): } } } - _yaml.dump(conf, os.path.join(project, 'project.conf')) + _yaml.roundtrip_dump(conf, os.path.join(project, 'project.conf')) element = { 'kind': 'manual', @@ -153,7 +153,7 @@ def test_use_of_protected_var_element_overrides(cli, datafiles, protected_var): } ], } - _yaml.dump(element, os.path.join(project, 'target.bst')) + _yaml.roundtrip_dump(element, os.path.join(project, 'target.bst')) result = cli.run(project=project, args=['build', 'target.bst']) result.assert_main_error(ErrorDomain.LOAD, @@ -176,7 +176,7 @@ def test_use_of_protected_var_in_element(cli, datafiles, protected_var): protected_var: 'some-value' } } - _yaml.dump(element, os.path.join(project, 'target.bst')) + _yaml.roundtrip_dump(element, os.path.join(project, 'target.bst')) result = cli.run(project=project, args=['build', 'target.bst']) result.assert_main_error(ErrorDomain.LOAD, |