script/commit-current-upstream-policy-docs is now script/write-upstream-policy-files: it writes the policy files and commits nothing. script/update-policy is now script/commit-upstream-policy-files, and make update-policy is now make commit-upstream-policy-files. test/update-policy.sh follows. Behaviour is unchanged. Model: opus-5-5
This commit is contained in:
1 parent
ed60414378
commit
f0ec2f38a8
11 files changed
+240
-232
No files matched your search
@@ -1,14 +1,15 @@
|
||||
#!/bin/sh
|
||||
# test/update-policy.sh: test script/commit-current-upstream-policy-docs
|
||||
# and script/update-policy on throwaway repos. Each scenario gets one
|
||||
# temp directory holding a repo, its local bare origin, a local git
|
||||
# repository of the canonical files in place of prompts, and a stub curl
|
||||
# that serves them, so nothing touches the network.
|
||||
# test/commit-upstream-policy-files.sh: test
|
||||
# script/write-upstream-policy-files and script/commit-upstream-policy-files
|
||||
# on throwaway repos. Each scenario gets one temp directory holding a
|
||||
# repo, its local bare origin, a local git repository of the canonical
|
||||
# files in place of prompts, and a stub curl that serves them, so nothing
|
||||
# touches the network.
|
||||
set -eu
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "$0")/.." && pwd -P)/script"
|
||||
COMMIT_CURRENT_UPSTREAM_POLICY_DOCS="$SCRIPT_DIR/commit-current-upstream-policy-docs"
|
||||
UPDATE_POLICY="$SCRIPT_DIR/update-policy"
|
||||
WRITE_UPSTREAM_POLICY_FILES="$SCRIPT_DIR/write-upstream-policy-files"
|
||||
COMMIT_UPSTREAM_POLICY_FILES="$SCRIPT_DIR/commit-upstream-policy-files"
|
||||
|
||||
dir=""
|
||||
trap 'rm -rf "$dir"' EXIT
|
||||
@@ -60,8 +61,8 @@ case "$url" in
|
||||
"$HASH" 0000000000000000000000000000000000000000 > "$output"
|
||||
fi
|
||||
;;
|
||||
"$site/raw/branch/main/script/commit-current-upstream-policy-docs")
|
||||
serve_file script/commit-current-upstream-policy-docs
|
||||
"$site/raw/branch/main/script/write-upstream-policy-files")
|
||||
serve_file script/write-upstream-policy-files
|
||||
;;
|
||||
"$site/compare/$first...$HASH.patch")
|
||||
git -C "$canonical" format-patch --stdout --root "$HASH" > "$output"
|
||||
@@ -79,7 +80,7 @@ EOF
|
||||
|
||||
write_canonical_files() {
|
||||
mkdir -p "$dir/canonical/prompts" "$dir/canonical/script"
|
||||
cp "$COMMIT_CURRENT_UPSTREAM_POLICY_DOCS" "$UPDATE_POLICY" \
|
||||
cp "$WRITE_UPSTREAM_POLICY_FILES" "$COMMIT_UPSTREAM_POLICY_FILES" \
|
||||
"$dir/canonical/script/"
|
||||
cat > "$dir/canonical/.gitignore" << 'EOF'
|
||||
*.log
|
||||
@@ -209,7 +210,7 @@ start_scenario() {
|
||||
git -C "$dir/repo" remote add origin "$dir/origin.git"
|
||||
|
||||
mkdir "$dir/repo/script"
|
||||
cp "$COMMIT_CURRENT_UPSTREAM_POLICY_DOCS" "$UPDATE_POLICY" \
|
||||
cp "$WRITE_UPSTREAM_POLICY_FILES" "$COMMIT_UPSTREAM_POLICY_FILES" \
|
||||
"$dir/repo/script/"
|
||||
printf '#!/bin/sh\necho example\n' > "$dir/repo/script/projectname"
|
||||
chmod +x "$dir/repo/script/projectname"
|
||||
@@ -257,18 +258,19 @@ remove_from_fixture() {
|
||||
before="$(git -C "$dir/repo" rev-parse HEAD)"
|
||||
}
|
||||
|
||||
run_update_policy() {
|
||||
run_commit_upstream_policy_files() {
|
||||
status=0
|
||||
(cd "$dir/repo" && PATH="$dir/bin:$PATH" TMPDIR="$dir/tmp" \
|
||||
script/update-policy "$@") > "$dir/output" 2>&1 || status=$?
|
||||
script/commit-upstream-policy-files "$@") > "$dir/output" 2>&1 ||
|
||||
status=$?
|
||||
}
|
||||
|
||||
# run_commit_current_upstream_policy_docs <arguments>: run the script in
|
||||
# this source tree, from outside the repo it updates.
|
||||
run_commit_current_upstream_policy_docs() {
|
||||
# run_write_upstream_policy_files <arguments>: run the script in this
|
||||
# source tree, from outside the repo it updates.
|
||||
run_write_upstream_policy_files() {
|
||||
status=0
|
||||
(cd "$dir" && PATH="$dir/bin:$PATH" TMPDIR="$dir/tmp" \
|
||||
"$COMMIT_CURRENT_UPSTREAM_POLICY_DOCS" "$@") > "$dir/output" 2>&1 ||
|
||||
"$WRITE_UPSTREAM_POLICY_FILES" "$@") > "$dir/output" 2>&1 ||
|
||||
status=$?
|
||||
}
|
||||
|
||||
@@ -345,7 +347,7 @@ test_own_entries_kept() {
|
||||
start_scenario "own entries kept in all four files"
|
||||
commit_and_push_fixture .gitignore .dockerignore .editorconfig \
|
||||
.golangci.yml .prettierrc REPO_POLICIES.md
|
||||
run_update_policy
|
||||
run_commit_upstream_policy_files
|
||||
expect_success
|
||||
|
||||
expect_file .gitignore << 'EOF'
|
||||
@@ -414,7 +416,7 @@ test_files_the_repo_lacks_are_written_whole() {
|
||||
remove_from_fixture REPO_POLICIES.md .gitignore .golangci.yml .gitea \
|
||||
docs/API_POLICIES.md docs/CODE_STYLEGUIDE_GO.md \
|
||||
docs/CODE_STYLEGUIDE_JS.md docs/CODE_STYLEGUIDE_PYTHON.md
|
||||
run_update_policy
|
||||
run_commit_upstream_policy_files
|
||||
expect_success
|
||||
|
||||
expect_same_as_canonical .gitignore
|
||||
@@ -446,7 +448,7 @@ test_language_files_need_a_source_file() {
|
||||
remove_from_fixture cmd .golangci.yml docs/CODE_STYLEGUIDE_GO.md \
|
||||
docs/GO_HTTP_SERVER_CONVENTIONS.md docs/CODE_STYLEGUIDE_JS.md \
|
||||
docs/CODE_STYLEGUIDE_PYTHON.md
|
||||
run_update_policy
|
||||
run_commit_upstream_policy_files
|
||||
expect_success
|
||||
expect_absent .golangci.yml
|
||||
expect_absent docs/CODE_STYLEGUIDE_GO.md
|
||||
@@ -462,7 +464,7 @@ test_javascript_source_brings_its_styleguide() {
|
||||
echo "export {}" > "$dir/repo/web.$extension"
|
||||
commit_and_push_fixture "web.$extension"
|
||||
remove_from_fixture docs/CODE_STYLEGUIDE_JS.md
|
||||
run_update_policy
|
||||
run_commit_upstream_policy_files
|
||||
expect_success
|
||||
expect_file docs/CODE_STYLEGUIDE_JS.md << 'EOF'
|
||||
new CODE_STYLEGUIDE_JS
|
||||
@@ -475,37 +477,37 @@ test_nothing_changed() {
|
||||
start_scenario "nothing changed"
|
||||
cp "$dir/canonical/.prettierrc" "$dir/repo/.prettierrc"
|
||||
commit_and_push_fixture .prettierrc
|
||||
run_update_policy
|
||||
run_commit_upstream_policy_files
|
||||
expect_success
|
||||
expect_output "nothing to commit"
|
||||
expect_nothing_written
|
||||
}
|
||||
|
||||
test_target_lacking_commit_current_upstream_policy_docs_gets_both_scripts() {
|
||||
start_scenario "a repo lacking script/commit-current-upstream-policy-docs gets it, and the current script/update-policy, in the commit"
|
||||
rm "$dir/repo/script/commit-current-upstream-policy-docs"
|
||||
echo "# An older version." >> "$dir/repo/script/update-policy"
|
||||
test_target_lacking_write_upstream_policy_files_gets_both_scripts() {
|
||||
start_scenario "a repo lacking script/write-upstream-policy-files gets it, and the current script/commit-upstream-policy-files, in the commit"
|
||||
rm "$dir/repo/script/write-upstream-policy-files"
|
||||
echo "# An older version." >> "$dir/repo/script/commit-upstream-policy-files"
|
||||
commit_and_push_fixture .prettierrc
|
||||
run_update_policy
|
||||
run_commit_upstream_policy_files
|
||||
expect_success
|
||||
expect_same_as_canonical script/commit-current-upstream-policy-docs
|
||||
expect_same_as_canonical script/update-policy
|
||||
expect_committed_executable script/commit-current-upstream-policy-docs
|
||||
expect_committed_executable script/update-policy
|
||||
expect_same_as_canonical script/write-upstream-policy-files
|
||||
expect_same_as_canonical script/commit-upstream-policy-files
|
||||
expect_committed_executable script/write-upstream-policy-files
|
||||
expect_committed_executable script/commit-upstream-policy-files
|
||||
expect_new_commit_not_pushed
|
||||
[ "$(files_in_commit)" = ".prettierrc script/commit-current-upstream-policy-docs script/update-policy " ] ||
|
||||
[ "$(files_in_commit)" = ".prettierrc script/commit-upstream-policy-files script/write-upstream-policy-files " ] ||
|
||||
fail "the commit holds other files: $(files_in_commit)"
|
||||
}
|
||||
|
||||
# The shell reads a script in blocks, so the padding makes it read the
|
||||
# last line only after main has returned. It finds that line only if
|
||||
# script/commit-current-upstream-policy-docs left the old file in place
|
||||
# under a new name. The old file is an earlier canonical version, so
|
||||
# script/commit-current-upstream-policy-docs replaces it.
|
||||
test_update_policy_replaces_itself() {
|
||||
start_scenario "script/update-policy replaces its own file and still exits 0"
|
||||
# script/write-upstream-policy-files left the old file in place under a
|
||||
# new name. The old file is an earlier canonical version, so
|
||||
# script/write-upstream-policy-files replaces it.
|
||||
test_commit_upstream_policy_files_replaces_itself() {
|
||||
start_scenario "script/commit-upstream-policy-files replaces its own file and still exits 0"
|
||||
{
|
||||
cat "$dir/repo/script/update-policy"
|
||||
cat "$dir/repo/script/commit-upstream-policy-files"
|
||||
i=0
|
||||
while [ "$i" -lt 2000 ]; do
|
||||
echo "# Padding."
|
||||
@@ -513,61 +515,62 @@ test_update_policy_replaces_itself() {
|
||||
done
|
||||
echo "echo 'the old file ran to its end'"
|
||||
} > "$dir/merged"
|
||||
cp "$dir/merged" "$dir/canonical/script/update-policy"
|
||||
cp "$dir/merged" "$dir/canonical/script/commit-upstream-policy-files"
|
||||
commit_canonical
|
||||
cp "$UPDATE_POLICY" "$dir/canonical/script/update-policy"
|
||||
cp "$COMMIT_UPSTREAM_POLICY_FILES" \
|
||||
"$dir/canonical/script/commit-upstream-policy-files"
|
||||
commit_canonical
|
||||
mv "$dir/merged" "$dir/repo/script/update-policy"
|
||||
chmod 755 "$dir/repo/script/update-policy"
|
||||
mv "$dir/merged" "$dir/repo/script/commit-upstream-policy-files"
|
||||
chmod 755 "$dir/repo/script/commit-upstream-policy-files"
|
||||
commit_and_push_fixture
|
||||
run_update_policy
|
||||
run_commit_upstream_policy_files
|
||||
expect_success
|
||||
expect_output "the old file ran to its end"
|
||||
expect_same_as_canonical script/update-policy
|
||||
expect_executable script/update-policy
|
||||
expect_same_as_canonical script/commit-upstream-policy-files
|
||||
expect_executable script/commit-upstream-policy-files
|
||||
expect_new_commit_not_pushed
|
||||
}
|
||||
|
||||
test_commit_current_upstream_policy_docs_with_path_commits_nothing() {
|
||||
start_scenario "script/commit-current-upstream-policy-docs with a path writes into that clone and commits nothing"
|
||||
rm "$dir/repo/script/commit-current-upstream-policy-docs" \
|
||||
"$dir/repo/script/update-policy"
|
||||
test_write_upstream_policy_files_with_path_commits_nothing() {
|
||||
start_scenario "script/write-upstream-policy-files with a path writes into that clone and commits nothing"
|
||||
rm "$dir/repo/script/write-upstream-policy-files" \
|
||||
"$dir/repo/script/commit-upstream-policy-files"
|
||||
commit_and_push_fixture .prettierrc
|
||||
run_commit_current_upstream_policy_docs "$dir/repo"
|
||||
run_write_upstream_policy_files "$dir/repo"
|
||||
expect_success
|
||||
expect_file .prettierrc << 'EOF'
|
||||
{ "tabWidth": 4 }
|
||||
EOF
|
||||
expect_same_as_canonical script/commit-current-upstream-policy-docs
|
||||
expect_same_as_canonical script/update-policy
|
||||
expect_executable script/commit-current-upstream-policy-docs
|
||||
expect_executable script/update-policy
|
||||
expect_same_as_canonical script/write-upstream-policy-files
|
||||
expect_same_as_canonical script/commit-upstream-policy-files
|
||||
expect_executable script/write-upstream-policy-files
|
||||
expect_executable script/commit-upstream-policy-files
|
||||
expect_no_commit
|
||||
[ "$(head -n 1 "$dir/output")" = "$HASH" ] ||
|
||||
fail "the first line of output is not the hash"
|
||||
expect_output "script/commit-current-upstream-policy-docs"
|
||||
expect_output "script/write-upstream-policy-files"
|
||||
[ -z "$(ls -A "$dir/tmp")" ] || fail "a temporary directory is left"
|
||||
}
|
||||
|
||||
test_commit_current_upstream_policy_docs_without_script_directory() {
|
||||
start_scenario "script/commit-current-upstream-policy-docs with a path writes both scripts into a clone with no script directory"
|
||||
test_write_upstream_policy_files_without_script_directory() {
|
||||
start_scenario "script/write-upstream-policy-files with a path writes both scripts into a clone with no script directory"
|
||||
commit_and_push_fixture .prettierrc
|
||||
remove_from_fixture script
|
||||
run_commit_current_upstream_policy_docs "$dir/repo"
|
||||
run_write_upstream_policy_files "$dir/repo"
|
||||
expect_success
|
||||
expect_same_as_canonical script/commit-current-upstream-policy-docs
|
||||
expect_same_as_canonical script/update-policy
|
||||
expect_executable script/commit-current-upstream-policy-docs
|
||||
expect_executable script/update-policy
|
||||
expect_same_as_canonical script/write-upstream-policy-files
|
||||
expect_same_as_canonical script/commit-upstream-policy-files
|
||||
expect_executable script/write-upstream-policy-files
|
||||
expect_executable script/commit-upstream-policy-files
|
||||
expect_no_commit
|
||||
}
|
||||
|
||||
test_commit_current_upstream_policy_docs_without_argument_updates_own_repo() {
|
||||
start_scenario "script/commit-current-upstream-policy-docs with no argument updates the repo it sits in"
|
||||
test_write_upstream_policy_files_without_argument_updates_own_repo() {
|
||||
start_scenario "script/write-upstream-policy-files with no argument updates the repo it sits in"
|
||||
commit_and_push_fixture .prettierrc
|
||||
status=0
|
||||
(cd "$dir" && PATH="$dir/bin:$PATH" \
|
||||
repo/script/commit-current-upstream-policy-docs) \
|
||||
repo/script/write-upstream-policy-files) \
|
||||
> "$dir/output" 2>&1 || status=$?
|
||||
expect_success
|
||||
expect_file .prettierrc << 'EOF'
|
||||
@@ -576,19 +579,19 @@ EOF
|
||||
expect_no_commit
|
||||
}
|
||||
|
||||
test_commit_current_upstream_policy_docs_bad_target() {
|
||||
start_scenario "script/commit-current-upstream-policy-docs refuses a path that is not the top of a clone"
|
||||
test_write_upstream_policy_files_bad_target() {
|
||||
start_scenario "script/write-upstream-policy-files refuses a path that is not the top of a clone"
|
||||
commit_and_push_fixture .prettierrc
|
||||
run_commit_current_upstream_policy_docs "$dir/repo/script"
|
||||
run_write_upstream_policy_files "$dir/repo/script"
|
||||
expect_failure
|
||||
expect_output "not the top of a git clone"
|
||||
run_commit_current_upstream_policy_docs "$dir/bin"
|
||||
run_write_upstream_policy_files "$dir/bin"
|
||||
expect_failure
|
||||
expect_output "not the top of a git clone"
|
||||
run_commit_current_upstream_policy_docs "$dir/no-such-directory"
|
||||
run_write_upstream_policy_files "$dir/no-such-directory"
|
||||
expect_failure
|
||||
expect_output "no such directory"
|
||||
run_commit_current_upstream_policy_docs "$dir/repo" extra
|
||||
run_write_upstream_policy_files "$dir/repo" extra
|
||||
expect_failure
|
||||
expect_output "usage:"
|
||||
expect_nothing_written
|
||||
@@ -597,13 +600,13 @@ test_commit_current_upstream_policy_docs_bad_target() {
|
||||
test_failed_fetch_stops() {
|
||||
for url in \
|
||||
"/api/v1/repos/sneak/prompts/branches/main" \
|
||||
"/raw/branch/main/script/commit-current-upstream-policy-docs" \
|
||||
"/raw/branch/main/script/write-upstream-policy-files" \
|
||||
"/compare/" \
|
||||
"/raw/commit/"; do
|
||||
start_scenario "a failed fetch of $url stops with nothing written"
|
||||
commit_and_push_fixture .gitignore .prettierrc REPO_POLICIES.md
|
||||
FAIL_URL="$url"
|
||||
run_update_policy
|
||||
run_commit_upstream_policy_files
|
||||
expect_failure
|
||||
expect_output "cannot fetch"
|
||||
expect_nothing_written
|
||||
@@ -614,7 +617,7 @@ test_one_missing_file_stops_all() {
|
||||
start_scenario "one file missing from prompts stops before any file is written"
|
||||
rm "$dir/canonical/prompts/REPO_POLICIES.md"
|
||||
commit_and_push_fixture .prettierrc REPO_POLICIES.md
|
||||
run_update_policy
|
||||
run_commit_upstream_policy_files
|
||||
expect_failure
|
||||
expect_output "cannot fetch"
|
||||
expect_nothing_written
|
||||
@@ -624,7 +627,7 @@ test_branch_response_without_hash_stops() {
|
||||
start_scenario "a branch response with no commit hash stops"
|
||||
commit_and_push_fixture .prettierrc
|
||||
BAD_BRANCH_JSON=yes
|
||||
run_update_policy
|
||||
run_commit_upstream_policy_files
|
||||
expect_failure
|
||||
expect_output "no commit hash"
|
||||
expect_nothing_written
|
||||
@@ -642,7 +645,7 @@ test_own_entry_above_closing_comment() {
|
||||
mv "$dir/merged" "$dir/repo/$file"
|
||||
commit_and_push_fixture .gitignore .dockerignore .editorconfig \
|
||||
.prettierrc REPO_POLICIES.md
|
||||
run_update_policy
|
||||
run_commit_upstream_policy_files
|
||||
expect_failure
|
||||
expect_output "$file has entries"
|
||||
expect_output "/myapp"
|
||||
@@ -656,7 +659,7 @@ test_uncommitted_change_stops() {
|
||||
start_scenario "a carried file with uncommitted changes stops"
|
||||
commit_and_push_fixture .prettierrc REPO_POLICIES.md
|
||||
echo "uncommitted" >> "$dir/repo/REPO_POLICIES.md"
|
||||
run_update_policy
|
||||
run_commit_upstream_policy_files
|
||||
expect_failure
|
||||
expect_output "REPO_POLICIES.md has uncommitted changes"
|
||||
expect_file REPO_POLICIES.md << 'EOF'
|
||||
@@ -667,14 +670,14 @@ EOF
|
||||
}
|
||||
|
||||
test_untracked_script_stops() {
|
||||
start_scenario "an untracked script/commit-current-upstream-policy-docs is not overwritten"
|
||||
rm "$dir/repo/script/commit-current-upstream-policy-docs"
|
||||
start_scenario "an untracked script/write-upstream-policy-files is not overwritten"
|
||||
rm "$dir/repo/script/write-upstream-policy-files"
|
||||
commit_and_push_fixture .prettierrc
|
||||
echo "our own script" > "$dir/repo/script/commit-current-upstream-policy-docs"
|
||||
run_commit_current_upstream_policy_docs "$dir/repo"
|
||||
echo "our own script" > "$dir/repo/script/write-upstream-policy-files"
|
||||
run_write_upstream_policy_files "$dir/repo"
|
||||
expect_failure
|
||||
expect_output "script/commit-current-upstream-policy-docs has uncommitted changes"
|
||||
expect_file script/commit-current-upstream-policy-docs << 'EOF'
|
||||
expect_output "script/write-upstream-policy-files has uncommitted changes"
|
||||
expect_file script/write-upstream-policy-files << 'EOF'
|
||||
our own script
|
||||
EOF
|
||||
expect_no_commit
|
||||
@@ -686,7 +689,7 @@ test_ignored_file_stops() {
|
||||
remove_from_fixture docs/API_POLICIES.md
|
||||
echo "docs/API_POLICIES.md" >> "$dir/repo/.git/info/exclude"
|
||||
echo "our own notes" > "$dir/repo/docs/API_POLICIES.md"
|
||||
run_commit_current_upstream_policy_docs "$dir/repo"
|
||||
run_write_upstream_policy_files "$dir/repo"
|
||||
expect_failure
|
||||
expect_output "docs/API_POLICIES.md is ignored by git"
|
||||
expect_file docs/API_POLICIES.md << 'EOF'
|
||||
@@ -696,12 +699,12 @@ EOF
|
||||
}
|
||||
|
||||
test_own_script_stops() {
|
||||
for script in script/commit-current-upstream-policy-docs \
|
||||
script/update-policy; do
|
||||
for script in script/write-upstream-policy-files \
|
||||
script/commit-upstream-policy-files; do
|
||||
start_scenario "a tracked $script with a line the canonical file has never held stops"
|
||||
echo "echo our own script" >> "$dir/repo/$script"
|
||||
commit_and_push_fixture .prettierrc
|
||||
run_update_policy
|
||||
run_commit_upstream_policy_files
|
||||
expect_failure
|
||||
expect_output "$script has lines"
|
||||
expect_output "echo our own script"
|
||||
@@ -713,7 +716,7 @@ test_gitignore_lacks_canonical_last_line() {
|
||||
start_scenario ".gitignore lacking the canonical last line keeps the repo's own line below the canonical content"
|
||||
printf '*.log\n\n# A comment of our own.\n/myapp\n' > "$dir/repo/.gitignore"
|
||||
commit_and_push_fixture .gitignore .prettierrc
|
||||
run_update_policy
|
||||
run_commit_upstream_policy_files
|
||||
expect_success
|
||||
expect_file .gitignore << 'EOF'
|
||||
*.log
|
||||
@@ -736,7 +739,7 @@ test_editorconfig_lacks_canonical_last_line() {
|
||||
start_scenario ".editorconfig lacking the canonical last line with a line of its own stops"
|
||||
printf 'root = true\n[*.py]\nindent_size = 2\n' > "$dir/repo/.editorconfig"
|
||||
commit_and_push_fixture .editorconfig .prettierrc
|
||||
run_update_policy
|
||||
run_commit_upstream_policy_files
|
||||
expect_failure
|
||||
expect_output ".editorconfig lacks this line"
|
||||
expect_output "[*.py]"
|
||||
@@ -766,7 +769,7 @@ linters:
|
||||
- pkg: example.com/other
|
||||
EOF
|
||||
commit_and_push_fixture .golangci.yml .prettierrc
|
||||
run_update_policy
|
||||
run_commit_upstream_policy_files
|
||||
expect_failure
|
||||
expect_output "no deny list in its test-support rule"
|
||||
expect_nothing_written
|
||||
@@ -781,7 +784,7 @@ test_own_golangci_setting_stops() {
|
||||
- pattern: model.Operator
|
||||
EOF
|
||||
commit_and_push_fixture .golangci.yml .prettierrc
|
||||
run_update_policy
|
||||
run_commit_upstream_policy_files
|
||||
expect_failure
|
||||
expect_output ".golangci.yml has lines"
|
||||
expect_output "forbidigo:"
|
||||
@@ -795,7 +798,7 @@ test_source_repo_stops() {
|
||||
mkdir "$dir/repo/prompts"
|
||||
echo "policy" > "$dir/repo/prompts/REPO_POLICIES.md"
|
||||
commit_and_push_fixture .prettierrc prompts/REPO_POLICIES.md
|
||||
run_update_policy
|
||||
run_commit_upstream_policy_files
|
||||
expect_failure
|
||||
expect_output "this repo is the source of the policy files"
|
||||
expect_nothing_written
|
||||
@@ -806,7 +809,7 @@ test_staged_file_stays_out_of_commit() {
|
||||
commit_and_push_fixture .prettierrc
|
||||
echo "notes" > "$dir/repo/notes.txt"
|
||||
git -C "$dir/repo" add notes.txt
|
||||
run_update_policy
|
||||
run_commit_upstream_policy_files
|
||||
expect_success
|
||||
[ "$(files_in_commit)" = ".prettierrc " ] ||
|
||||
fail "the commit holds more than the policy file"
|
||||
@@ -814,10 +817,10 @@ test_staged_file_stays_out_of_commit() {
|
||||
fail "notes.txt is no longer staged"
|
||||
}
|
||||
|
||||
test_update_policy_takes_no_argument() {
|
||||
start_scenario "script/update-policy refuses an argument"
|
||||
test_commit_upstream_policy_files_takes_no_argument() {
|
||||
start_scenario "script/commit-upstream-policy-files refuses an argument"
|
||||
commit_and_push_fixture .prettierrc
|
||||
run_update_policy "$HASH"
|
||||
run_commit_upstream_policy_files "$HASH"
|
||||
expect_failure
|
||||
expect_output "usage:"
|
||||
expect_nothing_written
|
||||
@@ -836,7 +839,7 @@ expect_former_canonical_line_replaced() {
|
||||
mv "$dir/merged" "$dir/repo/$1"
|
||||
commit_and_push_fixture "$1" .prettierrc
|
||||
|
||||
run_update_policy
|
||||
run_commit_upstream_policy_files
|
||||
expect_success
|
||||
if grep -q -F -x -e "$2" "$dir/repo/$1"; then
|
||||
fail "$1 still has: $2"
|
||||
@@ -855,10 +858,10 @@ test_former_canonical_gitignore_line_replaced() {
|
||||
}
|
||||
|
||||
test_former_canonical_script_line_replaced() {
|
||||
start_scenario "a script/commit-current-upstream-policy-docs line an earlier canonical commit held is replaced"
|
||||
start_scenario "a script/write-upstream-policy-files line an earlier canonical commit held is replaced"
|
||||
expect_former_canonical_line_replaced \
|
||||
script/commit-current-upstream-policy-docs "echo an older version"
|
||||
expect_same_as_canonical script/commit-current-upstream-policy-docs
|
||||
script/write-upstream-policy-files "echo an older version"
|
||||
expect_same_as_canonical script/write-upstream-policy-files
|
||||
}
|
||||
|
||||
# A line another file's history removed does not count as held by this
|
||||
@@ -873,7 +876,7 @@ test_line_removed_from_another_file_still_stops() {
|
||||
{ echo "*.old"; cat "$dir/repo/.gitignore"; } > "$dir/merged"
|
||||
mv "$dir/merged" "$dir/repo/.gitignore"
|
||||
commit_and_push_fixture .gitignore .prettierrc
|
||||
run_update_policy
|
||||
run_commit_upstream_policy_files
|
||||
expect_failure
|
||||
expect_output ".gitignore has entries"
|
||||
expect_output "*.old"
|
||||
@@ -886,12 +889,12 @@ main() {
|
||||
test_language_files_need_a_source_file
|
||||
test_javascript_source_brings_its_styleguide
|
||||
test_nothing_changed
|
||||
test_target_lacking_commit_current_upstream_policy_docs_gets_both_scripts
|
||||
test_update_policy_replaces_itself
|
||||
test_commit_current_upstream_policy_docs_with_path_commits_nothing
|
||||
test_commit_current_upstream_policy_docs_without_script_directory
|
||||
test_commit_current_upstream_policy_docs_without_argument_updates_own_repo
|
||||
test_commit_current_upstream_policy_docs_bad_target
|
||||
test_target_lacking_write_upstream_policy_files_gets_both_scripts
|
||||
test_commit_upstream_policy_files_replaces_itself
|
||||
test_write_upstream_policy_files_with_path_commits_nothing
|
||||
test_write_upstream_policy_files_without_script_directory
|
||||
test_write_upstream_policy_files_without_argument_updates_own_repo
|
||||
test_write_upstream_policy_files_bad_target
|
||||
test_failed_fetch_stops
|
||||
test_one_missing_file_stops_all
|
||||
test_branch_response_without_hash_stops
|
||||
@@ -908,12 +911,12 @@ main() {
|
||||
test_own_golangci_setting_stops
|
||||
test_source_repo_stops
|
||||
test_staged_file_stays_out_of_commit
|
||||
test_update_policy_takes_no_argument
|
||||
test_commit_upstream_policy_files_takes_no_argument
|
||||
test_former_canonical_golangci_line_replaced
|
||||
test_former_canonical_gitignore_line_replaced
|
||||
test_former_canonical_script_line_replaced
|
||||
test_line_removed_from_another_file_still_stops
|
||||
echo "update-policy tests passed"
|
||||
echo "commit-upstream-policy-files tests passed"
|
||||
}
|
||||
|
||||
main "$@"
|
||||
Reference in new issue
Block a user