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

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

131

132

133

134

135

136

137

138

139

140

141

142

143

144

145

#!/usr/bin/python 

 

import argparse, sys 

from valid_builders import PRETTY_NAMES, DESKTOP_PLATFORMS, DESKTOP_BUILDERS, MOBILE_BUILDERS,  \ 

                           TEST_BUILDERS, TALOS_BUILDERS, TALOS_SUITES, UNITTEST_SUITES 

 

'''Given a commit message or info file as a string of arguments 

   returns only those builder names that should be built 

    

   Comment has to be passed in split by whitespace, then split on :  

   the part before the : gets -- put in front for argparse''' 

 

def getDesktopBuilders(platforms, builderNames, buildTypes): 

    desktopBuilders = [] 

 

    if platforms != ['none']: 

        for buildType in buildTypes: 

            if buildType == 'opt': 

                buildType = 'build' 

            if buildType == 'debug': 

                buildType = 'leak test build' 

 

            for platform in platforms: 

                platform = 'desktop_' + platform 

                if platform in PRETTY_NAMES.keys(): 

                    custom_builder = "%s tryserver %s" % (PRETTY_NAMES[platform], buildType) 

                    if custom_builder in builderNames: 

                        desktopBuilders.extend([custom_builder]) 

    return desktopBuilders 

 

def getMobileBuilders(platforms, builderNames): 

    mobileBuilders = [] 

    # Need the master list of all possible mobile builders for a quick 'all' 

    # if asking for 'all', still check against the possible builder names to make sure it exists 

    if platforms == ['all']: 

        for m in MOBILE_BUILDERS: 

            if m in builderNames: 

                mobileBuilders.extend([m]) 

    elif platforms != ['none']: 

        for platform in platforms: 

            if platform in ('win32', 'macosx', 'linux'): 

                platform = 'mobile_' + platform 

            if platform in PRETTY_NAMES.keys(): 

                custom_builder = "%s tryserver %s" % (PRETTY_NAMES[platform], b) 

                if custom_builder in builderNames: 

                    mobileBuilders.extend([custom_builder]) 

    return mobileBuilders 

 

def getTestBuilders(platforms, testType, tests, builderNames, buildTypes): 

    testBuilders = [] 

    # for all possible suites, add in the builderNames for that platform 

    if tests != ['none']: 

        if tests == ['all']: 

          if testType == "test": 

            tests = UNITTEST_SUITES 

          if testType == "talos": 

            tests = TALOS_SUITES 

 

        if testType == "test": 

            for buildType in buildTypes: 

                for platform in platforms: 

                    for test in tests: 

                        # we only do unittests on WINNT 6.1 

                        if platform == 'win32': 

                            custom_builder = "%s tryserver %s %s %s" % (PRETTY_NAMES[platform][1], buildType, testType, test) 

                        else: 

                            custom_builder = "%s tryserver %s %s %s" % (PRETTY_NAMES[platform], buildType, testType, test) 

                        if custom_builder in (builderNames): 

                            testBuilders.extend([custom_builder]) 

 

        if testType == "talos": 

            for platform in platforms: 

                for test in tests: 

                    if platform == 'win32': 

                        # we still do talos runs on win2k3 ie: WINNT 5.1 

                        for w in PRETTY_NAMES['win32']: 

                            custom_builder = "%s tryserver %s %s" % (w, testType, test) 

                            if custom_builder in (builderNames): 

                                testBuilders.extend([custom_builder]) 

                    else: 

                        custom_builder = "%s tryserver %s %s" % (PRETTY_NAMES[platform], testType, test) 

                        if custom_builder in (builderNames): 

                            testBuilders.extend([custom_builder]) 

    return testBuilders 

 

def TryParser(message, builderNames): 

 

    parser = argparse.ArgumentParser(description='Pass in a commit message and a list \ 

                                     and tryParse populates the list with the builderNames\ 

                                     that need schedulers.') 

    parser.add_argument('--build', 

                        default='o', 

                        dest='build', 

                        choices='bdo', 

                        help='accepts the build types requested ') 

    parser.add_argument('--p', 

                        default='all', 

                        dest='desktop', 

                        help='provide a list of desktop platforms, or specify none (default is all)') 

    parser.add_argument('--m', 

                        default='all', 

                        dest='mobile', 

                        help='provide a list of mobile platform, or specify none (default is all)') 

    parser.add_argument('--u', 

                        default='none', 

                        dest='test', 

                        help='provide a list of unit tests, or specify all (default is None)') 

    parser.add_argument('--t', 

                        default='none', 

                        dest='talos', 

                        help='provide a list of talos tests, or specify all (default is None)') 

 

    (args, extra) = parser.parse_known_args(message) 

 

    # Build Types input validation is covered by choices 

    if args.build == 'b': 

        args.build = ['opt', 'debug'] 

    elif args.build == 'd': 

        args.build = ['debug'] 

    elif args.build == 'o': 

        args.build = ['opt'] 

 

    if args.desktop == 'all': 

        args.desktop = DESKTOP_PLATFORMS 

        print args.desktop 

    else: 

        args.desktop = args.desktop.split(',') 

        print args.desktop 

 

    if args.mobile: 

        args.mobile = args.mobile.split(',') 

    if args.test: 

        args.test = args.test.split(',') 

    if args.talos: 

        args.talos = args.talos.split(',') 

 

    # Get the custom builder names 

    customBuilderNames = getDesktopBuilders(args.desktop, builderNames, args.build) 

    customBuilderNames.extend(getMobileBuilders(args.mobile, builderNames)) 

    customBuilderNames.extend(getTestBuilders(args.desktop, "test", args.test, 

                              builderNames, args.build)) 

    customBuilderNames.extend(getTestBuilders(args.desktop, "talos", args.talos, builderNames, 

                              args.build)) 

 

    return customBuilderNames