Skip to content

refactor: remove "exposed" @system_dir instance variable (in helper method) - #604

Merged
hsbt merged 1 commit into
ruby:masterfrom
pvdb:system_dir_ivar
Dec 9, 2024
Merged

refactor: remove "exposed" @system_dir instance variable (in helper method)#604
hsbt merged 1 commit into
ruby:masterfrom
pvdb:system_dir_ivar

Conversation

@pvdb

@pvdbpvdb commented Nov 11, 2024

Copy link
Copy Markdown
Contributor

It is very unclear why the Rake::TestCase#rake_system_dir helper method:

defrake_system_dir@system_dir="system"FileUtils.mkdir_p@system_dirFile.writeFile.join(@system_dir,"sys1.rake"),<<~SYS task "sys1" do puts "SYS1" end SYSENV["RAKE_SYSTEM"]=@system_dirend

... creates and sets a @system_dir instance variable. 🤔

On inspection, it turns out its only use is the following assertion in one of the test cases:

assert_equal@system_dir,@app.system_dir

... so this PR removes the ivar and hardcodes the expected "system" value in the assertion:

- assert_equal @system_dir, @app.system_dir+ assert_equal "system", @app.system_dir

This may seem a tad controversial, but as it turns out, the sys1.rake Rakefile name and the SYS1 Rakefile contents (also "private" - as it were - to that very same utility method) are already hardcoded in one of the Rake test cases:

$ gitgrep -isys1 -- 'test/test*'test/test_rake_functional.rb: rake"-g","sys1"test/test_rake_functional.rb: assert_match %r{^SYS1},@outtest/test_rake_functional.rb: rake"-g","sys1","-T","extra"test/test_rake_functional.rb: rake"sys1","--trace"test/test_rake_functional.rb: assert_match %r{^SYS1},@outtest/test_rake_functional.rb: rake"-G","sys1"test/test_rake_functional.rb: rake"--nosearch","sys1"test/test_rake_functional.rb: assert_match %r{^SYS1},@out
$ _

... so the change in this PR just makes things more consistent with the other test cases and assertions.

@pvdbpvdb changed the title chore: refactor "exposed" @system_dir instance variable (in helper method)refactor: remove "exposed" @system_dir instance variable (in helper method)Dec 8, 2024
@hsbt

hsbt commented Dec 9, 2024

Copy link
Copy Markdown
Member

👍

@hsbt
hsbt merged commit 2e9a25b into ruby:masterDec 9, 2024
@pvdb
pvdb deleted the system_dir_ivar branch December 9, 2024 10:47
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@pvdb@hsbt