xref: /trunk/test/ODF-TESTING.md (revision 30d2e6beba5b3cdbcaf7208028ffe084e446bfd6)
1388d90fbSJim Jagielski<!--
2388d90fbSJim Jagielski Licensed to the Apache Software Foundation (ASF) under one
3388d90fbSJim Jagielski or more contributor license agreements.  See the NOTICE file
4388d90fbSJim Jagielski distributed with this work for additional information
5388d90fbSJim Jagielski regarding copyright ownership.  The ASF licenses this file
6388d90fbSJim Jagielski to you under the Apache License, Version 2.0 (the
7388d90fbSJim Jagielski "License"); you may not use this file except in compliance
8388d90fbSJim Jagielski with the License.  You may obtain a copy of the License at
9388d90fbSJim Jagielski
10388d90fbSJim Jagielski   http://www.apache.org/licenses/LICENSE-2.0
11388d90fbSJim Jagielski
12388d90fbSJim Jagielski Unless required by applicable law or agreed to in writing,
13388d90fbSJim Jagielski software distributed under the License is distributed on an
14388d90fbSJim Jagielski "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15388d90fbSJim Jagielski KIND, either express or implied.  See the License for the
16388d90fbSJim Jagielski specific language governing permissions and limitations
17388d90fbSJim Jagielski under the License.
18388d90fbSJim Jagielski-->
19388d90fbSJim Jagielski
20388d90fbSJim Jagielski# Running the ODF test suites
21388d90fbSJim Jagielski
22388d90fbSJim JagielskiTwo Python harnesses check how the office reads and writes ODF 1.2, 1.3 and 1.4. They are separate from the Java/Ant tests described in [README.md](README.md).
23388d90fbSJim Jagielski
24388d90fbSJim Jagielski| | `aoo-test/` | `odf-validate/` |
25388d90fbSJim Jagielski|---|---|---|
26388d90fbSJim Jagielski| What it is | A pytest suite | A regression gate over a document corpus |
27388d90fbSJim Jagielski| Platforms | macOS, Linux, Windows | macOS only (zsh, `hdiutil`, `.app`) |
28388d90fbSJim Jagielski| Office | Any installed AOO 5 or later | A macOS `.dmg` copied into `odf-validate/app/`, optionally rebuilt libraries |
29388d90fbSJim Jagielski| Needs a source tree | No | Yes: the corpus is the test documents under `main/` |
30388d90fbSJim Jagielski| Use it to | Check a build or install | Compare a change in the export code with an earlier run |
31388d90fbSJim Jagielski| Details | [aoo-test/README.md](aoo-test/README.md), [aoo-test/USAGE.md](aoo-test/USAGE.md) | [odf-validate/README.md](odf-validate/README.md) |
32388d90fbSJim Jagielski
33388d90fbSJim JagielskiBoth validate the saved packages against the OASIS RELAX NG schemas with jing, check the package rules, document types, `xml:id` and formula syntax, and cross-check with the Apache ODF Toolkit `odfvalidator`. Java is needed for the schema checks. The schemas are not stored in the repository; each harness downloads them and checks them against pinned sha256 values.
34388d90fbSJim Jagielski
35388d90fbSJim Jagielski## 1. The pytest suite (`aoo-test`)
36388d90fbSJim Jagielski
37388d90fbSJim JagielskiNeeds Python 3.10 or later, pytest 8 or later, and Java.
38388d90fbSJim Jagielski
39388d90fbSJim Jagielski    cd test/aoo-test
40388d90fbSJim Jagielski    python3 -m pytest -m selftest                       # checkers against negative controls, no office
41388d90fbSJim Jagielski    PYTHONPATH=src python3 -m aootest.fetch             # once: schemas, jing, odfvalidator into a per-user cache
42388d90fbSJim Jagielski    AOO_OFFICE=/path/to/install python3 -m pytest -m "not slow"
43388d90fbSJim Jagielski    AOO_OFFICE=/path/to/install python3 -m pytest       # everything, takes a while
44388d90fbSJim Jagielski
45388d90fbSJim Jagielski`AOO_OFFICE` is an `.app` bundle, the install root, its `program` directory, or the `soffice` launcher. Without it, the tests that need an office skip and say why; add `--require-office` to make that a failure. The suite uses private profiles and never touches yours.
46388d90fbSJim Jagielski
47388d90fbSJim Jagielski- The documents it saves come from the install itself (`share/template`, `share/samples`) and from documents it builds through UNO. Add your own with `--documents DIR`.
48388d90fbSJim Jagielski- It saves each document in strict ODF 1.2, 1.2 Extended, 1.3, 1.3 Extended, 1.4 and 1.4 Extended mode and the product default. A build that predates the ODF 1.3 or 1.4 work skips those modes; `--require-odf13` and `--require-odf14` make that a failure.
49388d90fbSJim Jagielski- Known deviations are rows in `data/expect/*.tsv`. `--strict-expect` fails the run if a row listed as failing starts to pass. Error kinds of the extended modes are compared with `data/baseline/`.
50388d90fbSJim Jagielski- `python3 -m pytest -m crash` runs the documents that crash the office; expect crash reports.
51388d90fbSJim Jagielski- Every option and the other test families (cross-check, stability, encrypted packages, about 300 OpenFormula cases, import twins) are in [aoo-test/USAGE.md](aoo-test/USAGE.md).
52388d90fbSJim Jagielski
53388d90fbSJim Jagielski## 2. The ODF validity corpus (`odf-validate`)
54388d90fbSJim Jagielski
55388d90fbSJim JagielskiEach step below is described in [odf-validate/README.md](odf-validate/README.md). The scripts are zsh.
56388d90fbSJim Jagielski
57*30d2e6beSJim Jagielski### Set up once
58388d90fbSJim Jagielski
59388d90fbSJim Jagielski    cd test/odf-validate
60388d90fbSJim Jagielski    ./fetch-schemas.sh                     # OASIS schemas into schema/, checksum-verified
61388d90fbSJim Jagielski    ./setup-app.sh <path-to-AOO.dmg>       # copies OpenOffice.app into app/
62388d90fbSJim Jagielski    ./fetch-odfvalidator.sh                # optional, for the cross-check
63388d90fbSJim Jagielski    python3 -I selftest.py                 # validator negative controls, no office
64388d90fbSJim Jagielski
65388d90fbSJim JagielskiThe defaults in `env.sh` are the author's. Set `ODFV_PYTHON` to the Python that the office's pyuno links against (`otool -L <app>/Contents/program/libpyuno.dylib` shows which), and `ODFV_JING` to a `jing.jar`. The jar that `aootest.fetch` downloads (`jing/` in its cache, `~/Library/Caches/aootest` on macOS) works. `crosscheck.py` also reads `ODFV_ODFVALIDATOR` and `ODFV_JAVA`, and `drive.sh` needs `gtimeout` from GNU coreutils.
66388d90fbSJim Jagielski
67*30d2e6beSJim Jagielski### Run the gate
68388d90fbSJim Jagielski
69388d90fbSJim Jagielski    python3 -I gate.py <tag> --stages corpus,validate,dump,diff,fixtures --modes ext,strict,v14,x14 --port 2900
70388d90fbSJim Jagielski    python3 -I gate.py <tag2> --prev runs/gate-<tag> --stages corpus,validate,dump,diff,fixtures --modes ext,strict,v13,x13,v14,x14 --port 2900
71388d90fbSJim Jagielski
72388d90fbSJim JagielskiThe default stage list also has `refresh`, which copies rebuilt libraries from `main/solver` into `app/` and fails if there is no build, so leave it out unless you built the office. The default modes are `ext,strict`.
73388d90fbSJim Jagielski
74388d90fbSJim Jagielski`gate.py` saves the corpus (the documents found under `main/` by `make-jobs.sh`) in each mode, validates the packages, reloads and dumps every saved document, and compares with an earlier run. It writes `runs/gate-<tag>/results.json`, resumes where it stopped, and exits 0 only if every stage passed. Read the `diff` entry of `results.json` as well as the exit status.
75388d90fbSJim Jagielski
76388d90fbSJim Jagielski- `runs/` is ignored by git and grows to many GB, so it holds the only copy of the earlier runs a gate compares with.
77388d90fbSJim Jagielski- `baseline/` has error kinds for `ext`, `strict`, `x14` and an empty `v14`. A gate in `v13` or `x13` mode has nothing to compare with until you pass `--prev` from a run that has them, so the first command leaves those modes out.
78388d90fbSJim Jagielski- The gate takes the list of documents from `--prev` when given, so the same documents are saved each time.
79388d90fbSJim Jagielski- Do not start your own office on the gate's ports: the `--port` value up to that value plus 35.
80388d90fbSJim Jagielski- To test rebuilt modules, add `refresh` to `--stages` (and `build` with `--build <modules>`), or copy libraries into `app/` with `./refresh-app.sh`, with no office running. The default `--libs` are `libxo`, `libsw`, `libsc`, `libsd` and `libsfx`.
81388d90fbSJim Jagielski
82388d90fbSJim Jagielski**Without the gate**, the individual steps (`make-jobs.sh`, `drive.sh`, `validate.py`, `report.py`, `compare.py`) are listed under "Running a corpus" and "Checking a change" in the README. `calcval.py` evaluates the OpenFormula cases in Calc.
83388d90fbSJim Jagielski
84388d90fbSJim Jagielski## What has been run
85388d90fbSJim Jagielski
86388d90fbSJim JagielskiThe selftests of both harnesses pass from a clean export of `trunk`. The office-driven parts of `aoo-test` and the gates were run in the development tree on macOS. Not run when this page was written: either harness from a clean export with an office, and a first gate with no `--prev` (including whether its `diff` stage passes without an earlier run).
87