Commit 2ea681f6 authored by Wandenberg Peixoto's avatar Wandenberg Peixoto

different log files for each test, if test fail the was not deleted

parent 606a1925
...@@ -10,6 +10,7 @@ require 'json' ...@@ -10,6 +10,7 @@ require 'json'
module BaseTestCase module BaseTestCase
def setup def setup
create_dirs create_dirs
config_log_and_pid_file
default_configuration default_configuration
@test_config_file = "#{test_method_name}.conf" @test_config_file = "#{test_method_name}.conf"
config_test_name = "config_#{test_method_name}" config_test_name = "config_#{test_method_name}"
...@@ -25,9 +26,8 @@ module BaseTestCase ...@@ -25,9 +26,8 @@ module BaseTestCase
def teardown def teardown
unless @disable_start_stop_server unless @disable_start_stop_server
self.stop_server self.stop_server
self.delete_config_file
end end
delete_dirs self.delete_config_and_log_files
end end
def nginx_executable def nginx_executable
...@@ -75,9 +75,14 @@ module BaseTestCase ...@@ -75,9 +75,14 @@ module BaseTestCase
File.open(mime_types_filename, 'w') {|f| f.write(@@mime_tipes_template) } File.open(mime_types_filename, 'w') {|f| f.write(@@mime_tipes_template) }
end end
def delete_config_file def delete_config_and_log_files
File.delete(config_filename) if has_passed?
File.delete(mime_types_filename) File.delete(config_filename) if File.exist?(config_filename)
File.delete(mime_types_filename) if File.exist?(mime_types_filename)
File.delete(@main_error_log) if File.exist?(@main_error_log)
File.delete(@access_log) if File.exist?(@access_log)
File.delete(@error_log) if File.exist?(@error_log)
end
end end
def create_dirs def create_dirs
...@@ -85,9 +90,15 @@ module BaseTestCase ...@@ -85,9 +90,15 @@ module BaseTestCase
FileUtils.mkdir('logs') unless File.exist?('logs') and File.directory?('logs') FileUtils.mkdir('logs') unless File.exist?('logs') and File.directory?('logs')
end end
def delete_dirs def has_passed?
FileUtils.rm_rf('tmp') if File.exist?('tmp') and File.directory?('tmp') @test_passed.nil? ? @passed : @test_passed
FileUtils.rm_rf('logs') if File.exist?('logs') and File.directory?('logs') end
def config_log_and_pid_file
@pid_file = File.expand_path("logs/nginx.pid")
@main_error_log = File.expand_path("logs/nginx-main_error-#{test_method_name}.log")
@access_log = File.expand_path("logs/nginx-http_access-#{test_method_name}.log")
@error_log = File.expand_path("logs/nginx-http_error-#{test_method_name}.log")
end end
def config_filename def config_filename
...@@ -165,8 +176,8 @@ module BaseTestCase ...@@ -165,8 +176,8 @@ module BaseTestCase
end end
@@config_template = %q{ @@config_template = %q{
pid <%= File.expand_path("logs/nginx.pid") %>; pid <%= @pid_file %>;
error_log <%= File.expand_path("logs/nginx-main_error.log") %> debug; error_log <%= @main_error_log %> debug;
# Development Mode # Development Mode
master_process off; master_process off;
daemon off; daemon off;
...@@ -181,8 +192,8 @@ http { ...@@ -181,8 +192,8 @@ http {
include mime.types; include mime.types;
default_type application/octet-stream; default_type application/octet-stream;
access_log <%= File.expand_path("logs/nginx-http_access.log")%>; access_log <%= @access_log %>;
error_log <%= File.expand_path("logs/nginx-http_error.log")%> debug; error_log <%= @error_log %> debug;
tcp_nopush on; tcp_nopush on;
tcp_nodelay on; tcp_nodelay on;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment