xref: /trunk/test/aoo-test/tests/odf/test_crosscheck.py (revision 2cb6d6f119bbe2f78742f1c5c8538cb0d4e72ede)
1################################################################
2#
3#  Licensed to the Apache Software Foundation (ASF) under one
4#  or more contributor license agreements.  See the NOTICE file
5#  distributed with this work for additional information
6#  regarding copyright ownership.  The ASF licenses this file
7#  to you under the Apache License, Version 2.0 (the
8#  "License"); you may not use this file except in compliance
9#  with the License.  You may obtain a copy of the License at
10#
11#    http://www.apache.org/licenses/LICENSE-2.0
12#
13#  Unless required by applicable law or agreed to in writing,
14#  software distributed under the License is distributed on an
15#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16#  KIND, either express or implied.  See the License for the
17#  specific language governing permissions and limitations
18#  under the License.
19
20"""A second validator over the saved output: odfvalidator (a different engine, with its own error recovery) must agree with
21jing about which streams of a document have errors. Strict ODF 1.2 output is compared in conformance mode, 1.2 extended
22output in extended mode. Error counts are not comparable between the engines, so only whether a stream has errors is."""
23import pytest
24
25from aootest import documents
26
27pytestmark = [pytest.mark.slow, pytest.mark.needs_java]
28
29MODES = [("strict", "conformance"), ("ext", "extended")]
30
31
32@pytest.mark.parametrize("mode,flavour", MODES)
33def test_validators_agree(saved, mode, flavour, source):
34    run, r = saved(mode, source)
35    assert r["out"], "not saved: %s" % r["detail"]
36    res = run.crosscheck()
37    if res is None:
38        pytest.skip("needs java, jing, odfvalidator and the ODF schemas (python -m aootest.fetch)")
39    name = documents.out_name(source)
40    res = res[flavour]
41    disagree = [k for k in res["only_jing"] + res["only_odfvalidator"] if k[0].split("/", 1)[0] == name]
42    assert name not in res["odfvalidator_crashed_on"], "odfvalidator crashed on %s" % name
43    assert not disagree, "only one validator reports errors: %s" % disagree[:3]
44