int longBowMain_Impl(int argc, char *argv[argc], ...) { LongBowStatus exitStatus = LONGBOW_STATUS_SUCCEEDED; // Perform some processing on the input parameters. LongBowConfig *config = longBowConfig_Create(argc, argv, NULL); if (config == NULL) { return LONGBOW_STATUS_FAILED; } va_list ap; va_start(ap, argv); for (LongBowTestRunner *testRunner = va_arg(ap, LongBowTestRunner *); testRunner != NULL; testRunner = va_arg(ap, LongBowTestRunner *)) { if (testRunner != NULL) { longBowTestRunner_SetConfiguration(testRunner, config); longBowTestRunner_Run(testRunner); longBowReportTesting_TestRunner(testRunner); if (!longBowTestRunner_IsSuccessful(testRunner)) { exitStatus = longBowTestRunner_GetStatus(testRunner); } } } va_end(ap); longBowConfig_Destroy(&config); return (int) exitStatus; }
LONGBOW_TEST_CASE(Global, CreateDestroy) { LongBowConfig *config = longBowConfig_Create(0, NULL, NULL); longBowConfig_Destroy(&config); }
LongBowConfig * longBowConfig_Create(int argc, char *argv[], const char *mainFileName) { LongBowConfig *result = longBowMemory_Allocate(sizeof(LongBowConfig)); result->properties = longBowProperties_Create(); longBowProperties_Set(result->properties, "trace", "false"); longBowProperties_Set(result->properties, "silent", "false"); longBowProperties_Set(result->properties, "run-forked", "false"); for (int i = 1; i < argc; i++) { if (longBowString_Equals("--help", argv[i]) || longBowString_Equals("-h", argv[i])) { // If the option is "--help", // then let all of the sub-systems that also take arguments process that option also. printf("LongBow %s\n", longBowAbout_Version()); printf("%s\n", longBowAbout_MiniNotice()); printf("Options\n"); //printf(" --main Print the name of the main test runner source file.\n"); printf(" --help Print this help message.\n"); printf(" --run-forked Run the tests as forked processes.\n"); printf(" --run-nonforked Run the tests in the same process (default).\n"); printf(" --version Print the version of LongBow used for this test.\n"); printf(" --core-dump Produce a core file upon the first failed assertion.\n"); printf(" --set name=value Set a configuration property name to the specified value\n"); longBowTestRunner_ConfigHelp(); longBowTestFixture_ConfigHelp(); longBowTestCase_ConfigHelp(); longBowReportRuntime_Create(argc, argv); longBowConfig_Destroy(&result); printf("\n"); return NULL; } else if (longBowString_Equals("--main", argv[i])) { printf("%s\n", mainFileName); longBowConfig_Destroy(&result); return NULL; } else if (longBowString_Equals("--version", argv[i])) { printf("%s\n", longBowAbout_Version()); longBowConfig_Destroy(&result); return NULL; } else if (longBowString_Equals("--run-nonforked", argv[i])) { longBowProperties_Set(result->properties, "run-forked", "false"); } else if (longBowString_Equals("--run-forked", argv[i])) { printf("?\n"); longBowProperties_Set(result->properties, "run-forked", "true"); } else if (longBowString_Equals("--trace", argv[i])) { longBowProperties_Set(result->properties, "trace", "true"); } else if (longBowString_Equals("--silent", argv[i])) { longBowProperties_Set(result->properties, "silent", "true"); } else if (longBowString_Equals("--core-dump", argv[i])) { longBowProperties_Set(result->properties, "core-dump", "true"); } else if (longBowString_StartsWith(argv[i], "--set")) { char *parameter = argv[++i]; if (_longBowConfig_Set(result, parameter) == false) { printf("Could not set parameter: %s\n", parameter); } } else if (longBowString_StartsWith(argv[i], "--show")) { _longBowConfig_Show(result); } else { printf("Unknown option '%s'\n", argv[i]); } } LongBowReportConfig *reportConfiguration = longBowReportRuntime_Create(argc, argv); if (reportConfiguration == NULL) { longBowConfig_Destroy(&result); result = NULL; } else { if (result == NULL) { // nothing to do. } else { result->reportConfiguration = reportConfiguration; } } if (result != NULL) { _longBowConfig_SetupEnvironment(result); } return result; }