Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions lib/rake.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ module Rake; end

require_relative "rake/ext/string"

require_relative "rake/win32"

require_relative "rake/linked_list"
require_relative "rake/cpu_counter"
require_relative "rake/scope"
Expand Down
6 changes: 2 additions & 4 deletions lib/rake/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
require_relative "thread_pool"
require_relative "thread_history_display"
require_relative "trace_output"
require_relative "win32"

module Rake

Expand Down Expand Up @@ -384,12 +383,11 @@ def dynamic_width_tput # :nodoc:
end

def unix? # :nodoc:
RbConfig::CONFIG["host_os"] =~
/(aix|darwin|linux|(net|free|open)bsd|cygwin|solaris|irix|hpux)/i
Rake.unix?
end

def windows? # :nodoc:
Win32.windows?
Rake.windows?
end

def truncate(string, width) # :nodoc:
Expand Down
11 changes: 11 additions & 0 deletions lib/rake/rake_module.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,17 @@ def application=(app)
@application = app
end

# True if running on a Windows system.
def windows?
RbConfig::CONFIG["host_os"] =~ %r!(msdos|mswin|djgpp|mingw|[Ww]indows)!
end

# True if running on a Unix system.
def unix?
RbConfig::CONFIG["host_os"] =~
/(aix|darwin|linux|(net|free|open)bsd|cygwin|solaris|irix|hpux)/i
end

def suggested_thread_count # :nodoc:
@cpu_count ||= Rake::CpuCounter.count
@cpu_count + 4
Expand Down
17 changes: 0 additions & 17 deletions lib/rake/win32.rb

This file was deleted.

1 change: 0 additions & 1 deletion rake.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ Gem::Specification.new do |s|
"lib/rake/thread_pool.rb",
"lib/rake/trace_output.rb",
"lib/rake/version.rb",
"lib/rake/win32.rb",
"rake.gemspec"
]
s.bindir = "exe"
Expand Down
7 changes: 7 additions & 0 deletions test/test_rake.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,11 @@ def test_original_dir_reports_current_dir
assert_equal @tempdir, Rake.original_dir
end

def test_platform_detection
# ensure that Rake's platform detection logic
# is mutually exclusive, and doesn't claim to
# be both Windows and Unix at the same time
assert ! (Rake.windows? && Rake.unix?)
end

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This preserves the original TestRakeApplication.test_windows exclusivity check, but - arguably - with a more intent-revealing name, and also by documenting it (as the original assertion was somewhat esoteric) 😃

end
14 changes: 12 additions & 2 deletions test/test_rake_application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -419,8 +419,18 @@ def test_terminal_columns
end
end

def test_windows
assert ! (@app.windows? && @app.unix?)
if Rake.unix?
def test_unix_platform_detection
assert @app.unix?
refute @app.windows?
end
end

if Rake.windows?
def test_windows_platform_detection
assert @app.windows?
refute @app.unix?
end
end

def test_loading_imports
Expand Down
12 changes: 7 additions & 5 deletions test/test_rake_directory_task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,15 @@ def test_directory
refute File.exist?("a/b/c")
end

def test_directory_colon
directory "a:b"
if Rake.unix?
def test_directory_colon
directory "a:b"

assert_equal FileCreationTask, Task["a:b"].class
end unless Rake::Win32.windows?
assert_equal FileCreationTask, Task["a:b"].class
end
end

if Rake::Win32.windows?
if Rake.windows?
def test_directory_win32
desc "WIN32 DESC"
directory "c:/a/b/c"
Expand Down
4 changes: 2 additions & 2 deletions test/test_rake_file_list.rb
Original file line number Diff line number Diff line change
Expand Up @@ -349,8 +349,8 @@ def test_string_ext
assert_equal ".one", ".one".ext
assert_equal ".", ".".ext("c")
assert_equal "..", "..".ext("c")
# These only need to work in windows
if Rake::Win32.windows?
# These only need to work on Windows
if Rake.windows?
assert_equal "one.x\\two.net", "one.x\\two.c".ext(".net")
assert_equal "one.x\\two.net", "one.x\\two".ext(".net")
end
Expand Down