mirror of
https://github.com/chromebrew/chromebrew.git
synced 2026-01-08 23:18:10 -05:00
Fix remove such that files from essential packages are not removed. (#10342)
* Fix remove such that essential files are not removed. Signed-off-by: Satadru Pramanik <satadru@gmail.com> * bump version Signed-off-by: Satadru Pramanik <satadru@gmail.com> * lint Signed-off-by: Satadru Pramanik <satadru@gmail.com> --------- Signed-off-by: Satadru Pramanik <satadru@gmail.com>
This commit is contained in:
committed by
GitHub
parent
42cad1a60b
commit
9f18d1f48a
@@ -1,5 +1,6 @@
|
||||
require 'minitest/autorun'
|
||||
require_relative '../../commands/remove'
|
||||
require_relative '../../lib/const'
|
||||
require_relative '../../lib/package_utils'
|
||||
|
||||
# Add lib to LOAD_PATH
|
||||
@@ -20,6 +21,16 @@ class RemoveCommandTest < Minitest::Test
|
||||
ESSENTIAL_PACKAGE_REMOVAL_TEST_EOF
|
||||
@random_essential_pkg = Package.load_package("#{@random_essential_package_name}.rb")
|
||||
|
||||
@package_with_essential_file = 'gcc_build'
|
||||
@essential_file = File.join(CREW_LIB_PREFIX, 'libstdc++.so.6')
|
||||
puts <<~PACKAGE_WITH_ESSENTIAL_FILE_REMOVAL_TEST_EOF
|
||||
|
||||
Testing the removal of package #{@package_with_essential_file}.
|
||||
(This should succeed, but essential file #{@essential_file}
|
||||
should not be removed.)
|
||||
|
||||
PACKAGE_WITH_ESSENTIAL_FILE_REMOVAL_TEST_EOF
|
||||
|
||||
@normal_package_name = 'xxd_standalone'
|
||||
puts <<~NORMAL_PACKAGE_REMOVAL_TEST_EOF
|
||||
|
||||
@@ -41,13 +52,24 @@ class RemoveCommandTest < Minitest::Test
|
||||
assert_raises(SystemExit) { Command.remove(@random_essential_pkg, true) }
|
||||
end
|
||||
|
||||
def test_remove_package_with_essential_file
|
||||
assert_output(true) do
|
||||
until PackageUtils.installed?(@package_with_essential_file)
|
||||
system "crew install -d #{@package_with_essential_file}", %i[out err] => File::NULL
|
||||
sleep 2
|
||||
end
|
||||
system "crew remove -d #{@package_with_essential_file}", %i[out err] => File::NULL
|
||||
return File.file?(@essential_file)
|
||||
end
|
||||
end
|
||||
|
||||
def test_remove_normal_package
|
||||
expected_output = <<~EOT
|
||||
#{@normal_package_name} removed
|
||||
EOT
|
||||
assert_output(/^#{Regexp.escape(expected_output.chomp)}!/, nil) do
|
||||
until PackageUtils.installed?(@normal_package_name)
|
||||
system "crew install -d #{@normal_package_name} &>/dev/null", out: File::NULL
|
||||
system "crew install -d #{@normal_package_name}", %i[out err] => File::NULL
|
||||
sleep 2
|
||||
end
|
||||
Command.remove(@normal_pkg, true)
|
||||
|
||||
Reference in New Issue
Block a user