1 /* 2 * Copyright (c) 2007, Michael Feathers, James Grenning and Bas Vodde 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are met: 7 * * Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. 9 * * Redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution. 12 * * Neither the name of the <organization> nor the 13 * names of its contributors may be used to endorse or promote products 14 * derived from this software without specific prior written permission. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY 17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 * DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY 20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 */ 27 28 #ifndef D_CommandLineArguments_H 29 #define D_CommandLineArguments_H 30 31 #include "SimpleString.h" 32 #include "TestOutput.h" 33 #include "TestFilter.h" 34 35 class TestPlugin; 36 37 class CommandLineArguments 38 { 39 public: 40 explicit CommandLineArguments(int ac, const char *const *av); 41 virtual ~CommandLineArguments(); 42 43 bool parse(TestPlugin* plugin); 44 bool needHelp() const; 45 bool isVerbose() const; 46 bool isVeryVerbose() const; 47 bool isColor() const; 48 bool isListingTestGroupNames() const; 49 bool isListingTestGroupAndCaseNames() const; 50 bool isRunIgnored() const; 51 size_t getRepeatCount() const; 52 bool isShuffling() const; 53 bool isReversing() const; 54 size_t getShuffleSeed() const; 55 const TestFilter* getGroupFilters() const; 56 const TestFilter* getNameFilters() const; 57 bool isJUnitOutput() const; 58 bool isEclipseOutput() const; 59 bool isTeamCityOutput() const; 60 bool runTestsInSeperateProcess() const; 61 const SimpleString& getPackageName() const; 62 const char* usage() const; 63 const char* help() const; 64 65 private: 66 67 enum OutputType 68 { 69 OUTPUT_ECLIPSE, OUTPUT_JUNIT, OUTPUT_TEAMCITY 70 }; 71 72 int ac_; 73 const char *const *av_; 74 75 bool needHelp_; 76 bool verbose_; 77 bool veryVerbose_; 78 bool color_; 79 bool runTestsAsSeperateProcess_; 80 bool listTestGroupNames_; 81 bool listTestGroupAndCaseNames_; 82 bool runIgnored_; 83 bool reversing_; 84 bool shuffling_; 85 bool shufflingPreSeeded_; 86 size_t repeat_; 87 size_t shuffleSeed_; 88 TestFilter* groupFilters_; 89 TestFilter* nameFilters_; 90 OutputType outputType_; 91 SimpleString packageName_; 92 93 SimpleString getParameterField(int ac, const char *const *av, int& i, const SimpleString& parameterName); 94 void setRepeatCount(int ac, const char *const *av, int& index); 95 bool setShuffle(int ac, const char *const *av, int& index); 96 void addGroupFilter(int ac, const char *const *av, int& index); 97 bool addGroupDotNameFilter(int ac, const char *const *av, int& index); 98 void addStrictGroupFilter(int ac, const char *const *av, int& index); 99 void addExcludeGroupFilter(int ac, const char *const *av, int& index); 100 void addExcludeStrictGroupFilter(int ac, const char *const *av, int& index); 101 void addNameFilter(int ac, const char *const *av, int& index); 102 void addStrictNameFilter(int ac, const char *const *av, int& index); 103 void addExcludeNameFilter(int ac, const char *const *av, int& index); 104 void addExcludeStrictNameFilter(int ac, const char *const *av, int& index); 105 void addTestToRunBasedOnVerboseOutput(int ac, const char *const *av, int& index, const char* parameterName); 106 bool setOutputType(int ac, const char *const *av, int& index); 107 void setPackageName(int ac, const char *const *av, int& index); 108 109 CommandLineArguments(const CommandLineArguments&); 110 CommandLineArguments& operator=(const CommandLineArguments&); 111 112 }; 113 114 #endif 115