Skip to content

Commit

Permalink
- Add enableFailingTask flag for enabling exception throwing of gradl…
Browse files Browse the repository at this point in the history
…e plugin task failure. (#404)

- Upgrade version of plugin to 1.1.6
  • Loading branch information
olivershen-wow committed Mar 30, 2023
1 parent f556f84 commit a60d901
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 7 deletions.
Binary file modified docs/images/UML/gradle_plugin_yaml_config_design.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion gradle_plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ dependencies {
}

// plugin publishing related
version = '1.1.5'
version = '1.1.6'
group = 'com.microsoft.hydralab'
// alter group to this when publish to local, in order to distinguish local version and gradle plugin portal version
//group = 'com.microsoft.hydralab.local'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,5 +90,6 @@ testSpec:
inspectorType: INSPECTOR_ANDROID_BATTERY_INFO
appId: com.microsoft.hydralab.android.client
description: test schedule
enableFailingTask: true

@endyaml
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ class ClientUtilsPlugin implements Plugin<Project> {
// add quotes back as quotes in gradle plugins will be replaced by blanks
testConfig.inspectionStrategiesStr = project.inspectionStrategiesStr.replace("\\", "\"")
}
if (project.hasProperty('enableFailingTask')) {
// add quotes back as quotes in gradle plugins will be replaced by blanks
testConfig.enableFailingTask = Boolean.parseBoolean(project.enableFailingTask)
}

requiredParamCheck(apiConfig, testConfig)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public class TestConfig {
public int testRound = -1;
public List<InspectionStrategy> inspectionStrategies = new ArrayList<>();
public String inspectionStrategiesStr = "";
public boolean enableFailingTask = true;

public void constructField(HashMap<String, Object> map) {
Object queueTimeOutSeconds = map.get("queueTimeOutSeconds");
Expand Down Expand Up @@ -100,6 +101,7 @@ public String toString() {
"\ttestRunArgs=" + testRunArgs + "\n" +
"\tmaxStepCount=" + maxStepCount + "\n" +
"\ttestRound=" + testRound + "\n" +
"\tinspectionStrategiesStr=" + inspectionStrategiesStr;
"\tinspectionStrategiesStr=" + inspectionStrategiesStr + "\n" +
"\tenableFailingTask=" + enableFailingTask;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ public class HydraLabClientUtils {
private static HydraLabAPIClient hydraLabAPIClient = new HydraLabAPIClient();
private static final int waitStartSec = 30;
private static final int minWaitFinishSec = 15;

private static boolean isTestRunningFailed = false;
private static boolean isTestResultFailed = false;

public static void switchClientInstance(HydraLabAPIClient client) {
Expand Down Expand Up @@ -336,16 +334,19 @@ private static void runTestInner(String reportFolderPath, HydraLabAPIConfig apiC
printlnf(testReportUrl);
printlnf("##vso[task.setvariable variable=TestTaskReportLink;]%s", testReportUrl);

displayFinalTestState();
displayFinalTestState(testConfig.enableFailingTask);
}

private static void markTestResultFail() {
isTestResultFailed = true;
}

private static void displayFinalTestState() {
private static void displayFinalTestState(boolean enableFailingTask) {
if (isTestResultFailed) {
printlnf("##[error]Final test state: fail.");
if (enableFailingTask) {
throw new RuntimeException("Test result failed, please check the output test result XML file.");
}
} else {
printlnf("Final test state: success.");
}
Expand Down
2 changes: 2 additions & 0 deletions gradle_plugin/template/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ inspectionStrategiesStr =
# Normal result folder name: $(runningType)-$(dateTime)
# Result folder name with tag: $(runningType)-$(tag)-$(dateTime)
tag =
# Flag to enable failing the task by throwing exception when test failed.
enableFailTask = # Optional, Value: {true (Default), false}

# Dynamic params, should be kept secret or may change frequently.
# Recommend to set these variables within pipeline.
Expand Down
3 changes: 2 additions & 1 deletion gradle_plugin/template/testSpec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,5 @@ testSpec:
inspection:
inspectorType: # <Required if inspectionStrategies is enabled>
appId: # <Required if inspectionStrategies is enabled>
description: # <Required if inspectionStrategies is enabled>
description: # <Required if inspectionStrategies is enabled>
enableFailingTask: # <Optional>

0 comments on commit a60d901

Please sign in to comment.