Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Support Win32 #98

Closed
wants to merge 3 commits into from

4 participants

@Donavan

With this commit, Gem reading/writing is forced to binary mode. This allows Win32 support without changing *nix operation.

@Donavan

Not having fork and symlink means a bunch of tests have to be skipped but the code they're testing works (manually tested) under Win32.

geminabox.gemspec
@@ -25,4 +25,5 @@ Gem::Specification.new do |s|
s.add_development_dependency('capybara')
s.add_development_dependency('capybara-mechanize')
s.add_development_dependency('pry')
+ s.add_development_dependency('pry-debugger')
@cwninja Owner
cwninja added a note

Could you remove the pry-debugger line? I think it's making the 1.8.7 travis suite fail. https://travis-ci.org/cwninja/geminabox/jobs/4713561

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@yaauie yaauie commented on the diff
test/integration/dependency_api/dependencies_api_test.rb
@@ -4,6 +4,7 @@
class DependenciesApiTest < Geminabox::TestCase
test "push a gem with dependencies" do
+ skip 'Test broken under Win32. (Missing fork)' if RbConfig::CONFIG['host_os'] =~ /mswin|windows|cygwin|mingw32/i
@yaauie
yaauie added a note

Could these be better served by skipping unless Process.respond_to?(:fork) ? If that were the case, these could possibly be tested with the win32-process gem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@Donavan

Will get on the suggested changes. win32-process dropped support for fork as it never worked correctly.

@reggieb
Owner

0.12.4 has been release and includes the binary mode fixes required on Windows system. Can you please try this version and raise any new issues you find. Thank you.

@reggieb reggieb closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 10, 2013
  1. @Donavan
Commits on Feb 11, 2013
  1. @Donavan

    Fixed tests using /dev/null to use nul under Win32. Skip tests that d…

    Donavan authored
    …epend on Posix functions Win32 is too moronic to include.
Commits on Mar 10, 2013
  1. @Donavan
This page is out of date. Refresh to see the latest.
View
1  .gitignore
@@ -5,3 +5,4 @@ Gemfile.lock
vendor/bundle
.rbenv-version
test/fixtures/fake_home_path/.gem/specs
+.idea
View
4 lib/geminabox.rb
@@ -241,7 +241,7 @@ def index_gems(gems)
def atomic_write(file_name)
temp_dir = File.join(settings.data, "_temp")
FileUtils.mkdir_p(temp_dir)
- temp_file = Tempfile.new("." + File.basename(file_name), temp_dir)
+ temp_file = Tempfile.new("." + File.basename(file_name), temp_dir, {:binmode => true})
yield temp_file
temp_file.close
File.rename(temp_file.path, file_name)
@@ -251,7 +251,7 @@ def atomic_write(file_name)
helpers do
def spec_for(gem_name, version)
spec_file = File.join(settings.data, "quick", "Marshal.#{Gem.marshal_version}", "#{gem_name}-#{version}.gemspec.rz")
- Marshal.load(Gem.inflate(File.read(spec_file))) if File.exists? spec_file
+ File.open(spec_file, 'rb') { |file| Marshal.load(Gem.inflate(file.read)) } if File.exists? spec_file
end
end
end
View
2  lib/geminabox/incoming_gem.rb
@@ -8,7 +8,7 @@ def initialize(gem_data, root_path = Geminabox.settings.data)
if RbConfig::CONFIG["MAJOR"].to_i <= 1 and RbConfig::CONFIG["MINOR"].to_i <= 8
@tempfile = Tempfile.new("gem")
else
- @tempfile = Tempfile.new("gem", :encoding => 'binary')
+ @tempfile = Tempfile.new("gem", {:binmode => true})
end
while data = gem_data.read(1024**2)
View
5 test/integration/dependency_api/dependencies_api_test.rb
@@ -4,6 +4,7 @@
class DependenciesApiTest < Geminabox::TestCase
test "push a gem with dependencies" do
+ skip 'Test broken under Win32. (Missing fork)' if RbConfig::CONFIG['host_os'] =~ /mswin|windows|cygwin|mingw32/i
@yaauie
yaauie added a note

Could these be better served by skipping unless Process.respond_to?(:fork) ? If that were the case, these could possibly be tested with the win32-process gem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
cache_fixture_data_dir "a_gem_with_deps" do
assert_can_push(:a, :deps => [[:b, '>= 0']])
end
@@ -14,11 +15,13 @@ class DependenciesApiTest < Geminabox::TestCase
end
test "ask about a missing gem" do
+ skip 'Test broken under Win32. (Missing fork)' if RbConfig::CONFIG['host_os'] =~ /mswin|windows|cygwin|mingw32/i
deps = fetch_deps("nothing", "nadda", "nought")
assert_equal [], deps
end
test "get dependencies for multiple gems" do
+ skip 'Test broken under Win32. (Missing fork)' if RbConfig::CONFIG['host_os'] =~ /mswin|windows|cygwin|mingw32/i
cache_fixture_data_dir "multiple_gems_with_deps" do
assert_can_push(:a, :deps => [[:b, '>= 0']])
assert_can_push(:another_gem, :deps => [[:fred, '>= 0'], [:john, '= 2.0']])
@@ -33,6 +36,7 @@ class DependenciesApiTest < Geminabox::TestCase
end
test "get dependencies for multiple versions of the same gem" do
+ skip 'Test broken under Win32. (Missing fork)' if RbConfig::CONFIG['host_os'] =~ /mswin|windows|cygwin|mingw32/i
cache_fixture_data_dir "one_gem_many_versions" do
assert_can_push(:a, :deps => [[:b, '>= 0']])
assert_can_push(:a, :deps => [[:b, '>= 1']], :version => "2.0.0")
@@ -47,6 +51,7 @@ class DependenciesApiTest < Geminabox::TestCase
end
test "dependency cache is cleared as expected" do
+ skip 'Test broken under Win32. (Missing fork)' if RbConfig::CONFIG['host_os'] =~ /mswin|windows|cygwin|mingw32/i
assert_can_push(:a, :deps => [[:b, '>= 0']])
deps = fetch_deps("a")
View
4 test/integration/pushing_gems/data_dir_errors_test.rb
@@ -19,6 +19,7 @@ class InvalidDataDirTest < Geminabox::TestCase
data "/dev/null"
test "report the error back to the user" do
+ skip 'Test broken under Win32.' if RbConfig::CONFIG['host_os'] =~ /mswin|windows|cygwin|mingw32/i
assert_match %r{Please ensure /dev/null is a directory.}, geminabox_push(gem_file(:example))
end
end
@@ -29,6 +30,7 @@ class UnwritableDataDirTest < Geminabox::TestCase
data "/tmp/read_only"
test "report the error back to the user" do
+ skip 'Test broken under Win32.' if RbConfig::CONFIG['host_os'] =~ /mswin|windows|cygwin|mingw32/i
assert_match %r{Please ensure /tmp/read_only is writable by the geminabox web server.}, geminabox_push(gem_file(:example))
end
end
@@ -39,6 +41,7 @@ class UnwritableUncreatableDataDirTest < Geminabox::TestCase
data "/tmp/read_only/geminabox-fail"
test "report the error back to the user" do
+ skip 'Test broken under Win32.' if RbConfig::CONFIG['host_os'] =~ /mswin|windows|cygwin|mingw32/i
assert_match %r{Could not create /tmp/read_only/geminabox-fail}, geminabox_push(gem_file(:example))
end
end
@@ -47,6 +50,7 @@ class WritableNoneExistentDataDirTest < Geminabox::TestCase
data "#{data}/more/layers/of/dirs"
test "create the data dir" do
+ skip 'Test broken under Win32.' if RbConfig::CONFIG['host_os'] =~ /mswin|windows|cygwin|mingw32/i
FileUtils.rm_rf(config.data)
assert_can_push
end
View
1  test/integration/web_interface/large_gem_list_test.rb
@@ -6,6 +6,7 @@ class LargeGemListSpec < Geminabox::TestCase
include Capybara::DSL
test "more than 5 versions of the same gem" do
+ skip 'Test broken under Win32.' if RbConfig::CONFIG['host_os'] =~ /mswin|windows|cygwin|mingw32/i
cache_fixture_data_dir('large_gem_list_test') do
assert_can_push(:unrelated_gem, :version => '1.0')
View
7 test/requests/atom_feed_test.rb
@@ -13,13 +13,14 @@ def app
Geminabox
end
- test "atom feed returns when no gems are defined" do
- get "/atom.xml"
+ test 'atom feed returns when no gems are defined' do
+ get '/atom.xml'
assert last_response.ok?
refute_match %r{<entry>}, last_response.body
end
- test "atom feed with a single gem" do
+ test 'atom feed with a single gem' do
+ skip 'Test broken under Win32.' if RbConfig::CONFIG['host_os'] =~ /mswin|windows|cygwin|mingw32/i
inject_gems do |builder|
builder.gem "foo"
end
View
5 test/test_helper.rb
@@ -23,8 +23,9 @@ def test(test_name, &block)
class MiniTest::Unit::TestCase
extend TestMethodMagic
+ DEV_NULL = RbConfig::CONFIG['host_os'] =~ /mswin|windows|cygwin|mingw32/i ? 'nul' : '/dev/null'
+ TEST_DATA_DIR = RbConfig::CONFIG['host_os'] =~ /mswin|windows|cygwin|mingw32/i ? "#{ENV['temp'].gsub('\\', '/')}/geminabox-test-data" : "/tmp/geminabox-test-data"
- TEST_DATA_DIR="/tmp/geminabox-test-data"
def clean_data_dir
FileUtils.rm_rf(TEST_DATA_DIR)
FileUtils.mkdir(TEST_DATA_DIR)
@@ -42,7 +43,7 @@ def fixture(*args)
def silence_stream(stream)
old_stream = stream.dup
- stream.reopen('/dev/null')
+ stream.reopen(DEV_NULL)
stream.sync = true
yield
ensure
View
2  test/test_support/gem_factory.rb
@@ -37,7 +37,7 @@ def gem(name, options = {})
end
}
- spec_file = Tempfile.open("spec") do |tmpfile|
+ spec_file = Tempfile.open("spec", {:binmode => true}) do |tmpfile|
tmpfile << spec
tmpfile.close
View
6 test/test_support/geminabox_test_case.rb
@@ -44,6 +44,7 @@ def to_app
def should_push_gem(gemname = :example, *args)
test("can push #{gemname}") do
+ skip 'Test broken under Win32.' if RbConfig::CONFIG['host_os'] =~ /mswin|windows|cygwin|mingw32/i
assert_can_push(gemname, *args)
gem_path = File.join(config.data, "gems", File.basename(gem_file(gemname, *args)) )
assert File.exists?( gem_path ), "Gemfile not in data dir."
@@ -53,6 +54,7 @@ def should_push_gem(gemname = :example, *args)
def should_push_gem_over_gemcutter_api(gemname = :example, *args)
test("can push #{gemname}") do
+ skip 'Test broken under Win32.' if RbConfig::CONFIG['host_os'] =~ /mswin|windows|cygwin|mingw32/i
gem_file = gem_file(gemname, *args)
gemcutter_push(gem_file)
gem_path = File.join(config.data, "gems", File.basename(gem_file) )
@@ -71,11 +73,11 @@ def url_with_port(port)
def setup
super
- start_app!
+ start_app! unless RbConfig::CONFIG['host_os'] =~ /mswin|windows|cygwin|mingw32/i
end
def teardown
- stop_app!
+ stop_app! unless RbConfig::CONFIG['host_os'] =~ /mswin|windows|cygwin|mingw32/i
super
end
View
7 test/units/incoming_gem_test.rb
@@ -40,10 +40,13 @@ class IncomingGemTest < MiniTest::Unit::TestCase
test "#hexdigest" do
file_name = GemFactory.gem_file(:example)
- file = File.open(file_name)
+ file = File.open(file_name, 'rb')
subject = Geminabox::IncomingGem.new(file)
- assert_equal Digest::SHA1.hexdigest(File.read(file_name)), subject.hexdigest
+ File.open(file_name, 'rb') do |compare_file|
+ assert_equal Digest::SHA1.hexdigest(compare_file.read), subject.hexdigest
+ end
+
end
end
Something went wrong with that request. Please try again.