Skip to content

Commit

Permalink
Better regenerate process
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrunner committed Aug 27, 2024
1 parent 021fb53 commit 32e4a64
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand All @@ -310,15 +310,15 @@ 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 \
.build/httpserver.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: \
Expand Down
21 changes: 13 additions & 8 deletions buildtools/check-example
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -42,8 +43,14 @@ 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
"""
current = sys.argv[1]
ref = sys.argv[2]
parser = argparse.ArgumentParser(description=main.__doc__)
parser.add_argument("--generate", action="store_true", help="Regenerate the ref image")
parser.add_argument("current", help="The current image")
parser.add_argument("ref", help="The reference image")
args = parser.parse_args()

current = args.current
ref = args.ref
mask = ref.replace("-ref", "-mask")
diff = current.replace(".html.png", "-diff.png")
old_ref = ref
Expand All @@ -56,12 +63,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",
Expand Down

0 comments on commit 32e4a64

Please sign in to comment.