PageRenderTime 18ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 0ms

/tst/org/diffkit/diff/testcase/TestCaseRunnerRun.groovy

http://diffkit.googlecode.com/
Groovy | 66 lines | 37 code | 11 blank | 18 comment | 5 complexity | f19183d9b2c66d6315c2d8815435ccde MD5 | raw file
  1. /**
  2. * Copyright 2010-2011 Joseph Panico
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. package org.diffkit.diff.testcase
  17. import java.text.SimpleDateFormat;
  18. import org.diffkit.common.DKValidate;
  19. import org.diffkit.db.DKDBFlavor
  20. /**
  21. * @author jpanico
  22. */
  23. public class TestCaseRunnerRun {
  24. private static final SimpleDateFormat DIR_NAME_FORMAT = new SimpleDateFormat('MM.dd.yy.HH.mm.ss');
  25. public final File dir
  26. public final DKDBFlavor flavor
  27. public List<TestCaseRun> testCaseRuns
  28. public TestCaseRunnerRun(File parentDir_, DKDBFlavor flavor_){
  29. DKValidate.notNull(parentDir_, flavor_)
  30. dir = this.createDir(parentDir_)
  31. flavor = flavor_
  32. DKValidate.notNull(dir)
  33. }
  34. private File createDir(File parentDir){
  35. String dirName ='tcr.run.'+ DIR_NAME_FORMAT.format(new Date())
  36. File dirFile = new File(parentDir, dirName)
  37. if (!dirFile.mkdir() )
  38. throw new RuntimeException("couldn't create directory->$dirFile")
  39. return dirFile
  40. }
  41. public void addRun(TestCaseRun run_){
  42. if(!run_)
  43. return;
  44. if(!testCaseRuns)
  45. testCaseRuns = new ArrayList<TestCaseRun>()
  46. testCaseRuns.add(run_)
  47. }
  48. public Boolean getFailed(){
  49. for(def run : testCaseRuns){
  50. if(run.failed)
  51. return true
  52. }
  53. return false
  54. }
  55. }