-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
107 lines (91 loc) · 3.31 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
begin
require "rake/clean"
require "open-uri"
require "archive"
require "nokogiri"
require "data_mapper"
require "awesome_print"
require "statsample"
Dir.glob(File.dirname(__FILE__) + '/lib/rake_tasks/*.rb') {|file| require file}
Dir.glob(File.dirname(__FILE__) + '/lib/*.rb') {|file| require file}
rescue LoadError => e
puts e
abort "Gems missing. Try use `bundle install`."
end
# This rakefile is used to set up the working environment for the mutation
# score predictor project. There are tasks to download and set up the required
# mutation testing tool Javalanche. Other tasks are present to aid the user in
# running the experiment. (All the tasks are located in /lib/rake_tasks/)
#
# @author Kevin Jalbert
# @version 0.8.0
task :default => :list
# Displays the available commands as well as required tools
task :list do
sh "#{@rake} -T"
puts "\nWork flow: 'install' -> 'setup_svm' -> 'cross_validation'"
puts "Consult README.md for additional details and requirements"
puts "Project being used must be imported in Eclipse (with metrics enabled)"
end
# Cleans the project and any generated files from the execution
task :clean => :clean_project do
# Create data directory to place misc data files
if not File.directory?("data")
mkdir "data"
end
end
# Cleans the project and all files not included in initial repository
task :clobber => :clean_project do
end
# Calls the clean commands on the project, as well as removing produced files
task :clean_project do
Dir.chdir("#{@project_location}") do
# Only clean Javalanche if the javalanche.xml is in the project directory
if File.exists?("javalanche.xml")
sh "#{create_javalanche_command("startHsql")}"
sh "#{create_javalanche_command("deleteResults")}"
sh "#{create_javalanche_command("deleteMutations")}"
sh "#{create_javalanche_command("cleanJavalanche")}"
sh "#{create_javalanche_command("stopHsql")}"
end
rm_f("javalanche.xml")
rm_f("Makefile")
rm_f("runMutations.sh")
rm_f("analyze.csv")
end
end
def find_and_set_classpath
puts "[LOG] Acquiring classpath of project by running ant/maven 'clean' then 'test' tasks"
Dir.chdir(@project_location) do
if @project_builder == "ant"
`ant clean`
output = `ant -v test`
# Take the longest classpath (the correct one)
output.scan(/-classpath'\s*\[junit\]\s*'(.*)'/).each do |match|
@classpath = match[0] if match[0].length > @classpath.length
end
elsif @project_builder == "maven"
`mvn clean`
output = `mvn -X test`
# Take the longest classpath (the correct one)
output.scan(/-classpath\s(.*?)\s/).each do |match|
@classpath = match[0] if match[0].length > @classpath.length
end
else
puts "[WARN] Using @classpath specified in Rakefile"
end
end
end
def number_of_tasks
# Make sure there exists enough memory for the tests to complete
if @memory_for_tests.to_i > @max_memory.to_i
raise("[ERROR] Not enough memory to execute test suite successfully")
end
# Figure out the number of task that can be ran reliably given the max memory
task = @max_memory.to_i / @memory_for_tests.to_i
# Ensure that the number of tasks is less then the number of cores avalible
if task > @max_cores.to_i
task = @max_cores.to_i
end
return task.to_s
end