From 3b1160606693f6951bf8866471f61586bb8b602d Mon Sep 17 00:00:00 2001 From: Pavel Lobashov Date: Tue, 16 Feb 2016 11:07:37 +0300 Subject: [PATCH 1/8] Remove unused method `get_file_path` --- app/helpers/runner_helper.rb | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/app/helpers/runner_helper.rb b/app/helpers/runner_helper.rb index 3cdbcf1ce..506f99f28 100644 --- a/app/helpers/runner_helper.rb +++ b/app/helpers/runner_helper.rb @@ -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 = [] From 230f4633a3958a59ac90c3c31ef4ff9403c45b5a Mon Sep 17 00:00:00 2001 From: Pavel Lobashov Date: Tue, 16 Feb 2016 11:08:17 +0300 Subject: [PATCH 2/8] Do not show any hidden files --- app/helpers/runner_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/helpers/runner_helper.rb b/app/helpers/runner_helper.rb index 506f99f28..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) From 36ff6cc8afd574e585d49488af63dab5dc6b4752 Mon Sep 17 00:00:00 2001 From: Pavel Lobashov Date: Tue, 16 Feb 2016 11:09:03 +0300 Subject: [PATCH 3/8] Add method `command_executioner` and use it --- app/server/managers/test_manager.rb | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/server/managers/test_manager.rb b/app/server/managers/test_manager.rb index 2962cfbe3..407a1cfe3 100644 --- a/app/server/managers/test_manager.rb +++ b/app/server/managers/test_manager.rb @@ -2,6 +2,15 @@ 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) @ssh_pid = Process.spawn(full_start_command, out: [server_log_path, 'w']) @@ -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) From 9035df0b797cc7653edf7a94562c5b9d6fcabc2a Mon Sep 17 00:00:00 2001 From: Pavel Lobashov Date: Tue, 16 Feb 2016 11:09:26 +0300 Subject: [PATCH 4/8] Replace usage of tilda (~) on `$HOME` ~ cannot be used in paths in quotes, like '~/RubymineProjcets/OnlineDocument', it will raise `file not found` There is no such problem with '$HOME/RubymineProjcets/OnlineDocument' --- app/server/managers/test_manager.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/server/managers/test_manager.rb b/app/server/managers/test_manager.rb index 407a1cfe3..8aea8949b 100644 --- a/app/server/managers/test_manager.rb +++ b/app/server/managers/test_manager.rb @@ -12,7 +12,7 @@ def command_executioner(test) 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 From 845eae537d9ec08ea7b16ed7276e6454cd4d06dd Mon Sep 17 00:00:00 2001 From: Pavel Lobashov Date: Tue, 16 Feb 2016 11:12:37 +0300 Subject: [PATCH 5/8] Do not hide non `_spec.rb` files in file list --- app/views/runner/show_tests.erb | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/app/views/runner/show_tests.erb b/app/views/runner/show_tests.erb index b49194db6..3ca4682c3 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 %> From ea169cb1c0c6378dae486a260f882b73954db35a Mon Sep 17 00:00:00 2001 From: Pavel Lobashov Date: Tue, 16 Feb 2016 11:13:05 +0300 Subject: [PATCH 6/8] Use root folders of project for view of all files --- config/initializers/constants.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/initializers/constants.rb b/config/initializers/constants.rb index b4be66958..167ab19a3 100644 --- a/config/initializers/constants.rb +++ b/config/initializers/constants.rb @@ -1,7 +1,7 @@ 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" +DOCS_TESTS_PATH = "/#{ENV['HOME']}/RubymineProjects/OnlineDocuments/" +TEAMLAB_TESTS_PATH = "/#{ENV['HOME']}/RubymineProjects/TeamLab/" SERVERS_LOGS_PATH = 'app/server/logs' DOCS_PROJECT_NAME = 'OnlineDocuments' TEAMLAB_PROJECT_NAME = 'TeamLab' From ba5df0e9bda11be2e164d22b7f36b7a2688445f7 Mon Sep 17 00:00:00 2001 From: Pavel Lobashov Date: Tue, 16 Feb 2016 11:15:28 +0300 Subject: [PATCH 7/8] Add Changelog for any files run feature --- Changelog.md | 5 +++++ 1 file changed, 5 insertions(+) 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 From e90ed5e74a4a5ca7e8b23ade3cb24a464a5a9ffe Mon Sep 17 00:00:00 2001 From: Pavel Lobashov Date: Tue, 16 Feb 2016 11:25:53 +0300 Subject: [PATCH 8/8] Remove redundant constants `DOCS_TESTS_PATH` and `TEAMLAB_PROJECT_PATH`. --- app/views/runner/show_tests.erb | 12 ++++++------ config/initializers/constants.rb | 2 -- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/app/views/runner/show_tests.erb b/app/views/runner/show_tests.erb index 3ca4682c3..cbe0a7b72 100644 --- a/app/views/runner/show_tests.erb +++ b/app/views/runner/show_tests.erb @@ -32,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 167ab19a3..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/" -TEAMLAB_TESTS_PATH = "/#{ENV['HOME']}/RubymineProjects/TeamLab/" SERVERS_LOGS_PATH = 'app/server/logs' DOCS_PROJECT_NAME = 'OnlineDocuments' TEAMLAB_PROJECT_NAME = 'TeamLab'