Add another presubmit check for fpdfview_c_api_test.c.
Add another presubmit check to keep fpdfview_c_api_test.c in order.
There already exists one in public/, but that does not catch the case
where one modifies fpdfview_c_api_test.c without touching files in
public/.
Change-Id: I1f557449c6a8e442ab8a23f089620d436a2dc155
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/57791
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/fpdfsdk/PRESUBMIT.py b/fpdfsdk/PRESUBMIT.py
new file mode 100644
index 0000000..a74a4e5
--- /dev/null
+++ b/fpdfsdk/PRESUBMIT.py
@@ -0,0 +1,40 @@
+# Copyright 2019 The PDFium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""Presubmit script for pdfium.
+
+See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts
+for more details about the presubmit API built into depot_tools.
+"""
+
+def _IsApiTestFile(affected_file):
+ return affected_file.LocalPath() == 'fpdfsdk/fpdf_view_c_api_test.c'
+
+
+def _CheckApiTestFile(input_api, output_api):
+ """Checks that the public headers match the API tests."""
+ src_path = input_api.os_path.dirname(input_api.PresubmitLocalPath())
+ if all([not _IsApiTestFile(f) for f in input_api.AffectedSourceFiles([])]):
+ return []
+
+ check_script = input_api.os_path.join(
+ src_path, 'testing' , 'tools' , 'api_check.py')
+ try:
+ input_api.subprocess.check_output(check_script)
+ return []
+ except input_api.subprocess.CalledProcessError as error:
+ return [output_api.PresubmitError('api_check.py failed:',
+ long_text=error.output)]
+
+
+def CheckChangeOnUpload(input_api, output_api):
+ results = []
+ results += _CheckApiTestFile(input_api, output_api)
+ return results
+
+
+def CheckChangeOnCommit(input_api, output_api):
+ results = []
+ results += _CheckApiTestFile(input_api, output_api)
+ return results