mirror of
				https://github.com/johnwhitington/cpdf-source.git
				synced 2025-06-05 22:09:39 +02:00 
			
		
		
		
	Allow just a single test to be run
This commit is contained in:
		| @@ -536,7 +536,8 @@ type args = | |||||||
|    mutable resample_factor : float; |    mutable resample_factor : float; | ||||||
|    mutable resample_interpolate : bool; |    mutable resample_interpolate : bool; | ||||||
|    mutable jbig2_lossy_threshold : float; |    mutable jbig2_lossy_threshold : float; | ||||||
|    mutable extract_stream_decompress : bool} |    mutable extract_stream_decompress : bool; | ||||||
|  |    mutable verify_single : string option} | ||||||
|  |  | ||||||
| let args = | let args = | ||||||
|   {op = None; |   {op = None; | ||||||
| @@ -670,7 +671,8 @@ let args = | |||||||
|    resample_factor = 101.; |    resample_factor = 101.; | ||||||
|    resample_interpolate = false; |    resample_interpolate = false; | ||||||
|    jbig2_lossy_threshold = 0.85; |    jbig2_lossy_threshold = 0.85; | ||||||
|    extract_stream_decompress = false} |    extract_stream_decompress = false; | ||||||
|  |    verify_single = None} | ||||||
|  |  | ||||||
| (* Do not reset original_filename or cpdflin or was_encrypted or | (* Do not reset original_filename or cpdflin or was_encrypted or | ||||||
| was_decrypted_with_owner or recrypt or producer or creator or path_to_* or | was_decrypted_with_owner or recrypt or producer or creator or path_to_* or | ||||||
| @@ -792,7 +794,8 @@ let reset_arguments () = | |||||||
|   args.resample_interpolate <- false; |   args.resample_interpolate <- false; | ||||||
|   args.jbig2_lossy_threshold <- 0.85; |   args.jbig2_lossy_threshold <- 0.85; | ||||||
|   args.extract_stream_decompress <- false; |   args.extract_stream_decompress <- false; | ||||||
|   clear Cpdfdrawcontrol.fontpack_initialised |   clear Cpdfdrawcontrol.fontpack_initialised; | ||||||
|  |   args.verify_single <- None | ||||||
|  |  | ||||||
| (* Prefer a) the one given with -cpdflin b) a local cpdflin, c) otherwise assume | (* Prefer a) the one given with -cpdflin b) a local cpdflin, c) otherwise assume | ||||||
| installed at a system place *) | installed at a system place *) | ||||||
| @@ -2819,6 +2822,7 @@ and specs = | |||||||
|    ("-obj", Arg.String setprintobj, "Print object"); |    ("-obj", Arg.String setprintobj, "Print object"); | ||||||
|    ("-json", Arg.Unit (fun () -> args.format_json <- true), "Format output as JSON"); |    ("-json", Arg.Unit (fun () -> args.format_json <- true), "Format output as JSON"); | ||||||
|    ("-verify", Arg.String (fun s -> setop (Verify s) ()), "Verify conformance to a standard"); |    ("-verify", Arg.String (fun s -> setop (Verify s) ()), "Verify conformance to a standard"); | ||||||
|  |    ("-verify-single", Arg.String (fun s -> args.verify_single <- Some s), "Verify a single test"); | ||||||
|    ("-mark-as", Arg.String (fun s -> setop (MarkAs s) ()), "Mark as conforming to a standard"); |    ("-mark-as", Arg.String (fun s -> setop (MarkAs s) ()), "Mark as conforming to a standard"); | ||||||
|    ("-remove-mark", Arg.String (fun s -> setop (RemoveMark s) ()), "Remove conformance mark"); |    ("-remove-mark", Arg.String (fun s -> setop (RemoveMark s) ()), "Remove conformance mark"); | ||||||
|    ("-extract-struct-tree", Arg.Unit (fun () -> setop ExtractStructTree ()), "Extract structure tree in JSON format"); |    ("-extract-struct-tree", Arg.Unit (fun () -> setop ExtractStructTree ()), "Extract structure tree in JSON format"); | ||||||
| @@ -4486,9 +4490,10 @@ let go () = | |||||||
|       begin match standard with |       begin match standard with | ||||||
|       | "PDF/UA-1(matterhorn)" -> |       | "PDF/UA-1(matterhorn)" -> | ||||||
|           let pdf = get_single_pdf args.op false in |           let pdf = get_single_pdf args.op false in | ||||||
|  |           let testname = match args.verify_single with None -> "" | Some x -> x in | ||||||
|             if args.format_json |             if args.format_json | ||||||
|               then flprint (Cpdfyojson.Safe.pretty_to_string (Cpdfua.test_matterhorn_json pdf)) |               then flprint (Cpdfyojson.Safe.pretty_to_string (Cpdfua.test_matterhorn_json pdf testname)) | ||||||
|               else Cpdfua.test_matterhorn_print pdf |               else Cpdfua.test_matterhorn_print pdf testname | ||||||
|       | _ -> error "Unknown verification type." |       | _ -> error "Unknown verification type." | ||||||
|       end |       end | ||||||
|   | Some (MarkAs standard) -> |   | Some (MarkAs standard) -> | ||||||
|   | |||||||
							
								
								
									
										23
									
								
								cpdfua.ml
									
									
									
									
									
								
							
							
						
						
									
										23
									
								
								cpdfua.ml
									
									
									
									
									
								
							| @@ -1302,9 +1302,16 @@ let matterhorn = | |||||||
|    ("31-030", "One or more characters used in text showing operators reference the .notdef glyph.", "UA1:7.21.8-1", matterhorn_31_030); |    ("31-030", "One or more characters used in text showing operators reference the .notdef glyph.", "UA1:7.21.8-1", matterhorn_31_030); | ||||||
|   ] |   ] | ||||||
|  |  | ||||||
| (* FIXME Allow the use of just a single test, and expose it in cpdf command line *) | let test_matterhorn pdf testname = | ||||||
|  |   let tests = | ||||||
| let test_matterhorn pdf = |     match testname with | ||||||
|  |     | "" -> matterhorn | ||||||
|  |     | n ->  | ||||||
|  |         match keep (fun (n', _, _, _) -> n' = n) matterhorn with | ||||||
|  |         | [] -> error "test not found" | ||||||
|  |         | [t] -> [t] | ||||||
|  |         | _ -> error "duplicate test" | ||||||
|  |   in | ||||||
|   (* A circularity in the role map prevents all structure checks, so we do it first at stop if it fails. *) |   (* A circularity in the role map prevents all structure checks, so we do it first at stop if it fails. *) | ||||||
|   let circularity_error = |   let circularity_error = | ||||||
|     try matterhorn_02_003 0 0 pdf; [] with |     try matterhorn_02_003 0 0 pdf; [] with | ||||||
| @@ -1320,21 +1327,21 @@ let test_matterhorn pdf = | |||||||
|            | MatterhornError extra -> Some (name, error, section, extra) |            | MatterhornError extra -> Some (name, error, section, extra) | ||||||
|            | MatterhornUnimplemented -> None |            | MatterhornUnimplemented -> None | ||||||
|            | e -> Some (name, "Incomplete", section, `String ("ERROR: " ^ Printexc.to_string e))) |            | e -> Some (name, "Incomplete", section, `String ("ERROR: " ^ Printexc.to_string e))) | ||||||
|         matterhorn |         tests | ||||||
|  |  | ||||||
| let test_matterhorn_print pdf = | let test_matterhorn_print pdf testname = | ||||||
|   iter |   iter | ||||||
|     (fun (name, error, section, extra) -> |     (fun (name, error, section, extra) -> | ||||||
|        Printf.eprintf "%s %s %s %s\n" name section error |        Printf.eprintf "%s %s %s %s\n" name section error | ||||||
|        (if extra = `Null then "" else "(" ^ Cpdfyojson.Safe.to_string extra ^ ")")) |        (if extra = `Null then "" else "(" ^ Cpdfyojson.Safe.to_string extra ^ ")")) | ||||||
|     (test_matterhorn pdf) |     (test_matterhorn pdf testname) | ||||||
|  |  | ||||||
| let test_matterhorn_json pdf = | let test_matterhorn_json pdf testname = | ||||||
|   `List |   `List | ||||||
|     (map |     (map | ||||||
|       (fun (name, error, section, extra) -> |       (fun (name, error, section, extra) -> | ||||||
|         `Assoc [("name", `String name); ("section", `String section); ("error", `String error); ("extra", extra)]) |         `Assoc [("name", `String name); ("section", `String section); ("error", `String error); ("extra", extra)]) | ||||||
|       (test_matterhorn pdf)) |       (test_matterhorn pdf testname)) | ||||||
|  |  | ||||||
| let pdfua_marker = | let pdfua_marker = | ||||||
|   Cpdfmetadata.(E (((rdf, "Description"), [((rdf, "about"), ""); ((Cpdfxmlm.ns_xmlns, "pdfuaid"), pdfuaid)]), [E (((pdfuaid, "part"), []), [D "1"])]))  |   Cpdfmetadata.(E (((rdf, "Description"), [((rdf, "about"), ""); ((Cpdfxmlm.ns_xmlns, "pdfuaid"), pdfuaid)]), [E (((pdfuaid, "part"), []), [D "1"])]))  | ||||||
|   | |||||||
| @@ -1,7 +1,7 @@ | |||||||
| (** PDF/UA *) | (** PDF/UA *) | ||||||
| val test_matterhorn_print : Pdf.t -> unit | val test_matterhorn_print : Pdf.t -> string -> unit | ||||||
|  |  | ||||||
| val test_matterhorn_json : Pdf.t -> Cpdfyojson.Safe.t | val test_matterhorn_json : Pdf.t -> string -> Cpdfyojson.Safe.t | ||||||
|  |  | ||||||
| val mark : Pdf.t -> unit | val mark : Pdf.t -> unit | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user