-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
move pixel-tests to use git-utils.sh, including caching #15995
Changes from all commits
7794bd2
4cae92e
2617f41
4ca93d7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ | |
GITHUB_BASE="${GITHUB_BASE:-cockpit-project/cockpit}" | ||
GITHUB_REPOSITORY="${GITHUB_BASE%/*}/${GITHUB_REPO}" | ||
HTTPS_REMOTE="https://github.com/${GITHUB_REPOSITORY}" | ||
SSH_REMOTE="git@github.com:${GITHUB_REPOSITORY}" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. FTR, :+1 for calling this SSH_REMOTE instead of PUSH_REMOTE, as pushing may happen over https as well. |
||
|
||
CACHE_DIR="${XDG_CACHE_HOME-${HOME}/.cache}/cockpit-dev/${GITHUB_REPOSITORY}.git" | ||
|
||
|
@@ -108,3 +109,13 @@ unpack_from_cache() { | |
message "UNPACK" "${SUBDIR} [ref: $1]" | ||
git_cache archive "$1" "${SUBDIR}" | tar -x --touch "${SUBDIR}" | ||
} | ||
|
||
cmd_remove() { | ||
# if we did this for ourselves the rm is enough, but it might be the case | ||
# that someone actually used git-submodule to fetch this, so clean up after | ||
# that as well. NB: deinit nicely recreates the empty directory for us. | ||
message REMOVE "${SUBDIR}" | ||
rm -rf "${SUBDIR}" | ||
git submodule deinit "${SUBDIR}" | ||
rm -rf "$(git rev-parse --absolute-git-dir)/modules/${SUBDIR}" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,35 @@ | ||
#!/bin/bash | ||
|
||
set -eu | ||
|
||
SUBDIR=test/reference | ||
REPO=pixel-test-reference | ||
|
||
GITHUB_BASE="${GITHUB_BASE:-cockpit-project/cockpit}" | ||
GITHUB_REPOSITORY="${GITHUB_BASE%/*}/${REPO}" | ||
CLONE_REMOTE="https://github.com/${GITHUB_REPOSITORY}" | ||
PUSH_REMOTE="git@github.com:${GITHUB_REPOSITORY}" | ||
GITHUB_REPO='pixel-test-reference' | ||
SUBDIR='test/reference' | ||
|
||
message() { | ||
[ "${V-}" != 0 ] || printf " %-8s %s\n" "$1" "$2" | ||
} | ||
set -eu | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tiny style nitpick: This ought to stay the first line in this (and every) script. Presumably it just got moved by accident? |
||
cd "$(realpath -m "$0"/../../..)" | ||
. pkg/lib/git-utils.sh | ||
|
||
cmd_init() { | ||
git submodule add -b empty "$CLONE_REMOTE" "$SUBDIR" | ||
} | ||
|
||
cmd_checkout() { | ||
local sha="${1-$(get_index_gitlink node_modules)}" | ||
|
||
fetch_sha_to_cache "${sha}" | ||
cmd_remove | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not sure I like how On the one hand, removing untracked files will make it impossible for the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See comment above. I'd like your input to decide what to do here :) |
||
clone_from_cache "${sha}" | ||
} | ||
|
||
cmd_pull() { | ||
git submodule update --init -- "$SUBDIR" | ||
# Our main goal is to ensure that the test/reference from | ||
# the index is the one that we actually have. | ||
local sha="$(get_index_gitlink test/reference)" | ||
if [ ! -e test/reference/.git ]; then | ||
# nothing there yet... | ||
cmd_checkout "${sha}" | ||
elif [ "$(git -C test/reference rev-parse HEAD)" != "${sha}" ]; then | ||
# wrong thing there... | ||
cmd_checkout "${sha}" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks a bit odd to have two branches with exactly the same code. This could just |
||
fi | ||
} | ||
|
||
cmd_status() { | ||
|
@@ -45,7 +55,7 @@ cmd_push() { | |
fi | ||
tag="sha-$(git rev-parse HEAD)" | ||
[ $(git tag -l "$tag") ] || git tag "$tag" HEAD | ||
git push "$PUSH_REMOTE" "$tag" | ||
git push "$SSH_REMOTE" "$tag" | ||
) | ||
git add "$SUBDIR" | ||
} | ||
|
@@ -62,7 +72,7 @@ main() { | |
fi | ||
|
||
shift | ||
[ "${V-0}" = 0 ] || set -x | ||
[ -n "${quiet}" ] || set -x | ||
"cmd_$cmd" "$@" | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -662,6 +662,9 @@ def assert_pixels(self, selector, key, ignore=[]): | |
if not (Image and self.pixels_label and self.cdp and self.cdp.valid): | ||
return | ||
|
||
# Make sure everything is up to date. This is normally very fast. | ||
subprocess.check_call([f'{TEST_DIR}/common/pixel-tests', 'pull']) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This runs the risk of removing anything that is in test/reference/ and checking it out from scratch, right? That might remove files that the dev has moved into test/reference while working on new pixel tests, no? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is one of the reasons I wanted your review here. What do you want to do about this? Refuse to delete the old tree if it's not clean? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yes, that sounds good. Also, have a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll implement this. Thanks. |
||
|
||
self.call_js_func('ph_scrollIntoViewIfNeeded', selector) | ||
|
||
rect = self.call_js_func('ph_element_clip', selector) | ||
|
@@ -673,14 +676,10 @@ def relative_clip(sel): | |
r['x'] - rect['x'] + r['width'], | ||
r['y'] - rect['y'] + r['height']) | ||
|
||
reference_dir = os.path.join(TEST_DIR, 'reference') | ||
if not os.path.exists(os.path.join(reference_dir, '.git')): | ||
subprocess.check_call([f'{TEST_DIR}/common/pixel-tests', 'pull']) | ||
|
||
ignore_rects = list(map(relative_clip, map(lambda item: selector + " " + item, ignore))) | ||
base = self.pixels_label + "-" + key | ||
filename = base + "-pixels.png" | ||
ref_filename = os.path.join(reference_dir, filename) | ||
ref_filename = os.path.join(TEST_DIR, 'reference', filename) | ||
ret = self.cdp.invoke("Page.captureScreenshot", clip=rect, no_trace=True) | ||
png_now = base64.standard_b64decode(ret["data"]) | ||
png_ref = os.path.exists(ref_filename) and open(ref_filename, "rb").read() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it actually important to ship this now, when we haven't so far? (FTR, I'm fine with it, just wondering if that is coincidental, or deliberate)