PageRenderTime 6ms CodeModel.GetById 1ms app.highlight 2ms RepoModel.GetById 1ms 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 */
16package org.diffkit.diff.testcase
17
18import java.text.SimpleDateFormat;
19
20
21import org.diffkit.common.DKValidate;
22import org.diffkit.db.DKDBFlavor 
23
24
25/**
26 * @author jpanico
27 */
28public class TestCaseRunnerRun {
29   
30   private static final SimpleDateFormat DIR_NAME_FORMAT = new SimpleDateFormat('MM.dd.yy.HH.mm.ss');
31   
32   public final File dir
33   public final DKDBFlavor flavor
34   public List<TestCaseRun> testCaseRuns
35   
36   public TestCaseRunnerRun(File parentDir_, DKDBFlavor flavor_){
37      DKValidate.notNull(parentDir_, flavor_)
38      dir = this.createDir(parentDir_)
39      flavor = flavor_
40      DKValidate.notNull(dir)
41   }
42   
43   private File createDir(File parentDir){
44      String dirName ='tcr.run.'+ DIR_NAME_FORMAT.format(new Date())
45      File dirFile = new File(parentDir, dirName)
46      if (!dirFile.mkdir() )
47         throw new RuntimeException("couldn't create directory->$dirFile")
48      return dirFile
49   }
50   
51   public void addRun(TestCaseRun run_){
52      if(!run_)
53         return;
54      if(!testCaseRuns)
55         testCaseRuns = new ArrayList<TestCaseRun>()
56      testCaseRuns.add(run_)
57   }
58   
59   public Boolean getFailed(){
60      for(def run : testCaseRuns){
61         if(run.failed)
62            return true
63      }
64      return false
65   }
66}