diff --git a/Changelog.md b/Changelog.md index 9d275dfa9..adfaf0b6f 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,10 @@ # Change log +## 1.8 +### New features +* Test list now shown not only `spec` and `RSpec` folder, but all project folders +* Ability to run any file, not only `_spec.rb`. Currently only supported `_spec.rb` and generic `.rb` files + ## 1.7.1 * Fix order in which project are pulled. If there was new dependencies in `testing-shared` - they will be included in OnlineDocuments diff --git a/app/helpers/runner_helper.rb b/app/helpers/runner_helper.rb index 3cdbcf1ce..782476541 100644 --- a/app/helpers/runner_helper.rb +++ b/app/helpers/runner_helper.rb @@ -4,7 +4,7 @@ def directory_hash(path, name = nil) data[:children] = children = [] data[:path] = path Dir.foreach(path).sort.each do |entry| - next if entry == '..' || entry == '.' + next if entry.start_with?('.') full_path = File.join(path, entry) if File.directory?(full_path) children << directory_hash(full_path, entry) @@ -28,19 +28,6 @@ def get_subtest_by_path(path_to_test) file_tests end - def get_file_path(file_name, project) - project_path = if project == :docs - DOCS_TESTS_PATH - elsif project == :tm - TEAMLAB_TESTS_PATH - end - path_to_test = '' - Find.find(project_path) do |path| - path_to_test = path if path =~ /#{file_name}/ - end - path_to_test.gsub(project_path, '') - end - def get_list_branches(project_path) system_message = `cd #{project_path}; git pull --prune; git checkout develop; git branch -a` branches = [] diff --git a/app/server/managers/test_manager.rb b/app/server/managers/test_manager.rb index 2962cfbe3..8aea8949b 100644 --- a/app/server/managers/test_manager.rb +++ b/app/server/managers/test_manager.rb @@ -2,8 +2,17 @@ module TestManager TEST_SPOT_USER_NAME = 'nct-at' + + # Determine which command is used to run test + # @return [String] command to run test. Empty if not supported. + def command_executioner(test) + return 'rspec' if test.end_with?('_spec.rb') + return 'ruby' if test.end_with?('rb') + '' + end + def start_test_on_server(test_path, options) - full_start_command = generate_run_test_command(test_path, options) + full_start_command = generate_run_test_command(test_path.gsub('~', '$HOME'), options) @ssh_pid = Process.spawn(full_start_command, out: [server_log_path, 'w']) Process.wait(@ssh_pid) full_start_command @@ -24,7 +33,7 @@ def stop_test end def generate_run_test_command(test, options) - execute_docker_command("source ~/.rvm/scripts/rvm; #{options.create_options}; #{open_folder_with_project(test)} && export DISPLAY=:0.0 && rspec '#{test}' #{save_to_html} 2>&1; #{kill_all_browsers_on_server}") + execute_docker_command("source ~/.rvm/scripts/rvm; #{options.create_options}; #{open_folder_with_project(test)} && export DISPLAY=:0.0 && #{command_executioner(test)} '#{test}' #{save_to_html} 2>&1; #{kill_all_browsers_on_server}") end def open_folder_with_project(test_path) diff --git a/app/views/runner/show_tests.erb b/app/views/runner/show_tests.erb index b49194db6..cbe0a7b72 100644 --- a/app/views/runner/show_tests.erb +++ b/app/views/runner/show_tests.erb @@ -11,13 +11,12 @@ <% show_file_tree(current_child, project) %> <% else %> <% unless current_child.has_key?(:children) %> - <% if current_child[:name].include?('_spec.rb') %> - <% child_name = current_child[:name].split('.')[0] %> -
-
add
-
<%= child_name %>
-
- <% end %> + <% child_name = current_child[:name] %> +
+
add
+
<%= child_name %> +
+
<% end %> <% end %> <% end %> @@ -33,26 +32,26 @@ <% if @client %> <% if @client.project == 'docs' %>
- <% show_file_tree(directory_hash(DOCS_TESTS_PATH)[:children], :docs) %> + <% show_file_tree(directory_hash(DOCS_PROJECT_PATH)[:children], :docs) %>
- <% show_file_tree(directory_hash(TEAMLAB_TESTS_PATH)[:children], :tm) %> + <% show_file_tree(directory_hash(DOCS_PROJECT_PATH)[:children], :tm) %>
<% end %> <% if @client.project == 'teamlab' %>
- <% show_file_tree(directory_hash(DOCS_TESTS_PATH)[:children], :docs) %> + <% show_file_tree(directory_hash(DOCS_PROJECT_PATH)[:children], :docs) %>
- <% show_file_tree(directory_hash(TEAMLAB_TESTS_PATH)[:children], :tm) %> + <% show_file_tree(directory_hash(TEAMLAB_PROJECT_PATH)[:children], :tm) %>
<% end %> <% else %>
- <% show_file_tree(directory_hash(DOCS_TESTS_PATH)[:children], :docs) %> + <% show_file_tree(directory_hash(DOCS_PROJECT_PATH)[:children], :docs) %>
- <% show_file_tree(directory_hash(TEAMLAB_TESTS_PATH)[:children], :tm) %> + <% show_file_tree(directory_hash(TEAMLAB_PROJECT_PATH)[:children], :tm) %>
<% end %> diff --git a/config/initializers/constants.rb b/config/initializers/constants.rb index b4be66958..8986d3847 100644 --- a/config/initializers/constants.rb +++ b/config/initializers/constants.rb @@ -1,7 +1,5 @@ DOCS_PROJECT_PATH = "/#{ENV['HOME']}/RubymineProjects/OnlineDocuments" TEAMLAB_PROJECT_PATH = "/#{ENV['HOME']}/RubymineProjects/TeamLab" -DOCS_TESTS_PATH = "/#{ENV['HOME']}/RubymineProjects/OnlineDocuments/spec" -TEAMLAB_TESTS_PATH = "/#{ENV['HOME']}/RubymineProjects/TeamLab/Rspec" SERVERS_LOGS_PATH = 'app/server/logs' DOCS_PROJECT_NAME = 'OnlineDocuments' TEAMLAB_PROJECT_NAME = 'TeamLab'