Debian Codegraph @

testing/mozbase/manifestparser/tests/test_manifestparser.py

raw
1 #!/usr/bin/env python
2
3 # This Source Code Form is subject to the terms of the Mozilla Public
4 # License, v. 2.0. If a copy of the MPL was not distributed with this file,
5 # You can obtain one at http://mozilla.org/MPL/2.0/.
6
7 import os
8 import shutil
9 import tempfile
10 import unittest
11 from io import StringIO
12
13 import manifestparser.toml
14 import mozunit
15 import pytest
16 from manifestparser import ManifestParser
17 from tomlkit import TOMLDocument
18
19 here = os.path.dirname(os.path.abspath(__file__))
20
21
22 class TestManifestParser(unittest.TestCase):
23 """
24 Test the manifest parser
25
26 You must have manifestparser installed before running these tests.
27 Run ``python manifestparser.py setup develop`` with setuptools installed.
28 """
29
30 def test_sanity_toml(self):
31 """Ensure basic parser is sane (TOML)"""
32
33 parser = ManifestParser(use_toml=True)
34 mozmill_example = os.path.join(here, "mozmill-example.toml")
35 parser.read(mozmill_example)
36 tests = parser.tests
37 self.assertEqual(
38 len(tests), len(open(mozmill_example).read().strip().splitlines())
39 )
40
41 # Ensure that capitalization and order aren't an issue:
42 lines = ['["%s"]' % test["name"] for test in tests]
43 self.assertEqual(lines, open(mozmill_example).read().strip().splitlines())
44
45 # Show how you select subsets of tests:
46 mozmill_restart_example = os.path.join(here, "mozmill-restart-example.toml")
47 parser.read(mozmill_restart_example)
48 restart_tests = parser.get(type="restart")
49 self.assertTrue(len(restart_tests) < len(parser.tests))
50 self.assertEqual(
51 len(restart_tests), len(parser.get(manifest=mozmill_restart_example))
52 )
53 self.assertFalse(
54 [
55 test
56 for test in restart_tests
57 if test["manifest"]
58 != os.path.join(here, "mozmill-restart-example.toml")
59 ]
60 )
61 self.assertEqual(
62 parser.get("name", tags=["foo"]),
63 [
64 "restartTests/testExtensionInstallUninstall/test2.js",
65 "restartTests/testExtensionInstallUninstall/test1.js",
66 ],
67 )
68 self.assertEqual(
69 parser.get("name", foo="bar"),
70 ["restartTests/testExtensionInstallUninstall/test2.js"],
71 )
72
73 def test_include(self):
74 """Illustrate how include works"""
75
76 include_example = os.path.join(here, "include-example.toml")
77 parser = ManifestParser(manifests=(include_example,), use_toml=False)
78
79 # All of the tests should be included, in order:
80 self.assertEqual(parser.get("name"), ["crash-handling", "fleem", "flowers"])
81 self.assertEqual(
82 [
83 (test["name"], os.path.basename(test["manifest"]))
84 for test in parser.tests
85 ],
86 [
87 ("crash-handling", "bar.toml"),
88 ("fleem", "include-example.toml"),
89 ("flowers", "foo.toml"),
90 ],
91 )
92
93 # The including manifest is always reported as a part of the generated test object.
94 self.assertTrue(
95 all(
96 [
97 t["ancestor_manifest"] == "include-example.toml"
98 for t in parser.tests
99 if t["name"] != "fleem"
100 ]
101 )
102 )
103
104 # The manifests should be there too:
105 self.assertEqual(len(parser.manifests()), 3)
106
107 # We already have the root directory:
108 self.assertEqual(here, parser.rootdir)
109
110 # DEFAULT values should persist across includes, unless they're
111 # overwritten. In this example, include-example.toml sets foo=bar, but
112 # it's overridden to fleem in bar.toml
113 self.assertEqual(parser.get("name", foo="bar"), ["fleem", "flowers"])
114 self.assertEqual(parser.get("name", foo="fleem"), ["crash-handling"])
115
116 # Passing parameters in the include section allows defining variables in
117 # the submodule scope:
118 self.assertEqual(parser.get("name", tags=["red"]), ["flowers"])
119
120 # However, this should be overridable from the DEFAULT section in the
121 # included file and that overridable via the key directly connected to
122 # the test:
123 self.assertEqual(parser.get(name="flowers")[0]["blue"], "ocean")
124 self.assertEqual(parser.get(name="flowers")[0]["yellow"], "submarine")
125
126 # You can query multiple times if you need to:
127 flowers = parser.get(foo="bar")
128 self.assertEqual(len(flowers), 2)
129
130 # Using the inverse flag should invert the set of tests returned:
131 self.assertEqual(
132 parser.get("name", inverse=True, tags=["red"]), ["crash-handling", "fleem"]
133 )
134
135 # All of the included tests actually exist:
136 self.assertEqual([i["name"] for i in parser.missing()], [])
137
138 # Write the output to a manifest:
139 buffer = StringIO()
140 parser.write(fp=buffer, global_kwargs={"foo": "bar"})
141 expected_output = """[DEFAULT]
142 foo = bar
143
144 [fleem]
145
146 [include/flowers]
147 blue = ocean
148 red = roses
149 yellow = submarine""" # noqa
150
151 self.assertEqual(buffer.getvalue().strip(), expected_output)
152
153 def test_include_toml(self):
154 """Illustrate how include works (TOML)"""
155
156 include_example = os.path.join(here, "include-example.toml")
157 parser = ManifestParser(manifests=(include_example,), use_toml=True)
158
159 # All of the tests should be included, in order:
160 self.assertEqual(parser.get("name"), ["crash-handling", "fleem", "flowers"])
161 self.assertEqual(
162 [
163 (test["name"], os.path.basename(test["manifest"]))
164 for test in parser.tests
165 ],
166 [
167 ("crash-handling", "bar.toml"),
168 ("fleem", "include-example.toml"),
169 ("flowers", "foo.toml"),
170 ],
171 )
172
173 # The including manifest is always reported as a part of the generated test object.
174 self.assertTrue(
175 all(
176 [
177 t["ancestor_manifest"] == "include-example.toml"
178 for t in parser.tests
179 if t["name"] != "fleem"
180 ]
181 )
182 )
183
184 # The manifests should be there too:
185 self.assertEqual(len(parser.manifests()), 3)
186
187 # We already have the root directory:
188 self.assertEqual(here, parser.rootdir)
189
190 # DEFAULT values should persist across includes, unless they're
191 # overwritten. In this example, include-example.toml sets foo=bar, but
192 # it's overridden to fleem in bar.toml
193 self.assertEqual(parser.get("name", foo="bar"), ["fleem", "flowers"])
194 self.assertEqual(parser.get("name", foo="fleem"), ["crash-handling"])
195
196 # Passing parameters in the include section allows defining variables in
197 # the submodule scope:
198 self.assertEqual(parser.get("name", tags=["red"]), ["flowers"])
199
200 # However, this should be overridable from the DEFAULT section in the
201 # included file and that overridable via the key directly connected to
202 # the test:
203 self.assertEqual(parser.get(name="flowers")[0]["blue"], "ocean")
204 self.assertEqual(parser.get(name="flowers")[0]["yellow"], "submarine")
205
206 # You can query multiple times if you need to:
207 flowers = parser.get(foo="bar")
208 self.assertEqual(len(flowers), 2)
209
210 # Using the inverse flag should invert the set of tests returned:
211 self.assertEqual(
212 parser.get("name", inverse=True, tags=["red"]), ["crash-handling", "fleem"]
213 )
214
215 # All of the included tests actually exist:
216 self.assertEqual([i["name"] for i in parser.missing()], [])
217
218 # Write the output to a manifest:
219 buffer = StringIO()
220 parser.write(fp=buffer, global_kwargs={"foo": "bar"})
221 expected_output = """[DEFAULT]
222 foo = bar
223
224 [fleem]
225
226 [include/flowers]
227 blue = ocean
228 red = roses
229 yellow = submarine""" # noqa
230
231 self.assertEqual(buffer.getvalue().strip(), expected_output)
232
233 def test_include_manifest_defaults_toml(self):
234 """
235 Test that manifest_defaults and manifests() are correctly populated
236 when includes are used. (TOML)
237 """
238
239 include_example = os.path.join(here, "include-example.toml")
240 noinclude_example = os.path.join(here, "just-defaults.toml")
241 bar_path = os.path.join(here, "include", "bar.toml")
242 foo_path = os.path.join(here, "include", "foo.toml")
243
244 parser = ManifestParser(
245 manifests=(include_example, noinclude_example), rootdir=here, use_toml=True
246 )
247
248 # Standalone manifests must be appear as-is.
249 self.assertTrue(include_example in parser.manifest_defaults)
250 self.assertTrue(noinclude_example in parser.manifest_defaults)
251
252 # Included manifests must only appear together with the parent manifest
253 # that included the manifest.
254 self.assertFalse(bar_path in parser.manifest_defaults)
255 self.assertFalse(foo_path in parser.manifest_defaults)
256 ancestor_toml = os.path.relpath(include_example, parser.rootdir)
257 self.assertTrue((ancestor_toml, bar_path) in parser.manifest_defaults)
258 self.assertTrue((ancestor_toml, foo_path) in parser.manifest_defaults)
259
260 # manifests() must only return file paths (strings).
261 manifests = parser.manifests()
262 self.assertEqual(len(manifests), 4)
263 self.assertIn(foo_path, manifests)
264 self.assertIn(bar_path, manifests)
265 self.assertIn(include_example, manifests)
266 self.assertIn(noinclude_example, manifests)
267
268 def test_include_handle_defaults_False_toml(self):
269 """
270 Test that manifest_defaults and manifests() are correct even when
271 handle_defaults is set to False. (TOML)
272 """
273 manifest = os.path.join(here, "include-example.toml")
274 foo_path = os.path.join(here, "include", "foo.toml")
275
276 parser = ManifestParser(
277 manifests=(manifest,), handle_defaults=False, rootdir=here, use_toml=True
278 )
279 ancestor_ini = os.path.relpath(manifest, parser.rootdir)
280
281 self.assertIn(manifest, parser.manifest_defaults)
282 self.assertNotIn(foo_path, parser.manifest_defaults)
283 self.assertIn((ancestor_ini, foo_path), parser.manifest_defaults)
284 self.assertEqual(
285 parser.manifest_defaults[manifest],
286 {
287 "foo": "bar",
288 "here": here,
289 },
290 )
291 self.assertEqual(
292 parser.manifest_defaults[(ancestor_ini, foo_path)],
293 {
294 "here": os.path.join(here, "include"),
295 "red": "roses",
296 "blue": "ocean",
297 "yellow": "daffodils",
298 },
299 )
300
301 def test_include_repeated_toml(self):
302 """
303 Test that repeatedly included manifests are independent of each other. (TOML)
304 """
305 include_example = os.path.join(here, "include-example.toml")
306 included_foo = os.path.join(here, "include", "foo.toml")
307
308 # In the expected output, blue and yellow have the values from foo.toml
309 # (ocean, submarine) instead of the ones from include-example.toml
310 # (violets, daffodils), because the defaults in the included file take
311 # precedence over the values from the parent.
312 include_output = """[include/crash-handling]
313 foo = fleem
314
315 [fleem]
316 foo = bar
317
318 [include/flowers]
319 blue = ocean
320 foo = bar
321 red = roses
322 yellow = submarine
323
324 """
325 included_output = """[include/flowers]
326 blue = ocean
327 yellow = submarine
328
329 """
330
331 parser = ManifestParser(
332 manifests=(include_example, included_foo), rootdir=here, use_toml=True
333 )
334 self.assertEqual(
335 parser.get("name"), ["crash-handling", "fleem", "flowers", "flowers"]
336 )
337 self.assertEqual(
338 [
339 (test["name"], os.path.basename(test["manifest"]))
340 for test in parser.tests
341 ],
342 [
343 ("crash-handling", "bar.toml"),
344 ("fleem", "include-example.toml"),
345 ("flowers", "foo.toml"),
346 ("flowers", "foo.toml"),
347 ],
348 )
349 self.check_included_repeat(
350 parser,
351 parser.tests[3],
352 parser.tests[2],
353 "%s%s" % (include_output, included_output),
354 True,
355 )
356
357 # Same tests, but with the load order of the manifests swapped.
358 parser = ManifestParser(
359 manifests=(included_foo, include_example), rootdir=here, use_toml=True
360 )
361 self.assertEqual(
362 parser.get("name"), ["flowers", "crash-handling", "fleem", "flowers"]
363 )
364 self.assertEqual(
365 [
366 (test["name"], os.path.basename(test["manifest"]))
367 for test in parser.tests
368 ],
369 [
370 ("flowers", "foo.toml"),
371 ("crash-handling", "bar.toml"),
372 ("fleem", "include-example.toml"),
373 ("flowers", "foo.toml"),
374 ],
375 )
376 self.check_included_repeat(
377 parser,
378 parser.tests[0],
379 parser.tests[3],
380 "%s%s" % (included_output, include_output),
381 True,
382 )
383
384 def check_included_repeat(
385 self, parser, isolated_test, included_test, expected_output, use_toml=False
386 ):
387 if use_toml:
388 include_example_filename = "include-example.toml"
389 foo_filename = "foo.toml"
390 else:
391 include_example_filename = "include-example.toml"
392 foo_filename = "foo.toml"
393 include_example = os.path.join(here, include_example_filename)
394 included_foo = os.path.join(here, "include", foo_filename)
395 ancestor_ini = os.path.relpath(include_example, parser.rootdir)
396 manifest_default_key = (ancestor_ini, included_foo)
397
398 self.assertFalse("ancestor_manifest" in isolated_test)
399 self.assertEqual(included_test["ancestor_manifest"], include_example_filename)
400
401 self.assertTrue(include_example in parser.manifest_defaults)
402 self.assertTrue(included_foo in parser.manifest_defaults)
403 self.assertTrue(manifest_default_key in parser.manifest_defaults)
404 self.assertEqual(
405 parser.manifest_defaults[manifest_default_key],
406 {
407 "foo": "bar",
408 "here": os.path.join(here, "include"),
409 "red": "roses",
410 "blue": "ocean",
411 "yellow": "daffodils",
412 },
413 )
414
415 buffer = StringIO()
416 parser.write(fp=buffer)
417 self.assertEqual(buffer.getvalue(), expected_output)
418
419 def test_invalid_path_toml(self):
420 """
421 Test invalid path should not throw when not strict (TOML)
422 """
423 manifest = os.path.join(here, "include-invalid.toml")
424 ManifestParser(manifests=(manifest,), strict=False, use_toml=True)
425
426 def test_copy_toml(self):
427 """Test our ability to copy a set of manifests (TOML)"""
428
429 tempdir = tempfile.mkdtemp()
430 include_example = os.path.join(here, "include-example.toml")
431 manifest = ManifestParser(manifests=(include_example,), use_toml=True)
432 manifest.copy(tempdir)
433 self.assertEqual(
434 sorted(os.listdir(tempdir)), ["fleem", "include", "include-example.toml"]
435 )
436 self.assertEqual(
437 sorted(os.listdir(os.path.join(tempdir, "include"))),
438 ["bar.toml", "crash-handling", "flowers", "foo.toml"],
439 )
440 from_manifest = ManifestParser(manifests=(include_example,), use_toml=True)
441 to_manifest = os.path.join(tempdir, "include-example.toml")
442 to_manifest = ManifestParser(manifests=(to_manifest,), use_toml=True)
443 self.assertEqual(to_manifest.get("name"), from_manifest.get("name"))
444 shutil.rmtree(tempdir)
445
446 def test_path_override_toml(self):
447 """You can override the path in the section too.
448 This shows that you can use a relative path"""
449 path_example = os.path.join(here, "path-example.toml")
450 manifest = ManifestParser(manifests=(path_example,), use_toml=True)
451 self.assertEqual(manifest.tests[0]["path"], os.path.join(here, "fleem"))
452
453 def test_relative_path_toml(self):
454 """
455 Relative test paths are correctly calculated. (TOML)
456 """
457 relative_path = os.path.join(here, "relative-path.toml")
458 manifest = ManifestParser(manifests=(relative_path,), use_toml=True)
459 self.assertEqual(
460 manifest.tests[0]["path"], os.path.join(os.path.dirname(here), "fleem")
461 )
462 self.assertEqual(manifest.tests[0]["relpath"], os.path.join("..", "fleem"))
463 self.assertEqual(
464 manifest.tests[1]["relpath"], os.path.join("..", "testsSIBLING", "example")
465 )
466
467 def test_path_from_fd(self):
468 """
469 Test paths are left untouched when manifest is a file-like object.
470 """
471 fp = StringIO("[section]\npath=fleem")
472 manifest = ManifestParser(manifests=(fp,))
473 self.assertEqual(manifest.tests[0]["path"], "fleem")
474 self.assertEqual(manifest.tests[0]["relpath"], "fleem")
475 self.assertEqual(manifest.tests[0]["manifest"], None)
476
477 def test_comments_toml(self):
478 """
479 ensure comments work, see
480 https://bugzilla.mozilla.org/show_bug.cgi?id=813674
481 (TOML)
482 """
483 comment_example = os.path.join(here, "comment-example.toml")
484 manifest = ManifestParser(manifests=(comment_example,), use_toml=True)
485 self.assertEqual(len(manifest.tests), 8)
486 names = [i["name"] for i in manifest.tests]
487 self.assertFalse("test_0202_app_launch_apply_update_dirlocked.js" in names)
488
489 def test_verifyDirectory_toml(self):
490 directory = os.path.join(here, "verifyDirectory")
491
492 # correct manifest
493 manifest_path = os.path.join(directory, "verifyDirectory.toml")
494 manifest = ManifestParser(manifests=(manifest_path,), use_toml=True)
495 missing = manifest.verifyDirectory(directory, extensions=(".js",))
496 self.assertEqual(missing, (set(), set()))
497
498 # manifest is missing test_1.js
499 test_1 = os.path.join(directory, "test_1.js")
500 manifest_path = os.path.join(directory, "verifyDirectory_incomplete.toml")
501 manifest = ManifestParser(manifests=(manifest_path,), use_toml=True)
502 missing = manifest.verifyDirectory(directory, extensions=(".js",))
503 self.assertEqual(missing, (set(), set([test_1])))
504
505 # filesystem is missing test_notappearinginthisfilm.js
506 missing_test = os.path.join(directory, "test_notappearinginthisfilm.js")
507 manifest_path = os.path.join(directory, "verifyDirectory_toocomplete.toml")
508 manifest = ManifestParser(manifests=(manifest_path,), use_toml=True)
509 missing = manifest.verifyDirectory(directory, extensions=(".js",))
510 self.assertEqual(missing, (set([missing_test]), set()))
511
512 def test_just_defaults_toml(self):
513 """Ensure a manifest with just a DEFAULT section exposes that data. (TOML)"""
514
515 parser = ManifestParser(use_toml=True)
516 manifest = os.path.join(here, "just-defaults.toml")
517 parser.read(manifest)
518 self.assertEqual(len(parser.tests), 0)
519 self.assertTrue(manifest in parser.manifest_defaults)
520 self.assertEqual(parser.manifest_defaults[manifest]["foo"], "bar")
521
522 def test_manifest_list_toml(self):
523 """
524 Ensure a manifest with just a DEFAULT section still returns
525 itself from the manifests() method. (TOML)
526 """
527
528 parser = ManifestParser(use_toml=True)
529 manifest = os.path.join(here, "no-tests.toml")
530 parser.read(manifest)
531 self.assertEqual(len(parser.tests), 0)
532 self.assertTrue(len(parser.manifests()) == 1)
533
534 def test_manifest_with_invalid_condition_toml(self):
535 """
536 Ensure a skip-if or similar condition with an assignment in it
537 causes errors. (TOML)
538 """
539
540 parser = ManifestParser(use_toml=True)
541 manifest = os.path.join(here, "broken-skip-if.toml")
542 with self.assertRaisesRegex(
543 Exception, "Should not assign in skip-if condition for DEFAULT"
544 ):
545 parser.read(manifest)
546
547 def test_parse_error_toml(self):
548 """
549 Verify handling of a mal-formed TOML file
550 """
551
552 parser = ManifestParser(use_toml=True)
553 manifest = os.path.join(here, "parse-error.toml")
554 with self.assertRaisesRegex(
555 Exception,
556 r".*'str' object has no attribute 'keys'.*",
557 ):
558 parser.read(manifest)
559
560 def test_parse_error_tomlkit(self):
561 """
562 Verify handling of a mal-formed TOML file
563 """
564
565 parser = ManifestParser(use_toml=True, document=True)
566 manifest = os.path.join(here, "parse-error.toml")
567 with self.assertRaisesRegex(
568 Exception,
569 r".*'String' object has no attribute 'keys'.*",
570 ):
571 parser.read(manifest)
572
573 def test_edit_manifest(self):
574 """
575 Verify reading and writing TOML manifest with tomlkit
576 """
577 parser = ManifestParser(use_toml=True, document=True)
578 before = "edit-manifest-before.toml"
579 before_path = os.path.join(here, before)
580 parser.read(before_path)
581 assert before_path in parser.source_documents
582 manifest = parser.source_documents[before_path]
583 assert manifest is not None
584 assert isinstance(manifest, TOMLDocument)
585
586 filename = "bug_20.js"
587 assert filename in manifest
588 condition = "os == 'mac'"
589 bug = "Bug 20"
590 manifestparser.toml.add_skip_if(manifest, filename, condition, bug)
591 condition = "os == 'windows'"
592 manifestparser.toml.add_skip_if(manifest, filename, condition, bug)
593
594 filename = "test_foo.html"
595 assert filename in manifest
596 condition = "os == 'mac' && debug"
597 manifestparser.toml.add_skip_if(manifest, filename, condition)
598
599 filename = "test_bar.html"
600 assert filename in manifest
601 condition = "tsan"
602 bug = "Bug 444"
603 manifestparser.toml.add_skip_if(manifest, filename, condition, bug)
604 condition = "os == 'linux'" # pre-existing, should be ignored
605 bug = "Bug 555"
606 manifestparser.toml.add_skip_if(manifest, filename, condition, bug)
607
608 filename = "bug_100.js"
609 assert filename in manifest
610 condition = "apple_catalina"
611 bug = "Bug 200"
612 manifestparser.toml.add_skip_if(manifest, filename, condition, bug)
613
614 filename = "bug_3.js"
615 assert filename in manifest
616 condition = "verify"
617 bug = "Bug 33333"
618 manifestparser.toml.add_skip_if(manifest, filename, condition, bug)
619
620 # Should not extend exising conditions
621 filename = "test_extend_linux.js"
622 assert filename in manifest
623 condition = "os == 'linux' && version == '18.04'"
624 manifestparser.toml.add_skip_if(manifest, filename, condition)
625
626 # Should simplify exising conditions
627 filename = "test_simplify_linux.js"
628 assert filename in manifest
629 condition = "os == 'linux'"
630 manifestparser.toml.add_skip_if(manifest, filename, condition)
631
632 manifest_str = manifestparser.toml.alphabetize_toml_str(manifest)
633 after = "edit-manifest-after.toml"
634 after_path = os.path.join(here, after)
635 after_str = open(after_path, encoding="utf-8").read()
636 assert manifest_str == after_str
637
638 def test_remove_skipif(self):
639 """
640 Verify removing skip-if conditions from TOML manifest
641 """
642 parser = ManifestParser(use_toml=True, document=True)
643 before = "remove-manifest-before.toml"
644 before_path = os.path.join(here, before)
645 parser.read(before_path)
646 manifest = parser.source_documents[before_path]
647
648 manifestparser.toml.remove_skip_if(manifest, os_name="linux")
649
650 manifest_str = manifestparser.toml.alphabetize_toml_str(manifest)
651 after = "remove-manifest-after1.toml"
652 after_path = os.path.join(here, after)
653 after_str = open(after_path, encoding="utf-8").read()
654 assert manifest_str == after_str
655
656 parser.read(before_path)
657 manifest = parser.source_documents[before_path]
658
659 manifestparser.toml.remove_skip_if(
660 manifest, os_name="linux", os_version="18.04"
661 )
662
663 manifest_str = manifestparser.toml.alphabetize_toml_str(manifest)
664 after = "remove-manifest-after2.toml"
665 after_path = os.path.join(here, after)
666 after_str = open(after_path, encoding="utf-8").read()
667 assert manifest_str == after_str
668
669 parser.read(before_path)
670 manifest = parser.source_documents[before_path]
671
672 manifestparser.toml.remove_skip_if(
673 manifest, os_name="linux", os_version="18.04", processor="x86"
674 )
675
676 manifest_str = manifestparser.toml.alphabetize_toml_str(manifest)
677 after = "remove-manifest-after3.toml"
678 after_path = os.path.join(here, after)
679 after_str = open(after_path, encoding="utf-8").read()
680 assert manifest_str == after_str
681
682 parser.read(before_path)
683 manifest = parser.source_documents[before_path]
684
685 manifestparser.toml.remove_skip_if(
686 manifest, os_name="unknown", os_version="18.04", processor="x86"
687 )
688
689 manifest_str = manifestparser.toml.alphabetize_toml_str(manifest)
690 after = "remove-manifest-before.toml"
691 after_path = os.path.join(here, after)
692 after_str = open(after_path, encoding="utf-8").read()
693 assert manifest_str == after_str
694
695 parser.read(before_path)
696 manifest = parser.source_documents[before_path]
697
698 with pytest.raises(ValueError):
699 manifestparser.toml.remove_skip_if(manifest)
700
701
702 if __name__ == "__main__":
703 mozunit.main()