apidoc_test.py (1523B)
1 # This Source Code Form is subject to the terms of the Mozilla Public 2 # License, v. 2.0. If a copy of the MPL was not distributed with this 3 # file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 5 import argparse 6 import subprocess as sp 7 import sys 8 9 # Run the doclet on the test package and verify that the output matches the 10 # expected output. 11 12 parser = argparse.ArgumentParser() 13 parser.add_argument("--javadoc") 14 parser.add_argument("--doclet-jar") 15 parser.add_argument("--java-root") 16 parser.add_argument("--out-dir") 17 parser.add_argument("--expected") 18 parser.add_argument("--expected-map") 19 args = parser.parse_args() 20 21 output = args.out_dir + "/api.txt" 22 23 sp.check_call([ 24 args.javadoc, 25 "-doclet", 26 "org.mozilla.doclet.ApiDoclet", 27 "-docletpath", 28 args.doclet_jar, 29 "-subpackages", 30 "org.mozilla.test", 31 "-sourcepath", 32 args.java_root, 33 "-root-dir", 34 args.java_root, 35 "-skip-class-regex", 36 "TestSkippedClass$:^org.mozilla.test.TestClass.TestSkippedClass2$", 37 "-output", 38 output, 39 ]) 40 41 result = sp.call([ 42 "python3", 43 "../apilint/src/main/resources/diff.py", 44 "--existing", 45 args.expected, 46 "--local", 47 output, 48 ]) 49 50 result_map = sp.call([ 51 "python3", 52 "../apilint/src/main/resources/diff.py", 53 "--existing", 54 args.expected_map, 55 "--local", 56 output + ".map", 57 ]) 58 59 # result == 0 from `diff` means that the files are identical 60 if result != 0 or result_map != 0: 61 print("") 62 print("ERROR: Doclet output differs from expected.") 63 sys.exit(1)