File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -33,8 +33,6 @@ module Rake; end
3333
3434require_relative "rake/ext/string"
3535
36- require_relative "rake/win32"
37-
3836require_relative "rake/linked_list"
3937require_relative "rake/cpu_counter"
4038require_relative "rake/scope"
Original file line number Diff line number Diff line change 77require_relative "thread_pool"
88require_relative "thread_history_display"
99require_relative "trace_output"
10- require_relative "win32"
1110
1211module Rake
1312
@@ -384,12 +383,11 @@ def dynamic_width_tput # :nodoc:
384383 end
385384
386385 def unix? # :nodoc:
387- RbConfig ::CONFIG [ "host_os" ] =~
388- /(aix|darwin|linux|(net|free|open)bsd|cygwin|solaris|irix|hpux)/i
386+ Rake . unix?
389387 end
390388
391389 def windows? # :nodoc:
392- Win32 . windows?
390+ Rake . windows?
393391 end
394392
395393 def truncate ( string , width ) # :nodoc:
Original file line number Diff line number Diff line change @@ -14,6 +14,17 @@ def application=(app)
1414 @application = app
1515 end
1616
17+ # True if running on a Windows system.
18+ def windows?
19+ RbConfig ::CONFIG [ "host_os" ] =~ %r!(msdos|mswin|djgpp|mingw|[Ww]indows)!
20+ end
21+
22+ # True if running on a Unix system.
23+ def unix?
24+ RbConfig ::CONFIG [ "host_os" ] =~
25+ /(aix|darwin|linux|(net|free|open)bsd|cygwin|solaris|irix|hpux)/i
26+ end
27+
1728 def suggested_thread_count # :nodoc:
1829 @cpu_count ||= Rake ::CpuCounter . count
1930 @cpu_count + 4
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -90,7 +90,6 @@ Gem::Specification.new do |s|
9090 "lib/rake/thread_pool.rb" ,
9191 "lib/rake/trace_output.rb" ,
9292 "lib/rake/version.rb" ,
93- "lib/rake/win32.rb" ,
9493 "rake.gemspec"
9594 ]
9695 s . bindir = "exe"
Original file line number Diff line number Diff line change @@ -38,4 +38,11 @@ def test_original_dir_reports_current_dir
3838 assert_equal @tempdir , Rake . original_dir
3939 end
4040
41+ def test_platform_detection
42+ # ensure that Rake's platform detection logic
43+ # is mutually exclusive, and doesn't claim to
44+ # be both Windows and Unix at the same time
45+ assert ! ( Rake . windows? && Rake . unix? )
46+ end
47+
4148end
Original file line number Diff line number Diff line change @@ -419,8 +419,16 @@ def test_terminal_columns
419419 end
420420 end
421421
422- def test_windows
423- assert ! ( @app . windows? && @app . unix? )
422+ if Rake . unix?
423+ def test_unix_platform_detection
424+ assert @app . unix?
425+ end
426+ end
427+
428+ if Rake . windows?
429+ def test_windows_platform_detection
430+ assert @app . windows?
431+ end
424432 end
425433
426434 def test_loading_imports
Original file line number Diff line number Diff line change @@ -27,13 +27,15 @@ def test_directory
2727 refute File . exist? ( "a/b/c" )
2828 end
2929
30- def test_directory_colon
31- directory "a:b"
30+ if Rake . unix?
31+ def test_directory_colon
32+ directory "a:b"
3233
33- assert_equal FileCreationTask , Task [ "a:b" ] . class
34- end unless Rake ::Win32 . windows?
34+ assert_equal FileCreationTask , Task [ "a:b" ] . class
35+ end
36+ end
3537
36- if Rake :: Win32 . windows?
38+ if Rake . windows?
3739 def test_directory_win32
3840 desc "WIN32 DESC"
3941 directory "c:/a/b/c"
Original file line number Diff line number Diff line change @@ -349,8 +349,8 @@ def test_string_ext
349349 assert_equal ".one" , ".one" . ext
350350 assert_equal "." , "." . ext ( "c" )
351351 assert_equal ".." , ".." . ext ( "c" )
352- # These only need to work in windows
353- if Rake :: Win32 . windows?
352+ # These only need to work on Windows
353+ if Rake . windows?
354354 assert_equal "one.x\\ two.net" , "one.x\\ two.c" . ext ( ".net" )
355355 assert_equal "one.x\\ two.net" , "one.x\\ two" . ext ( ".net" )
356356 end
You can’t perform that action at this time.
0 commit comments