Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7ab1d09f authored by vadimt's avatar vadimt Committed by android-build-merger
Browse files

Continuing experiments with test stability attribute

am: 7ad1026c

Change-Id: I0bb9774313856cd90cb23aea85779d4220d61271
parents eda5c215 7ad1026c
Loading
Loading
Loading
Loading
+49 −66
Original line number Diff line number Diff line
@@ -40,8 +40,8 @@ public class TestStabilityRule implements TestRule {
                    + "(?<local>(BuildFromAndroidStudio|"
                    + "([0-9]+|[A-Z])-eng\\.[a-z]+\\.[0-9]+\\.[0-9]+))|"
                    + "(?<presubmit>([0-9]+|[A-Z])-P[0-9]+)|"
                    + "(?<postsubmit>([0-9]+|[A-Z])+-[0-9]+|"
                    + "(?<platform>([0-9]+|[A-Z])+))"
                    + "(?<postsubmit>([0-9]+|[A-Z])-[0-9]+)|"
                    + "(?<platform>[0-9]+|[A-Z])"
                    + ")$");
    private static final Pattern PLATFORM_BUILD =
            Pattern.compile("^("
@@ -61,8 +61,18 @@ public class TestStabilityRule implements TestRule {
            return new Statement() {
                @Override
                public void evaluate() throws Throwable {
                    final String launcherVersion =
                            getInstrumentation().
                    getRunFlavor();

                    base.evaluate();
                }
            };
        } else {
            return base;
        }
    }

    private static void getRunFlavor() throws Exception {
        final String launcherVersion = getInstrumentation().
                getContext().
                getPackageManager().
                getPackageInfo(
@@ -73,64 +83,37 @@ public class TestStabilityRule implements TestRule {

        final Matcher launcherBuildMatcher = LAUNCHER_BUILD.matcher(launcherVersion);

                    boolean launcherLocalBuild = false;
                    boolean launcherUnbundledPresubmit = false;
                    boolean launcherUnbundledPostsubmit = false;
                    boolean launcherPlatform = false;

        if (!launcherBuildMatcher.find()) {
            Log.e(TAG, "Match not found");
                    } else if (launcherBuildMatcher.group("local") != null) {
                        launcherLocalBuild = true;
                    } else if (launcherBuildMatcher.group("presubmit") != null) {
                        launcherUnbundledPresubmit = true;
                    } else if (launcherBuildMatcher.group("postsubmit") != null) {
                        launcherUnbundledPostsubmit = true;
                    } else if (launcherBuildMatcher.group("platform") != null) {
                        launcherPlatform = true;
                    } else {
                        Log.e(TAG, "ERROR1");
        }

                    boolean platformLocalBuild = false;
                    boolean platformPresubmit = false;
                    boolean platformPostsubmit = false;

        final String platformVersion = Build.VERSION.INCREMENTAL;
        final Matcher platformBuildMatcher = PLATFORM_BUILD.matcher(platformVersion);

        if (!platformBuildMatcher.find()) {
            Log.e(TAG, "Match not found");
                    } else if (platformBuildMatcher.group("commandLine") != null) {
                        platformLocalBuild = true;
                    } else if (platformBuildMatcher.group("presubmit") != null) {
                        platformPresubmit = true;
                    } else if (platformBuildMatcher.group("postsubmit") != null) {
                        platformPostsubmit = true;
                    } else {
                        Log.e(TAG, "ERROR2");
        }

        Log.d(TAG, "Launcher: " + launcherVersion + ", platform: " + platformVersion);

                    if (launcherLocalBuild && (platformLocalBuild || platformPostsubmit)) {
        if (launcherBuildMatcher.group("local") != null && (
                platformBuildMatcher.group("commandLine") != null ||
                        platformBuildMatcher.group("postsubmit") != null)) {
            Log.d(TAG, "LOCAL RUN");
                    } else if (launcherUnbundledPresubmit && platformPostsubmit) {
        } else if (launcherBuildMatcher.group("presubmit") != null
                && platformBuildMatcher.group("postsubmit") != null) {
            Log.d(TAG, "UNBUNDLED PRESUBMIT");
                    } else if (launcherUnbundledPostsubmit && platformPostsubmit) {
        } else if (launcherBuildMatcher.group("postsubmit") != null
                && platformBuildMatcher.group("postsubmit") != null) {
            Log.d(TAG, "UNBUNDLED POSTSUBMIT");
                    } else if (launcherPlatform && platformPresubmit) {
        } else if (launcherBuildMatcher.group("platform") != null
                && platformBuildMatcher.group("presubmit") != null) {
            Log.d(TAG, "PLATFORM PRESUBMIT");
                    } else if (launcherPlatform && platformPostsubmit) {
        } else if (launcherBuildMatcher.group("platform") != null
                && platformBuildMatcher.group("postsubmit") != null) {
            Log.d(TAG, "PLATFORM POSTSUBMIT");
        } else {
            Log.e(TAG, "ERROR3");
        }

                    base.evaluate();
                }
            };
        } else {
            return base;
        }
    }
}