Skip to content

Commit

Permalink
[rubygems/rubygems] Reset Gem.state_file along with Gem.state_home
Browse files Browse the repository at this point in the history
As `Gem.state_file` is placed under `Gem.state_home` directory, when
the latter is reset, also the former should be reset.
If left unreset, the file for a previously run test will be re-created
and will not be deleted.

rubygems/rubygems@1378d07afd
  • Loading branch information
nobu authored and matzbot committed Feb 21, 2024
1 parent 1fa4d15 commit 6ecb14d
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion test/rubygems/helper.rb
Expand Up @@ -76,6 +76,8 @@ class Gem::TestCase < Test::Unit::TestCase

attr_accessor :uri # :nodoc:

@@tempdirs = []

def assert_activate(expected, *specs)
specs.each do |spec|
case spec
Expand Down Expand Up @@ -287,7 +289,8 @@ def setup

FileUtils.mkdir_p @tmp

@tempdir = Dir.mktmpdir("test_rubygems_", @tmp)
@tempdir = Dir.mktmpdir(method_name.to_s, @tmp)
@@tempdirs << @tempdir

ENV["GEM_VENDOR"] = nil
ENV["GEMRC"] = nil
Expand Down Expand Up @@ -354,6 +357,7 @@ def setup
Gem.instance_variable_set :@config_home, nil
Gem.instance_variable_set :@data_home, nil
Gem.instance_variable_set :@state_home, @statehome
Gem.instance_variable_set :@state_file, nil
Gem.instance_variable_set :@gemdeps, nil
Gem.instance_variable_set :@env_requirements_by_name, nil
Gem.send :remove_instance_variable, :@ruby_version if
Expand Down Expand Up @@ -470,6 +474,8 @@ def teardown
end

@back_ui.close

assert_empty @@tempdirs.select {|tempdir| File.exist?(tempdir) }
end

def credential_setup
Expand Down

0 comments on commit 6ecb14d

Please sign in to comment.