Created
March 19, 2010 14:11
-
-
Save Stray/337532 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# rake file sugar for project sprouts | |
# to specify a package to be tested: rake testpackage['packagename'] | |
# you can also use a package name that recurs as a filter: rake testpackage['api'] | |
# if you like, you can be more specific: rake testpackage['somepackage.model'] | |
# to restore all tests: rake testall | |
# note: these tasks edit the AllTests.as file. | |
desc 'Prepare the AllTests class to test a specific package' | |
task :testpackage, :packageName do |t, args| | |
tempFile = File.new("test/temp.as", "w"); | |
allTestsFile = File.open("test/AllTests.as", "r"); | |
allTestsFile.each do |line| | |
line = line.gsub('//','') | |
if(line.include?('addTest')) | |
if !(line.include?(args.packageName)) | |
line = '//' + line | |
end | |
end | |
tempFile.write(line) | |
end | |
tempFile.close | |
allTestsFile.close | |
File.delete("test/AllTests.as") | |
File.rename("test/temp.as", "test/AllTests.as") | |
Rake::Task[ "test" ].invoke | |
end | |
desc 'Set all tests active in the AllTests.as package' | |
task :testall do | |
tempFile = File.new("test/temp.as", "w"); | |
allTestsFile = File.open("test/AllTests.as", "r"); | |
allTestsFile.each do |line| | |
line = line.gsub('//','') | |
tempFile.write(line) | |
end | |
tempFile.close | |
allTestsFile.close | |
File.delete("test/AllTests.as") | |
File.rename("test/temp.as", "test/AllTests.as") | |
Rake::Task[ "test" ].invoke | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment