Skip to content

Commit

Permalink
Fixes from review
Browse files Browse the repository at this point in the history
  • Loading branch information
tomuben committed Jun 17, 2024
1 parent fac0bb8 commit 60f42e2
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 18 deletions.
32 changes: 19 additions & 13 deletions ext/scripts/package_mgmt_utils.pm
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,31 @@ sub generate_joined_and_transformed_string_from_file{

sub generate_joined_and_transformed_string_from_files {
my ($element_separator, $combining_template, $templates_ref, $separators_ref, $rendered_line_transformation_functions_ref, $files_ref) = @_;
my %transformed_lines;
my @transformed_lines;
foreach my $file ( @$files_ref ) {
my @transformed_lines_for_current_file = generate_transformed_lines_for_templates(
$file, $element_separator, $templates_ref, $rendered_line_transformation_functions_ref);
foreach my $lines_ref ( @transformed_lines_for_current_file ) {
foreach my $line ( @$lines_ref) {
$transformed_lines{$line} = 1;

if (!@transformed_lines) {
@transformed_lines = @transformed_lines_for_current_file;
} else {
if ($#transformed_lines_for_current_file != $#transformed_lines) {
die "Internal error processing package file $file\n";
}
}
}
for my $i (0 .. $#transformed_lines_for_current_file) {
#Resolve reference for the resulting and new arrays, merge both and assign back the reference to the resulting array
my $transformed_lines_for_current_file_part_ref = $transformed_lines_for_current_file[$i];
my @transformed_lines_for_current_file_part = @$transformed_lines_for_current_file_part_ref;

my @transformed_lines_arr = sort( keys %transformed_lines );
my $transformed_lines_part_ref = $transformed_lines[$i];
my @transformed_lines_part = @$transformed_lines_part_ref;

if( !@transformed_lines_arr ){
return "";
push (@transformed_lines_part, @transformed_lines_for_current_file_part);
$transformed_lines[$i] = \@transformed_lines_part;
}
}
}

my @transformed_lines_arr_as_ref = ( \@transformed_lines_arr );
my $final_string = generate_joined_string_from_lines(\@transformed_lines_arr_as_ref, $combining_template, $separators_ref);
my $final_string = generate_joined_string_from_lines(\@transformed_lines, $combining_template, $separators_ref);
return $final_string;
}

Expand Down Expand Up @@ -268,7 +274,7 @@ sub merge_package_files {
my ($base_file, $base_search_dir, $file_pattern) = @_;

my @files_in_search_dir = find_files_matching_pattern($base_search_dir, $file_pattern);
return ($base_file, @files_in_search_dir);
return sort ($base_file, @files_in_search_dir);
}

1;
17 changes: 12 additions & 5 deletions ext/scripts/tests/install_scripts/run_pip_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ then
DRY_RUN_OPTION=
fi

if [ -z "${RUN_PIP_TESTS_EXECUTOR-}" ]
then
echo Running pip tests without exector.
else
echo Running pip tests with executor "'$RUN_PIP_TESTS_EXECUTOR'".
fi

function run_install() {
if [ -z "${RUN_PIP_TESTS_EXECUTOR-}" ]
then
Expand Down Expand Up @@ -109,7 +116,7 @@ echo

echo ./install_via_pip.pl installing a package twice with different versions must fail
TEST_OUTPUT=$(run_install_must_fail "$PATH_TO_INSTALL_SCRIPTS/install_via_pip.pl --file test_files/pip/version_conflict/same_pkg/step2 --ancestor-pip-package-root-path test_files/pip/version_conflict/same_pkg/build_info/packages --python-binary python3 --with-versions $DRY_RUN_OPTION")
assert "$TEST_OUTPUT" "Dry-Run: python3 -m pip install --no-cache-dir 'azure-common==1.1.28' 'azure-common==1.1.4'"
assert "$TEST_OUTPUT" "Dry-Run: python3 -m pip install --no-cache-dir 'azure-common==1.1.4' 'azure-common==1.1.28'"
echo


Expand All @@ -121,19 +128,19 @@ echo

echo ./install_via_pip.pl installing with ancestors and correct dependency
TEST_OUTPUT=$(run_install "$PATH_TO_INSTALL_SCRIPTS/install_via_pip.pl --file test_files/pip/no_version_conflict/dependency_already_installed/step2 --ancestor-pip-package-root-path test_files/pip/no_version_conflict/dependency_already_installed/build_info/packages --python-binary python3 --with-versions $DRY_RUN_OPTION")
assert "$TEST_OUTPUT" "Dry-Run: python3 -m pip install --no-cache-dir 'azure-batch==1.0.0' 'azure-common==1.1.4'"
assert "$TEST_OUTPUT" "Dry-Run: python3 -m pip install --no-cache-dir 'azure-common==1.1.4' 'azure-batch==1.0.0'"
echo


echo ./install_via_pip.pl installing with ancestors and dependency with wrong version must fail
TEST_OUTPUT=$(run_install_must_fail "$PATH_TO_INSTALL_SCRIPTS/install_via_pip.pl --file test_files/pip/version_conflict/dependency_already_installed/step2 --ancestor-pip-package-root-path test_files/pip/version_conflict/dependency_already_installed/build_info/packages --python-binary python3 --with-versions $DRY_RUN_OPTION")
assert "$TEST_OUTPUT" "Dry-Run: python3 -m pip install --no-cache-dir 'azure-batch==1.0.0' 'azure-common==1.1.28'"
assert "$TEST_OUTPUT" "Dry-Run: python3 -m pip install --no-cache-dir 'azure-common==1.1.28' 'azure-batch==1.0.0'"
echo


echo ./install_via_pip.pl installing with ancestors and package which has a dependency to an older package must fail
TEST_OUTPUT=$(run_install_must_fail "$PATH_TO_INSTALL_SCRIPTS/install_via_pip.pl --file test_files/pip/version_conflict/other_package_with_older_dependency_already_installed/step2 --ancestor-pip-package-root-path test_files/pip/version_conflict/other_package_with_older_dependency_already_installed/build_info/packages --python-binary python3 --with-versions $DRY_RUN_OPTION")
assert "$TEST_OUTPUT" "Dry-Run: python3 -m pip install --no-cache-dir 'azure-batch==1.0.0' 'azure-storage-queue==1.1.0'"
assert "$TEST_OUTPUT" "Dry-Run: python3 -m pip install --no-cache-dir 'azure-storage-queue==1.1.0' 'azure-batch==1.0.0'"
echo


Expand All @@ -145,7 +152,7 @@ echo

echo ./install_via_pip.pl installing with multiple ancestors
TEST_OUTPUT=$(run_install "$PATH_TO_INSTALL_SCRIPTS/install_via_pip.pl --file test_files/pip/no_version_conflict/multiple_ancestors/step3 --ancestor-pip-package-root-path test_files/pip/no_version_conflict/multiple_ancestors/build_info/packages --python-binary python3 --with-versions $DRY_RUN_OPTION")
assert "$TEST_OUTPUT" "Dry-Run: python3 -m pip install --no-cache-dir 'azure-batch==14.2.0' 'azure-common==1.1.28' 'azure-storage-queue==1.1.0'"
assert "$TEST_OUTPUT" "Dry-Run: python3 -m pip install --no-cache-dir 'azure-common==1.1.28' 'azure-batch==14.2.0' 'azure-storage-queue==1.1.0'"
echo

check_for_failed_tests
Expand Down

0 comments on commit 60f42e2

Please sign in to comment.