Skip to content
Myr

[Tests] `install_nvm_from_git`: stop git background gc/maintenance racing with cleanup

Before adoption: this commit came in with the history the project adopted, so no landing records it.

The test's `rm -rf "$NVM_DIR"` intermittently failed with `rm: cannot remove...: Directory not empty` and aborted under `set -e`. Cause: after the clone/fetch, git can spawn a detached background gc/maintenance process that keeps writing into the clone dir while `rm -rf` runs (a concurrent writer makes the final rmdir fail). It is not egress- or version-related (it reproduces with all endpoints allowed), and it is environment-timing dependent (recently became consistent on the GitHub runners). Disable git's background work for the test (gc.autoDetach / maintenance.auto) so all git operations finish synchronously, and retry the rm once as a safety net.

authored by Jordan Harband · committed by Jordan Harband · parent 61c9ff7 · Browse files · 1 file+6 added−3 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+6 added−3 removed

  • tests:+6 added−3 removed

1 file+6 added−3 removed

modified:test/install_script/install_nvm_from_git+6 added-3 removed
15 unmodified lines
16NVM_ENV=testing \. ../../install.sh1718set -ex1920git config --global gc.autoDetach false21git config --global maintenance.auto false2223# nvm_do_install is available24type install_nvm_from_git > /dev/null 2>&1 || die 'install_nvm_from_git is not available'2526test_step() {
69 unmodified lines
96 # Ensure it clones the repository for non existing directory97 test_step "Clones repo $message"98 install_nvm_from_git99 test_install_data "$(get_head_ref)" "$(get_head_changeset)" "$message" "$ref" "$changeset" "$avoid_ref"97 rm -rf "$NVM_DIR"100 rm -rf "$NVM_DIR" || { sleep 1; rm -rf "$NVM_DIR"; }101102 # Ensure it initializes the repository for an empty existing repository103 mkdir -p "$NVM_DIR" || die 'Unable to create directory'104 test_step "Initialize repo $message"105 install_nvm_from_git106 test_install_data "$(get_head_ref)" "$(get_head_changeset)" "$message" "$ref" "$changeset" "$avoid_ref"104 rm -rf "$NVM_DIR"107 rm -rf "$NVM_DIR" || { sleep 1; rm -rf "$NVM_DIR"; }108109 # Ensure it updates the repository for an existing git repository110 git clone "$(nvm_source "git")" -b "v0.36.0" --depth=2 "$NVM_DIR" || die 'Unable to clone repository'111 step_to_previous_changeset112 test_step "Updates repo $message"113 install_nvm_from_git114 test_install_data "$(get_head_ref)" "$(get_head_changeset)" "$message" "$ref" "$changeset" "$avoid_ref"112 rm -rf "$NVM_DIR"115 rm -rf "$NVM_DIR" || { sleep 1; rm -rf "$NVM_DIR"; }116}117118# Handle latest version119test_install "" "latest version" "$(nvm_latest_version)"
13 unmodified lines