diff --git a/Makefile b/Makefile index 670e4a2635ec..494e3ddb4c8f 100644 --- a/Makefile +++ b/Makefile @@ -292,7 +292,7 @@ contribs/dist: .build/build-dll.timestamp mkdir -p $(dir $@) CI=true LANGUAGE=en_US buildtools/retry node buildtools/check-example.js \ .build/examples-hosted/$*.html - buildtools/check-example .build/examples-hosted/$*.html.png examples/$*-ref.png + buildtools/check-example --generate .build/examples-hosted/$*.html.png examples/$*-ref.png touch $@ .build/error.check.timestamp: .build/examples-ngeo.timestamp \ @@ -310,7 +310,7 @@ contribs/dist: .build/build-dll.timestamp mkdir -p $(dir $@) CI=true LANGUAGE=en_US buildtools/retry node buildtools/check-example.js \ .build/examples-hosted/contribs/gmf/$*.html - buildtools/check-example .build/examples-hosted/contribs/gmf/$*.html.png contribs/gmf/examples/$*-ref.png + buildtools/check-example --generate .build/examples-hosted/contribs/gmf/$*.html.png contribs/gmf/examples/$*-ref.png touch $@ .build/contribs/gmf/apps/%.check.timestamp: .build/gmf-apps.timestamp \ @@ -318,7 +318,7 @@ contribs/dist: .build/build-dll.timestamp mkdir -p $(dir $@) CI=true LANGUAGE=en_US buildtools/retry node buildtools/check-example.js \ .build/examples-hosted/contribs/gmf/apps/$*.html - buildtools/check-example .build/examples-hosted/contribs/gmf/apps/$*.html.png contribs/gmf/apps/$*-ref.png + buildtools/check-example --generate .build/examples-hosted/contribs/gmf/apps/$*.html.png contribs/gmf/apps/$*-ref.png touch $@ .build/test-check-example/%.check.timestamp: \ diff --git a/buildtools/check-example b/buildtools/check-example index 81afe2d4fa63..0b1ad5438dcf 100755 --- a/buildtools/check-example +++ b/buildtools/check-example @@ -21,6 +21,7 @@ # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +import argparse import os import shutil import subprocess @@ -42,6 +43,10 @@ def main(): Optional mask image (name from Reference image): examples/simple-mask.png Generate diff image (name from Generated image): .build/examples-hosted/simple-diff.png """ + parser = argparse.ArgumentParser(description=main.__doc__) + parser.add_argument("--generate", action="store_true", help="Regenerate the ref image") + args = parser.parse_args() + current = sys.argv[1] ref = sys.argv[2] mask = ref.replace("-ref", "-mask") @@ -56,12 +61,10 @@ def main(): subprocess.run(["gm", "composite", "-compose", "Multiply", old_current, mask, current], check=True) subprocess.run(["gm", "composite", "-compose", "Multiply", old_ref, mask, ref], check=True) - # Set to True to regenerate ref images - if False: - if "/error-" not in ref: - shutil.copyfile(current, old_ref) - shutil.copyfile(current, ref) - sys.exit(0) + if args.generate and "/error-" not in ref: + shutil.copyfile(current, old_ref) + shutil.copyfile(current, ref) + sys.exit(0) result = subprocess.run( [ "gm",