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"""Known crashes of the office under test, kept out of the default run: a crash makes macOS write a report and slows every 21office start that follows, so these run on request (python3 -m pytest -m crash). A row in data/expect/crash.tsv records each 22one; with --strict-expect the item fails when the crash is gone, which is the cue to delete the row.""" 23import pytest 24 25from aootest import documents 26from aootest.client import WorkerFailure 27from aootest.odfversion import SAVE_MODES 28 29pytestmark = [pytest.mark.slow, pytest.mark.crash] 30 31 32def test_paragraph_bitmap_fill_mode_does_not_kill_the_office(aoo_offices, tmp_path): 33 """Building para-fill-foreign sets FillBitmapMode on Writer paragraphs; the worker's generate op must come back.""" 34 session = aoo_offices.get(3) 35 res = session.call("generate", {"builder": "para-fill-foreign", "outdir": str(tmp_path)}, timeout=300) 36 assert res["files"] == ["aoo-form.odt"] 37 38 39def test_draw_annotations_step_does_not_stall_the_office(aoo_offices, tmp_path): 40 """Annotations on Impress and Draw pages: in a fresh trunk dev app the draw script's `annotations` step ran past its own 90 s limit.""" 41 session = aoo_offices.get(3, tag="build-draw-annotations") 42 try: 43 res = session.call("generate", {"builder": "draw-annotations", "outdir": str(tmp_path / "out")}, timeout=150) 44 finally: 45 session.close() 46 assert res["files"] == ["annotations.odg", "annotations.odp"] 47 48 49EXCLUDED = documents.script_excluded() 50 51 52@pytest.fixture(scope="module") 53def excluded_files(aoo_offices, tmp_path_factory): 54 """{builder: output directory}, each builder run once in an office of its own.""" 55 made = {} 56 57 def get(builder): 58 if builder not in made: 59 out = tmp_path_factory.mktemp(builder) / "out" 60 session = aoo_offices.get(SAVE_MODES["ext"], tag="build-" + builder) 61 try: 62 session.call("generate", {"builder": builder, "outdir": str(out)}, timeout=documents.BUILD_TIMEOUTS.get(builder, documents.BUILD_TIMEOUT)) 63 finally: 64 session.close() 65 made[builder] = out 66 return made[builder] 67 return get 68 69 70@pytest.mark.parametrize("builder,name,reason", EXCLUDED, ids=["%s/%s" % (b, f) for b, f, _ in EXCLUDED]) 71def test_excluded_document_survives_every_save_mode(builder, name, reason, excluded_files, aoo_offices, tmp_path): 72 """Converts a document that data/built-excluded.tsv keeps out of the default run in each save mode, in a fresh office each time.""" 73 src = excluded_files(builder) / name 74 kind = documents.BUILT_KIND[name.rsplit(".", 1)[1]] 75 died = [] 76 for mode_name, mode in SAVE_MODES.items(): 77 session = aoo_offices.get(mode, tag="excluded-%s-%s-%s" % (builder, name, mode_name)) 78 try: 79 session.call("convert", {"src": str(src), "dst": str(tmp_path / ("%s.%s" % (mode_name, kind))), "filter": documents.FILTERS[kind]}, 80 timeout=120) 81 except WorkerFailure as e: 82 died.append("%s: %s" % (mode_name, e)) 83 finally: 84 session.close() 85 assert not died, "; ".join(died) 86