def testGetSetResult(self): """Test the get and set result methods of the task. The get result method should return the same results as were set. """ flag_sets = [MockFlagSet(flag) for flag in range(NUM_FLAGS)] for flag_set in flag_sets: result_task = Task(flag_set) # The get result method should return the same results as were set, in # build stage. Currently, the build result is a 5-element tuple containing # the checksum of the result image, the performance cost of the build, the # compilation image, the length of the build, and the length of the text # section of the build. result = tuple( [random.randint(0, RANDOM_BUILD_RESULT) for _ in range(5)]) result_task.SetResult(task.BUILD_STAGE, result) assert result == result_task.GetResult(task.BUILD_STAGE) # The checksum is the identifier of the test stage. identifier = result_task.GetIdentifier(task.TEST_STAGE) # The first element of the result tuple is the checksum. assert identifier == result[0] # The get result method should return the same results as were set, in # test stage. random_test_result = random.randint(0, RANDOM_TESTRESULT) result_task.SetResult(task.TEST_STAGE, random_test_result) test_result = result_task.GetResult(task.TEST_STAGE) assert test_result == random_test_result
def testGetIdentifier(self): """Test the get identifier method of the task. The get identifier method should returns the flag set in the build stage. """ flag_sets = [MockFlagSet(flag) for flag in range(NUM_FLAGS)] for flag_set in flag_sets: identifier_task = Task(flag_set) identifier = identifier_task.GetIdentifier(task.BUILD_STAGE) # The task formats the flag set into a string. assert identifier == str(flag_set.FormattedForUse())