source: flex_extract.git/python/test_suite.py @ 97e09f4

ctbtodevfeature/makefilesorigin/task/language-editingtask/language-editing
Last change on this file since 97e09f4 was 54a8a01, checked in by Anne Philipp <anne.philipp@…>, 3 years ago

restructuring, documentations and bug fixes

  • Property mode set to 100755
File size: 3.4 KB
Line 
1#!/usr/bin/env python
2# -*- coding: utf-8 -*-
3#*******************************************************************************
4# @Author: Leopold Haimberger (University of Vienna)
5#
6# @Date: December 2015
7#
8# @Change History:
9#
10#    February 2018 - Anne Philipp (University of Vienna):
11#        - applied PEP8 style guide
12#        - added documentation
13#
14# @License:
15#    (C) Copyright 2015-2018.
16#
17#    This software is licensed under the terms of the Apache Licence Version 2.0
18#    which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
19#
20# @Program Functionality:
21#    This script triggers the flex_extract test suite. Call with
22#    test_suite.py [test group]
23#
24# @Program Content:
25#
26#*******************************************************************************
27
28# ------------------------------------------------------------------------------
29# MODULES
30# ------------------------------------------------------------------------------
31import os
32import sys
33import json
34import subprocess
35
36# ------------------------------------------------------------------------------
37# PROGRAM
38# ------------------------------------------------------------------------------
39try:
40    taskfile = open('test_suite.json')
41except IOError:
42    print 'could not open suite definition file test_suite.json'
43    exit()
44
45if not os.path.isfile('../src/CONVERT2'):
46    print '../src/CONVERT2 could not be found'
47    print 'please run "install.py --target=local" first'
48    exit()
49
50fprs = os.getenv('FLEXPART_ROOT_SCRIPTS')
51if fprs is None:
52    print 'FLEXPART_ROOT_SCRIPTS not set .. some test jobs may fail'
53
54tasks = json.load(taskfile, encoding='latin-1')
55taskfile.close()
56if not os.path.exists('../test'):
57    os.makedirs('../test')
58if len(sys.argv) > 1:
59    groups = sys.argv[1:]
60else:
61    groups = ['xinstall', 'default', 'ops', 'work', 'cv', 'fc']#,'hires']
62jobcounter = 0
63jobfailed = 0
64for g in groups:
65    try:
66        tk, tv = g, tasks[g]
67    finally:
68        pass
69    garglist = []
70    for ttk, ttv in tv.iteritems():
71        if isinstance(ttv, basestring):
72            if ttk != 'script':
73                garglist.append('--' + ttk)
74                if ttv[0] == '$':
75                    garglist.append(os.path.expandvars(ttv))
76                else:
77                    garglist.append(ttv)
78    for ttk, ttv in tv.iteritems():
79        if isinstance(ttv, dict):
80            arglist = []
81            for tttk, tttv in ttv.iteritems():
82                if isinstance(tttv, basestring):
83                    arglist.append('--' + tttk)
84                    if '$' in tttv[0]:
85                        arglist.append(os.path.expandvars(tttv))
86                    else:
87                        arglist.append(tttv)
88            print 'Command: ', ' '.join([tv['script']] + garglist + arglist)
89            o = '../test/' + tk + '_' + ttk + '_' + '_'.join(ttv.keys())
90            print 'Output will be sent to ', o
91            f = open(o, 'w')
92            try:
93                p = subprocess.check_call([tv['script']] + garglist + arglist,
94                                          stdout=f, stderr=f)
95            except subprocess.CalledProcessError as e:
96                f.write('\nFAILED\n')
97                print 'FAILED'
98                jobfailed += 1
99            jobcounter += 1
100            f.close()
101
102print 'Test suite tasks completed'
103print str(jobcounter-jobfailed) + ' successful, ' + str(jobfailed) + ' failed'
104print 'If tasks have been submitted via ECACCESS please check emails'
Note: See TracBrowser for help on using the repository browser.
hosted by ZAMG