aboutsummaryrefslogtreecommitdiffstats
path: root/python/servo/mutation/init.py
blob: 5cf7c1fce4870323e6389d2098a4bc782fb623cb (plain) (blame)
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
# Copyright 2013 The Servo Project Developers. See the COPYRIGHT
# file at the top-level directory of this distribution.
#
# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
# option. This file may not be copied, modified, or distributed
# except according to those terms.

from os import listdir
from os.path import isfile, isdir, join
import json
import sys
import test


def get_folders_list(path):
    folder_list = []
    for filename in listdir(path):
        if (isdir(join(path, filename))):
            folder_name = join(path, filename)
            folder_list.append(folder_name)
        return(folder_list)


def mutation_test_for(mutation_path):
    test_mapping_file = join(mutation_path, 'Test_mapping.json')
    if(isfile(test_mapping_file)):
        json_data = open(test_mapping_file).read()
        test_mapping = json.loads(json_data)

        for src_file in test_mapping.keys():
            test.mutation_test(join(mutation_path, src_file.encode('utf-8')), test_mapping[src_file])

        for folder in get_folders_list(mutation_path):
            mutation_test_for(folder)
    else:
        print("This folder {0} has no test mapping file.".format(mutation_path))

mutation_test_for(sys.argv[1])