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