diff --git a/test/functional/bundleadd_v2/add-include.bats b/test/functional/bundleadd_v2/add-include.bats index 76d49088..20552902 100755 --- a/test/functional/bundleadd_v2/add-include.bats +++ b/test/functional/bundleadd_v2/add-include.bats @@ -9,8 +9,6 @@ test_setup() { create_bundle -n test-bundle2 -f /bar/test-file2 "$TEST_NAME" # add test-bundle2 as a dependency of test-bundle1 add_dependency_to_manifest "$TEST_NAME"/web-dir/10/Manifest.test-bundle1 test-bundle2 - # since we modified one manifest we need to update that in MoM too, so re add the bundle manifest - update_hashes_in_mom "$TEST_NAME"/web-dir/10/Manifest.MoM } diff --git a/test/functional/bundlelist_v2/list-deps-flat.bats b/test/functional/bundlelist_v2/list-deps-flat.bats index 1d390f6e..6a607371 100755 --- a/test/functional/bundlelist_v2/list-deps-flat.bats +++ b/test/functional/bundlelist_v2/list-deps-flat.bats @@ -11,7 +11,6 @@ test_setup() { # add bundle2 and 3 as dependencies of bundle1 add_dependency_to_manifest "$TEST_NAME"/web-dir/10/Manifest.test-bundle1 test-bundle2 add_dependency_to_manifest "$TEST_NAME"/web-dir/10/Manifest.test-bundle1 test-bundle3 - update_hashes_in_mom "$TEST_NAME"/web-dir/10/Manifest.MoM } diff --git a/test/functional/bundlelist_v2/list-deps-nested.bats b/test/functional/bundlelist_v2/list-deps-nested.bats index 0bbed34c..6970db35 100755 --- a/test/functional/bundlelist_v2/list-deps-nested.bats +++ b/test/functional/bundlelist_v2/list-deps-nested.bats @@ -11,7 +11,6 @@ test_setup() { # add bundle2 as dependencies of bundle1 and bundle 3 as dependency of bundle2 add_dependency_to_manifest "$TEST_NAME"/web-dir/10/Manifest.test-bundle1 test-bundle2 add_dependency_to_manifest "$TEST_NAME"/web-dir/10/Manifest.test-bundle2 test-bundle3 - update_hashes_in_mom "$TEST_NAME"/web-dir/10/Manifest.MoM } diff --git a/test/functional/bundlelist_v2/list-has-dep-nested-not-installed.bats b/test/functional/bundlelist_v2/list-has-dep-nested-not-installed.bats index 168a1680..264373cb 100755 --- a/test/functional/bundlelist_v2/list-has-dep-nested-not-installed.bats +++ b/test/functional/bundlelist_v2/list-has-dep-nested-not-installed.bats @@ -11,7 +11,6 @@ test_setup() { # add bundle1 as dependencies of bundle2 and bundle 2 as dependency of bundle3 add_dependency_to_manifest "$TEST_NAME"/web-dir/10/Manifest.test-bundle2 test-bundle1 add_dependency_to_manifest "$TEST_NAME"/web-dir/10/Manifest.test-bundle3 test-bundle2 - update_hashes_in_mom "$TEST_NAME"/web-dir/10/Manifest.MoM } diff --git a/test/functional/bundlelist_v2/list-has-dep-nested-server.bats b/test/functional/bundlelist_v2/list-has-dep-nested-server.bats index cbcb8c33..1e381783 100755 --- a/test/functional/bundlelist_v2/list-has-dep-nested-server.bats +++ b/test/functional/bundlelist_v2/list-has-dep-nested-server.bats @@ -11,7 +11,6 @@ test_setup() { # add bundle1 as dependencies of bundle2 and bundle 2 as dependency of bundle3 add_dependency_to_manifest "$TEST_NAME"/web-dir/10/Manifest.test-bundle2 test-bundle1 add_dependency_to_manifest "$TEST_NAME"/web-dir/10/Manifest.test-bundle3 test-bundle2 - update_hashes_in_mom "$TEST_NAME"/web-dir/10/Manifest.MoM } diff --git a/test/functional/bundlelist_v2/list-has-dep-nested.bats b/test/functional/bundlelist_v2/list-has-dep-nested.bats index 2bffa0b0..0f8ef271 100755 --- a/test/functional/bundlelist_v2/list-has-dep-nested.bats +++ b/test/functional/bundlelist_v2/list-has-dep-nested.bats @@ -11,7 +11,6 @@ test_setup() { # add bundle1 as dependencies of bundle2 and bundle 2 as dependency of bundle3 add_dependency_to_manifest "$TEST_NAME"/web-dir/10/Manifest.test-bundle2 test-bundle1 add_dependency_to_manifest "$TEST_NAME"/web-dir/10/Manifest.test-bundle3 test-bundle2 - update_hashes_in_mom "$TEST_NAME"/web-dir/10/Manifest.MoM } diff --git a/test/functional/bundleremove_v2/remove-include-nested.bats b/test/functional/bundleremove_v2/remove-include-nested.bats index 360db37a..e73688f5 100755 --- a/test/functional/bundleremove_v2/remove-include-nested.bats +++ b/test/functional/bundleremove_v2/remove-include-nested.bats @@ -11,7 +11,6 @@ test_setup() { # add dependencies add_dependency_to_manifest "$TEST_NAME"/web-dir/10/Manifest.test-bundle2 test-bundle1 add_dependency_to_manifest "$TEST_NAME"/web-dir/10/Manifest.test-bundle3 test-bundle2 - update_hashes_in_mom "$TEST_NAME"/web-dir/10/Manifest.MoM } diff --git a/test/functional/bundleremove_v2/remove-include.bats b/test/functional/bundleremove_v2/remove-include.bats index 85c5f4ce..9fe22565 100755 --- a/test/functional/bundleremove_v2/remove-include.bats +++ b/test/functional/bundleremove_v2/remove-include.bats @@ -9,7 +9,6 @@ test_setup() { create_bundle -L -n test-bundle2 -f /bar/test-file2 "$TEST_NAME" # add test-bundle1 as dependency of test-bundle2 add_dependency_to_manifest "$TEST_NAME"/web-dir/10/Manifest.test-bundle2 test-bundle1 - update_hashes_in_mom "$TEST_NAME"/web-dir/10/Manifest.MoM } diff --git a/test/functional/testlib.bash b/test/functional/testlib.bash index c48433aa..1def2430 100644 --- a/test/functional/testlib.bash +++ b/test/functional/testlib.bash @@ -450,7 +450,8 @@ add_dependency_to_manifest() { local dependency=$2 local path local manifest_name - local bundle_name + local version + local pre_version # If no parameters are received show usage if [ $# -eq 0 ]; then cat <<-EOM @@ -460,14 +461,31 @@ add_dependency_to_manifest() { return fi validate_item "$manifest" - path=$(dirname "$manifest") - manifest_name=$(basename "$manifest") - bundle_name=${manifest_name#Manifest.} + validate_param "$dependency" + path=$(dirname "$(dirname "$manifest")") + version=$(basename "$(dirname "$manifest")") + manifest_name=$(basename "$manifest") + + # if the provided manifest does not exist in the current version, it means + # we need to copy it from a previous version. + # this could happen for example if a manifest is created in one version (e.g. 10), + # but the dependency should be added in a different, future version (e.g. 20) + if [ ! -e "$path"/"$version"/"$manifest_name" ]; then + pre_version="$version" + while [ "$pre_version" -gt 0 ] && [ ! -e "$path"/"$pre_version"/"$manifest_name" ]; do + pre_version=$(awk '/previous/ { print $2 }' "$path"/"$pre_version"/Manifest.MoM) + done + sudo cp "$path"/"$pre_version"/"$manifest_name" "$path"/"$version"/"$manifest_name" + sudo sed -i "s/version:.*/version:\\t$version/" "$manifest" + sudo sed -i "s/previous:.*/previous:\\t$pre_version/" "$manifest" + fi + sudo sed -i "s/timestamp:.*/timestamp:\\t$(date +"%s")/" "$manifest" sudo sed -i "/contentsize:.*/a includes:\\t$dependency" "$manifest" # If a manifest tar already exists for that manifest, renew the manifest tar sudo rm -f "$manifest".tar create_tar "$manifest" + update_hashes_in_mom "$path"/"$version"/Manifest.MoM }