Skip to content

Commit 313d869

Browse files
committed
Log Spec::Constants::Each error instead of flag.
MSP-11130 Instead of writing `1` to the file and then printing a verbose message in the spec task action, log the verbose message and just print the log in the spec task action, so other tools can just look at the log when not using `rake spec`. NOTE: Failing specs due to unnecessary `Metasploit::Framework::Spec::Constants::Each.configure!`
1 parent 1d09fa6 commit 313d869

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

lib/metasploit/framework/spec/constants/each.rb

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ module Metasploit::Framework::Spec::Constants::Each
99
# CONSTANTS
1010
#
1111

12-
LOG_PATHNAME = Pathname.new('log/metasploit/framework/spec/constants/each.remove')
12+
LOG_PATHNAME = Pathname.new('log/metasploit/framework/spec/constants/each.log')
1313

1414
#
1515
# Module Methods
@@ -72,7 +72,9 @@ def self.configure!
7272
end
7373
else
7474
LOG_PATHNAME.open('w') { |f|
75-
f.write('1')
75+
f.puts "No leaks were cleaned by `Metasploit::Framework::Spec::Constants::Each.configured!`. Remove " \
76+
"it from `spec/spec_helper.rb` so it does not interfere with contexts that persist loaded " \
77+
"modules for entire context and clean up modules in `after(:all)` and then `rm log/remove-cleaner`"
7678
}
7779
end
7880
end
@@ -96,9 +98,11 @@ def self.configured?
9698
def self.define_task
9799
Rake::Task.define_task(:spec) do
98100
if LOG_PATHNAME.exist?
99-
$stderr.puts "No leaks were cleaned by `#{self}.configured!`. Remove it from `spec/spec_helper.rb` so it " \
100-
"does not interfere with contexts that persist loaded modules for entire context and clean up " \
101-
"modules in `after(:all)` and then `rm log/remove-cleaner`"
101+
LOG_PATHNAME.open { |f|
102+
f.each_line do |line|
103+
$stderr.write line
104+
end
105+
}
102106

103107
exit(1)
104108
end

spec/spec_helper.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,5 @@
5656
config.use_transactional_fixtures = true
5757
end
5858

59+
Metasploit::Framework::Spec::Constants::Each.configure!
5960
Metasploit::Framework::Spec::Constants::Suite.configure!

0 commit comments

Comments
 (0)