diff options
author | Eric Wong <e@80x24.org> | 2013-10-30 01:50:21 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2013-10-30 07:01:05 +0000 |
commit | 03c193bf6c742ea445e74a009d2502d2a6bda9f8 (patch) | |
tree | ca37592fe95590fa038108e33ffba00247821d66 /test | |
parent | e3b7523f3570d7ccf8d88fe4c3c854b677dc7e4f (diff) | |
download | yahns-03c193bf6c742ea445e74a009d2502d2a6bda9f8.tar.gz |
This is often forgotten, and we need to make a tweak to the coverage generator to dump correctly.
Diffstat (limited to 'test')
-rw-r--r-- | test/helper.rb | 5 | ||||
-rw-r--r-- | test/test_server.rb | 24 |
2 files changed, 27 insertions, 2 deletions
diff --git a/test/helper.rb b/test/helper.rb index 3f141e4..5e417ae 100644 --- a/test/helper.rb +++ b/test/helper.rb @@ -17,12 +17,13 @@ GTL = Mutex.new if ENV["COVERAGE"] require "coverage" COVMATCH = %r{/lib/yahns\b.*rb\z} + COVDUMPFILE = File.expand_path("coverage.dump") def __covmerge res = Coverage.result - # do not create the file, Makefile does htis before any tests run - File.open("coverage.dump", IO::RDWR) do |covtmp| + # do not create the file, Makefile does this before any tests run + File.open(COVDUMPFILE, IO::RDWR) do |covtmp| covtmp.binmode covtmp.sync = true diff --git a/test/test_server.rb b/test/test_server.rb index 79e498d..934ae3e 100644 --- a/test/test_server.rb +++ b/test/test_server.rb @@ -559,4 +559,28 @@ class TestServer < Testcase ensure quit_wait(pid) end + + def test_working_directory + err, cfg, host, port = @err, Yahns::Config.new, @srv.addr[3], @srv.addr[1] + ru = lambda { |_| + [ 200, {'Content-Length'=>Dir.pwd.size.to_s }, [Dir.pwd] ] + } + Dir.mktmpdir do |tmpdir| + begin + pid = mkserver(cfg) do + cfg.instance_eval do + working_directory tmpdir + GTL.synchronize { app(:rack, ru) { listen "#{host}:#{port}" } } + stderr_path err.path + end + end + refute_equal Dir.pwd, tmpdir + Net::HTTP.start(host, port) do |http| + assert_equal tmpdir, http.request(Net::HTTP::Get.new("/")).body + end + ensure + quit_wait(pid) + end + end + end end |