platform_build_soong/android/all_teams_test.go

300 lines
8 KiB
Go
Raw Normal View History

// Copyright 2024 Google Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package android
import (
"android/soong/android/team_proto"
"log"
"testing"
"google.golang.org/protobuf/proto"
)
func TestAllTeams(t *testing.T) {
t.Parallel()
ctx := GroupFixturePreparers(
Add test-only and test-target fields to all_teams proto. The `test-only` flag designates the module contains test-only, not production code. In order to generate code-coverage reports, we wanted a way to filter out code (like java_library) that is test-only and doesn't need to be in the report. The XXX_test modules will have test-only set automatically. For modules like `java_library`, users will be a able to set this in the Android.bp file. As a follow-up, I'll run some queries to find modules that are only reachable from top level test targets and mark them test-only as appropriate. `test-only` is being added to the team.proto and will be written via the `all_teams` target. Currently, it is challenging to find "all top level test targets". I'm adding another field to mark the target as a "top level test target" if it is a XXX_test or XXX_test_host module. The goal is to mark all modules the user intended to run as a test, either with tradefed or directly as a native test. I added 'module-type/kind' to the proto so I can do some queries: gqui from "flatten(out/soong/ownership/all_teams.pb, teams)" proto team.proto:AllTeams 'select teams.kind, count(*) where teams.top_level_target = true group by teams.kind' +--------------+----------+ | teams.kind | count(*) | +--------------+----------+ | android_test | 1379 | | art_cc_test | 56 | | cc_benchmark | 68 | | cc_fuzz | 515 | | cc_test | 3519 | | cc_test_host | 6 | | java_fuzz | 5 | | java_test | 773 | +--------------+----------+ % gqui from "flatten(~/aosp-main-with-phones/out/soong/ownership/all_teams.pb, teams)" proto team.proto:AllTeams 'select teams.kind ,count(*) where teams.test_only = true group by teams.kind' +--------------------------+----------+ | teams.kind | count(*) | +--------------------------+----------+ | android_test | 1379 | | android_test_helper_app | 1678 | | art_cc_test | 56 | | art_cc_test_library | 13 | | cc_benchmark | 68 | | cc_fuzz | 515 | | cc_test | 3519 | | cc_test_host | 6 | | cc_test_library | 484 | | java_library | 2 | | java_test | 773 | | java_test_helper_library | 29 | +--------------------------+----------+ All modules can be seen here: https://docs.google.com/spreadsheets/d/1Zqbh7lDDdlI1xVmrN9fZ8bm8XD7EoORjjiPqbMvAKgQ/edit#gid=396553017 FOLLOW UP cls: *) Add more top level tests, like sh_test and python_test *) Add validation so that only modules currently marked test-only can depend on modules marked test-only *) Remove test_spec, code_metadata, TestModuleProviderKey: aosp/2928500 Test: go test ./java ./cc ./android Test: m blueprint_tests Test: m nothing --no-skip-soong-tests !! android already failing on selects_test Test: m all_teams && gqui from "flatten(out/soong/ownership/all_teams.pb, teams)" Change-Id: Ib97dca60989aa9d7f000727c92af2e354926f072
2024-03-27 14:46:47 +01:00
prepareForTestWithTeamAndFakes,
Prefer variants test-only:true attribute when grouping. When looking at more details of modules that are marked test-only, I saw that `java_test_host` modules were not in the list. The test I wrote for it passes, but in a real run, there are two variants (one windows, one linux) which causes it to fail. The `all_teams` code visis all variants, even not enabled ones. The windows variant, for which GenerateAndroidBuildActions was not being called, did not have a provider and its empty data was overriding the variant for which we had data. I changed the code to prefer variants where it is true. Generally for "test-only", the value is logically true independent of variant, so if one variant sets it true, it should be considered true for all variants. I think this is a slightly better check than preferring a variant with a provider or that is enabled. Prev CL % gqui from "flatten(~/aosp-main-with-phones/out/soong/ownership/all_teams.pb, teams)" proto team.proto:AllTeams 'select teams.kind, count(*) where teams.test_only = true and teams.kind not like "%cc_%" group by teams.kind' +--------------------------+----------+ | teams.kind | count(*) | +--------------------------+----------+ | android_test | 1382 | | android_test_helper_app | 1680 | | java_fuzz | 5 | | java_test | 774 | | java_test_helper_library | 29 | +--------------------------+----------+ After gqui from "flatten(~/aosp-main-with-phones/out/soong/ownership/all_teams.pb, teams)" proto ~/aosp-main-with-phones/build/soong/android/team_proto/team.proto:AllTeams ' select teams.kind, count(*) where teams.test_only = true and teams.kind not like "%cc_%" group by teams.kind' +--------------------------+----------+ | teams.kind | count(*) | +--------------------------+----------+ | android_test | 1382 | | android_test_helper_app | 1680 | | csuite_test | 16 | | java_fuzz | 10 | | java_test | 774 | | java_test_helper_library | 35 | | java_test_host | 495 | +--------------------------+----------+ Test: go test ./android Test: m all_teams Test: m blueprint_tests Change-Id: Idc5ed1c0375dc7390a0d58fcb4bf0d7fe1c7ab4f
2024-04-16 16:33:52 +02:00
// This adds two variants, one armv7-a-neon, one armv8-a
PrepareForTestWithArchMutator,
FixtureRegisterWithContext(func(ctx RegistrationContext) {
ctx.RegisterParallelSingletonType("all_teams", AllTeamsFactory)
}),
).RunTestWithBp(t, `
fake {
name: "main_test",
team: "someteam",
}
team {
name: "someteam",
trendy_team_id: "cool_team",
}
team {
name: "team2",
trendy_team_id: "22222",
}
fake {
name: "tool",
team: "team2",
}
fake {
name: "noteam",
Add test-only and test-target fields to all_teams proto. The `test-only` flag designates the module contains test-only, not production code. In order to generate code-coverage reports, we wanted a way to filter out code (like java_library) that is test-only and doesn't need to be in the report. The XXX_test modules will have test-only set automatically. For modules like `java_library`, users will be a able to set this in the Android.bp file. As a follow-up, I'll run some queries to find modules that are only reachable from top level test targets and mark them test-only as appropriate. `test-only` is being added to the team.proto and will be written via the `all_teams` target. Currently, it is challenging to find "all top level test targets". I'm adding another field to mark the target as a "top level test target" if it is a XXX_test or XXX_test_host module. The goal is to mark all modules the user intended to run as a test, either with tradefed or directly as a native test. I added 'module-type/kind' to the proto so I can do some queries: gqui from "flatten(out/soong/ownership/all_teams.pb, teams)" proto team.proto:AllTeams 'select teams.kind, count(*) where teams.top_level_target = true group by teams.kind' +--------------+----------+ | teams.kind | count(*) | +--------------+----------+ | android_test | 1379 | | art_cc_test | 56 | | cc_benchmark | 68 | | cc_fuzz | 515 | | cc_test | 3519 | | cc_test_host | 6 | | java_fuzz | 5 | | java_test | 773 | +--------------+----------+ % gqui from "flatten(~/aosp-main-with-phones/out/soong/ownership/all_teams.pb, teams)" proto team.proto:AllTeams 'select teams.kind ,count(*) where teams.test_only = true group by teams.kind' +--------------------------+----------+ | teams.kind | count(*) | +--------------------------+----------+ | android_test | 1379 | | android_test_helper_app | 1678 | | art_cc_test | 56 | | art_cc_test_library | 13 | | cc_benchmark | 68 | | cc_fuzz | 515 | | cc_test | 3519 | | cc_test_host | 6 | | cc_test_library | 484 | | java_library | 2 | | java_test | 773 | | java_test_helper_library | 29 | +--------------------------+----------+ All modules can be seen here: https://docs.google.com/spreadsheets/d/1Zqbh7lDDdlI1xVmrN9fZ8bm8XD7EoORjjiPqbMvAKgQ/edit#gid=396553017 FOLLOW UP cls: *) Add more top level tests, like sh_test and python_test *) Add validation so that only modules currently marked test-only can depend on modules marked test-only *) Remove test_spec, code_metadata, TestModuleProviderKey: aosp/2928500 Test: go test ./java ./cc ./android Test: m blueprint_tests Test: m nothing --no-skip-soong-tests !! android already failing on selects_test Test: m all_teams && gqui from "flatten(out/soong/ownership/all_teams.pb, teams)" Change-Id: Ib97dca60989aa9d7f000727c92af2e354926f072
2024-03-27 14:46:47 +01:00
test_only: true,
}
Prefer variants test-only:true attribute when grouping. When looking at more details of modules that are marked test-only, I saw that `java_test_host` modules were not in the list. The test I wrote for it passes, but in a real run, there are two variants (one windows, one linux) which causes it to fail. The `all_teams` code visis all variants, even not enabled ones. The windows variant, for which GenerateAndroidBuildActions was not being called, did not have a provider and its empty data was overriding the variant for which we had data. I changed the code to prefer variants where it is true. Generally for "test-only", the value is logically true independent of variant, so if one variant sets it true, it should be considered true for all variants. I think this is a slightly better check than preferring a variant with a provider or that is enabled. Prev CL % gqui from "flatten(~/aosp-main-with-phones/out/soong/ownership/all_teams.pb, teams)" proto team.proto:AllTeams 'select teams.kind, count(*) where teams.test_only = true and teams.kind not like "%cc_%" group by teams.kind' +--------------------------+----------+ | teams.kind | count(*) | +--------------------------+----------+ | android_test | 1382 | | android_test_helper_app | 1680 | | java_fuzz | 5 | | java_test | 774 | | java_test_helper_library | 29 | +--------------------------+----------+ After gqui from "flatten(~/aosp-main-with-phones/out/soong/ownership/all_teams.pb, teams)" proto ~/aosp-main-with-phones/build/soong/android/team_proto/team.proto:AllTeams ' select teams.kind, count(*) where teams.test_only = true and teams.kind not like "%cc_%" group by teams.kind' +--------------------------+----------+ | teams.kind | count(*) | +--------------------------+----------+ | android_test | 1382 | | android_test_helper_app | 1680 | | csuite_test | 16 | | java_fuzz | 10 | | java_test | 774 | | java_test_helper_library | 35 | | java_test_host | 495 | +--------------------------+----------+ Test: go test ./android Test: m all_teams Test: m blueprint_tests Change-Id: Idc5ed1c0375dc7390a0d58fcb4bf0d7fe1c7ab4f
2024-04-16 16:33:52 +02:00
// write the test-only provider value once
Add test-only and test-target fields to all_teams proto. The `test-only` flag designates the module contains test-only, not production code. In order to generate code-coverage reports, we wanted a way to filter out code (like java_library) that is test-only and doesn't need to be in the report. The XXX_test modules will have test-only set automatically. For modules like `java_library`, users will be a able to set this in the Android.bp file. As a follow-up, I'll run some queries to find modules that are only reachable from top level test targets and mark them test-only as appropriate. `test-only` is being added to the team.proto and will be written via the `all_teams` target. Currently, it is challenging to find "all top level test targets". I'm adding another field to mark the target as a "top level test target" if it is a XXX_test or XXX_test_host module. The goal is to mark all modules the user intended to run as a test, either with tradefed or directly as a native test. I added 'module-type/kind' to the proto so I can do some queries: gqui from "flatten(out/soong/ownership/all_teams.pb, teams)" proto team.proto:AllTeams 'select teams.kind, count(*) where teams.top_level_target = true group by teams.kind' +--------------+----------+ | teams.kind | count(*) | +--------------+----------+ | android_test | 1379 | | art_cc_test | 56 | | cc_benchmark | 68 | | cc_fuzz | 515 | | cc_test | 3519 | | cc_test_host | 6 | | java_fuzz | 5 | | java_test | 773 | +--------------+----------+ % gqui from "flatten(~/aosp-main-with-phones/out/soong/ownership/all_teams.pb, teams)" proto team.proto:AllTeams 'select teams.kind ,count(*) where teams.test_only = true group by teams.kind' +--------------------------+----------+ | teams.kind | count(*) | +--------------------------+----------+ | android_test | 1379 | | android_test_helper_app | 1678 | | art_cc_test | 56 | | art_cc_test_library | 13 | | cc_benchmark | 68 | | cc_fuzz | 515 | | cc_test | 3519 | | cc_test_host | 6 | | cc_test_library | 484 | | java_library | 2 | | java_test | 773 | | java_test_helper_library | 29 | +--------------------------+----------+ All modules can be seen here: https://docs.google.com/spreadsheets/d/1Zqbh7lDDdlI1xVmrN9fZ8bm8XD7EoORjjiPqbMvAKgQ/edit#gid=396553017 FOLLOW UP cls: *) Add more top level tests, like sh_test and python_test *) Add validation so that only modules currently marked test-only can depend on modules marked test-only *) Remove test_spec, code_metadata, TestModuleProviderKey: aosp/2928500 Test: go test ./java ./cc ./android Test: m blueprint_tests Test: m nothing --no-skip-soong-tests !! android already failing on selects_test Test: m all_teams && gqui from "flatten(out/soong/ownership/all_teams.pb, teams)" Change-Id: Ib97dca60989aa9d7f000727c92af2e354926f072
2024-03-27 14:46:47 +01:00
fake {
Prefer variants test-only:true attribute when grouping. When looking at more details of modules that are marked test-only, I saw that `java_test_host` modules were not in the list. The test I wrote for it passes, but in a real run, there are two variants (one windows, one linux) which causes it to fail. The `all_teams` code visis all variants, even not enabled ones. The windows variant, for which GenerateAndroidBuildActions was not being called, did not have a provider and its empty data was overriding the variant for which we had data. I changed the code to prefer variants where it is true. Generally for "test-only", the value is logically true independent of variant, so if one variant sets it true, it should be considered true for all variants. I think this is a slightly better check than preferring a variant with a provider or that is enabled. Prev CL % gqui from "flatten(~/aosp-main-with-phones/out/soong/ownership/all_teams.pb, teams)" proto team.proto:AllTeams 'select teams.kind, count(*) where teams.test_only = true and teams.kind not like "%cc_%" group by teams.kind' +--------------------------+----------+ | teams.kind | count(*) | +--------------------------+----------+ | android_test | 1382 | | android_test_helper_app | 1680 | | java_fuzz | 5 | | java_test | 774 | | java_test_helper_library | 29 | +--------------------------+----------+ After gqui from "flatten(~/aosp-main-with-phones/out/soong/ownership/all_teams.pb, teams)" proto ~/aosp-main-with-phones/build/soong/android/team_proto/team.proto:AllTeams ' select teams.kind, count(*) where teams.test_only = true and teams.kind not like "%cc_%" group by teams.kind' +--------------------------+----------+ | teams.kind | count(*) | +--------------------------+----------+ | android_test | 1382 | | android_test_helper_app | 1680 | | csuite_test | 16 | | java_fuzz | 10 | | java_test | 774 | | java_test_helper_library | 35 | | java_test_host | 495 | +--------------------------+----------+ Test: go test ./android Test: m all_teams Test: m blueprint_tests Change-Id: Idc5ed1c0375dc7390a0d58fcb4bf0d7fe1c7ab4f
2024-04-16 16:33:52 +02:00
name: "test-and-team-and-top1",
Add test-only and test-target fields to all_teams proto. The `test-only` flag designates the module contains test-only, not production code. In order to generate code-coverage reports, we wanted a way to filter out code (like java_library) that is test-only and doesn't need to be in the report. The XXX_test modules will have test-only set automatically. For modules like `java_library`, users will be a able to set this in the Android.bp file. As a follow-up, I'll run some queries to find modules that are only reachable from top level test targets and mark them test-only as appropriate. `test-only` is being added to the team.proto and will be written via the `all_teams` target. Currently, it is challenging to find "all top level test targets". I'm adding another field to mark the target as a "top level test target" if it is a XXX_test or XXX_test_host module. The goal is to mark all modules the user intended to run as a test, either with tradefed or directly as a native test. I added 'module-type/kind' to the proto so I can do some queries: gqui from "flatten(out/soong/ownership/all_teams.pb, teams)" proto team.proto:AllTeams 'select teams.kind, count(*) where teams.top_level_target = true group by teams.kind' +--------------+----------+ | teams.kind | count(*) | +--------------+----------+ | android_test | 1379 | | art_cc_test | 56 | | cc_benchmark | 68 | | cc_fuzz | 515 | | cc_test | 3519 | | cc_test_host | 6 | | java_fuzz | 5 | | java_test | 773 | +--------------+----------+ % gqui from "flatten(~/aosp-main-with-phones/out/soong/ownership/all_teams.pb, teams)" proto team.proto:AllTeams 'select teams.kind ,count(*) where teams.test_only = true group by teams.kind' +--------------------------+----------+ | teams.kind | count(*) | +--------------------------+----------+ | android_test | 1379 | | android_test_helper_app | 1678 | | art_cc_test | 56 | | art_cc_test_library | 13 | | cc_benchmark | 68 | | cc_fuzz | 515 | | cc_test | 3519 | | cc_test_host | 6 | | cc_test_library | 484 | | java_library | 2 | | java_test | 773 | | java_test_helper_library | 29 | +--------------------------+----------+ All modules can be seen here: https://docs.google.com/spreadsheets/d/1Zqbh7lDDdlI1xVmrN9fZ8bm8XD7EoORjjiPqbMvAKgQ/edit#gid=396553017 FOLLOW UP cls: *) Add more top level tests, like sh_test and python_test *) Add validation so that only modules currently marked test-only can depend on modules marked test-only *) Remove test_spec, code_metadata, TestModuleProviderKey: aosp/2928500 Test: go test ./java ./cc ./android Test: m blueprint_tests Test: m nothing --no-skip-soong-tests !! android already failing on selects_test Test: m all_teams && gqui from "flatten(out/soong/ownership/all_teams.pb, teams)" Change-Id: Ib97dca60989aa9d7f000727c92af2e354926f072
2024-03-27 14:46:47 +01:00
test_only: true,
team: "team2",
Prefer variants test-only:true attribute when grouping. When looking at more details of modules that are marked test-only, I saw that `java_test_host` modules were not in the list. The test I wrote for it passes, but in a real run, there are two variants (one windows, one linux) which causes it to fail. The `all_teams` code visis all variants, even not enabled ones. The windows variant, for which GenerateAndroidBuildActions was not being called, did not have a provider and its empty data was overriding the variant for which we had data. I changed the code to prefer variants where it is true. Generally for "test-only", the value is logically true independent of variant, so if one variant sets it true, it should be considered true for all variants. I think this is a slightly better check than preferring a variant with a provider or that is enabled. Prev CL % gqui from "flatten(~/aosp-main-with-phones/out/soong/ownership/all_teams.pb, teams)" proto team.proto:AllTeams 'select teams.kind, count(*) where teams.test_only = true and teams.kind not like "%cc_%" group by teams.kind' +--------------------------+----------+ | teams.kind | count(*) | +--------------------------+----------+ | android_test | 1382 | | android_test_helper_app | 1680 | | java_fuzz | 5 | | java_test | 774 | | java_test_helper_library | 29 | +--------------------------+----------+ After gqui from "flatten(~/aosp-main-with-phones/out/soong/ownership/all_teams.pb, teams)" proto ~/aosp-main-with-phones/build/soong/android/team_proto/team.proto:AllTeams ' select teams.kind, count(*) where teams.test_only = true and teams.kind not like "%cc_%" group by teams.kind' +--------------------------+----------+ | teams.kind | count(*) | +--------------------------+----------+ | android_test | 1382 | | android_test_helper_app | 1680 | | csuite_test | 16 | | java_fuzz | 10 | | java_test | 774 | | java_test_helper_library | 35 | | java_test_host | 495 | +--------------------------+----------+ Test: go test ./android Test: m all_teams Test: m blueprint_tests Change-Id: Idc5ed1c0375dc7390a0d58fcb4bf0d7fe1c7ab4f
2024-04-16 16:33:52 +02:00
arch: {arm: { skip: false},
arm64: { skip: true}},
}
// write the test-only provider once, but on the other arch
fake {
name: "test-and-team-and-top2",
test_only: true,
team: "team2",
arch: {arm: { skip: true},
arm64: { skip: false}},
}
// write the test-only provider value twice
fake {
name: "test-and-team-and-top3",
test_only: true,
team: "team2",
}
// Don't write the test-only provider value
fake {
name: "test-and-team-and-top4",
test_only: true,
team: "team2",
arch: {arm: { skip: true},
arm64: { skip: true}},
}
`)
var teams *team_proto.AllTeams
teams = getTeamProtoOutput(t, ctx)
// map of module name -> trendy team name.
Prefer variants test-only:true attribute when grouping. When looking at more details of modules that are marked test-only, I saw that `java_test_host` modules were not in the list. The test I wrote for it passes, but in a real run, there are two variants (one windows, one linux) which causes it to fail. The `all_teams` code visis all variants, even not enabled ones. The windows variant, for which GenerateAndroidBuildActions was not being called, did not have a provider and its empty data was overriding the variant for which we had data. I changed the code to prefer variants where it is true. Generally for "test-only", the value is logically true independent of variant, so if one variant sets it true, it should be considered true for all variants. I think this is a slightly better check than preferring a variant with a provider or that is enabled. Prev CL % gqui from "flatten(~/aosp-main-with-phones/out/soong/ownership/all_teams.pb, teams)" proto team.proto:AllTeams 'select teams.kind, count(*) where teams.test_only = true and teams.kind not like "%cc_%" group by teams.kind' +--------------------------+----------+ | teams.kind | count(*) | +--------------------------+----------+ | android_test | 1382 | | android_test_helper_app | 1680 | | java_fuzz | 5 | | java_test | 774 | | java_test_helper_library | 29 | +--------------------------+----------+ After gqui from "flatten(~/aosp-main-with-phones/out/soong/ownership/all_teams.pb, teams)" proto ~/aosp-main-with-phones/build/soong/android/team_proto/team.proto:AllTeams ' select teams.kind, count(*) where teams.test_only = true and teams.kind not like "%cc_%" group by teams.kind' +--------------------------+----------+ | teams.kind | count(*) | +--------------------------+----------+ | android_test | 1382 | | android_test_helper_app | 1680 | | csuite_test | 16 | | java_fuzz | 10 | | java_test | 774 | | java_test_helper_library | 35 | | java_test_host | 495 | +--------------------------+----------+ Test: go test ./android Test: m all_teams Test: m blueprint_tests Change-Id: Idc5ed1c0375dc7390a0d58fcb4bf0d7fe1c7ab4f
2024-04-16 16:33:52 +02:00
actualTeams := make(map[string]string)
Add test-only and test-target fields to all_teams proto. The `test-only` flag designates the module contains test-only, not production code. In order to generate code-coverage reports, we wanted a way to filter out code (like java_library) that is test-only and doesn't need to be in the report. The XXX_test modules will have test-only set automatically. For modules like `java_library`, users will be a able to set this in the Android.bp file. As a follow-up, I'll run some queries to find modules that are only reachable from top level test targets and mark them test-only as appropriate. `test-only` is being added to the team.proto and will be written via the `all_teams` target. Currently, it is challenging to find "all top level test targets". I'm adding another field to mark the target as a "top level test target" if it is a XXX_test or XXX_test_host module. The goal is to mark all modules the user intended to run as a test, either with tradefed or directly as a native test. I added 'module-type/kind' to the proto so I can do some queries: gqui from "flatten(out/soong/ownership/all_teams.pb, teams)" proto team.proto:AllTeams 'select teams.kind, count(*) where teams.top_level_target = true group by teams.kind' +--------------+----------+ | teams.kind | count(*) | +--------------+----------+ | android_test | 1379 | | art_cc_test | 56 | | cc_benchmark | 68 | | cc_fuzz | 515 | | cc_test | 3519 | | cc_test_host | 6 | | java_fuzz | 5 | | java_test | 773 | +--------------+----------+ % gqui from "flatten(~/aosp-main-with-phones/out/soong/ownership/all_teams.pb, teams)" proto team.proto:AllTeams 'select teams.kind ,count(*) where teams.test_only = true group by teams.kind' +--------------------------+----------+ | teams.kind | count(*) | +--------------------------+----------+ | android_test | 1379 | | android_test_helper_app | 1678 | | art_cc_test | 56 | | art_cc_test_library | 13 | | cc_benchmark | 68 | | cc_fuzz | 515 | | cc_test | 3519 | | cc_test_host | 6 | | cc_test_library | 484 | | java_library | 2 | | java_test | 773 | | java_test_helper_library | 29 | +--------------------------+----------+ All modules can be seen here: https://docs.google.com/spreadsheets/d/1Zqbh7lDDdlI1xVmrN9fZ8bm8XD7EoORjjiPqbMvAKgQ/edit#gid=396553017 FOLLOW UP cls: *) Add more top level tests, like sh_test and python_test *) Add validation so that only modules currently marked test-only can depend on modules marked test-only *) Remove test_spec, code_metadata, TestModuleProviderKey: aosp/2928500 Test: go test ./java ./cc ./android Test: m blueprint_tests Test: m nothing --no-skip-soong-tests !! android already failing on selects_test Test: m all_teams && gqui from "flatten(out/soong/ownership/all_teams.pb, teams)" Change-Id: Ib97dca60989aa9d7f000727c92af2e354926f072
2024-03-27 14:46:47 +01:00
actualTests := []string{}
actualTopLevelTests := []string{}
for _, teamProto := range teams.Teams {
Prefer variants test-only:true attribute when grouping. When looking at more details of modules that are marked test-only, I saw that `java_test_host` modules were not in the list. The test I wrote for it passes, but in a real run, there are two variants (one windows, one linux) which causes it to fail. The `all_teams` code visis all variants, even not enabled ones. The windows variant, for which GenerateAndroidBuildActions was not being called, did not have a provider and its empty data was overriding the variant for which we had data. I changed the code to prefer variants where it is true. Generally for "test-only", the value is logically true independent of variant, so if one variant sets it true, it should be considered true for all variants. I think this is a slightly better check than preferring a variant with a provider or that is enabled. Prev CL % gqui from "flatten(~/aosp-main-with-phones/out/soong/ownership/all_teams.pb, teams)" proto team.proto:AllTeams 'select teams.kind, count(*) where teams.test_only = true and teams.kind not like "%cc_%" group by teams.kind' +--------------------------+----------+ | teams.kind | count(*) | +--------------------------+----------+ | android_test | 1382 | | android_test_helper_app | 1680 | | java_fuzz | 5 | | java_test | 774 | | java_test_helper_library | 29 | +--------------------------+----------+ After gqui from "flatten(~/aosp-main-with-phones/out/soong/ownership/all_teams.pb, teams)" proto ~/aosp-main-with-phones/build/soong/android/team_proto/team.proto:AllTeams ' select teams.kind, count(*) where teams.test_only = true and teams.kind not like "%cc_%" group by teams.kind' +--------------------------+----------+ | teams.kind | count(*) | +--------------------------+----------+ | android_test | 1382 | | android_test_helper_app | 1680 | | csuite_test | 16 | | java_fuzz | 10 | | java_test | 774 | | java_test_helper_library | 35 | | java_test_host | 495 | +--------------------------+----------+ Test: go test ./android Test: m all_teams Test: m blueprint_tests Change-Id: Idc5ed1c0375dc7390a0d58fcb4bf0d7fe1c7ab4f
2024-04-16 16:33:52 +02:00
if teamProto.TrendyTeamId != nil {
actualTeams[teamProto.GetTargetName()] = *teamProto.TrendyTeamId
} else {
actualTeams[teamProto.GetTargetName()] = ""
}
Add test-only and test-target fields to all_teams proto. The `test-only` flag designates the module contains test-only, not production code. In order to generate code-coverage reports, we wanted a way to filter out code (like java_library) that is test-only and doesn't need to be in the report. The XXX_test modules will have test-only set automatically. For modules like `java_library`, users will be a able to set this in the Android.bp file. As a follow-up, I'll run some queries to find modules that are only reachable from top level test targets and mark them test-only as appropriate. `test-only` is being added to the team.proto and will be written via the `all_teams` target. Currently, it is challenging to find "all top level test targets". I'm adding another field to mark the target as a "top level test target" if it is a XXX_test or XXX_test_host module. The goal is to mark all modules the user intended to run as a test, either with tradefed or directly as a native test. I added 'module-type/kind' to the proto so I can do some queries: gqui from "flatten(out/soong/ownership/all_teams.pb, teams)" proto team.proto:AllTeams 'select teams.kind, count(*) where teams.top_level_target = true group by teams.kind' +--------------+----------+ | teams.kind | count(*) | +--------------+----------+ | android_test | 1379 | | art_cc_test | 56 | | cc_benchmark | 68 | | cc_fuzz | 515 | | cc_test | 3519 | | cc_test_host | 6 | | java_fuzz | 5 | | java_test | 773 | +--------------+----------+ % gqui from "flatten(~/aosp-main-with-phones/out/soong/ownership/all_teams.pb, teams)" proto team.proto:AllTeams 'select teams.kind ,count(*) where teams.test_only = true group by teams.kind' +--------------------------+----------+ | teams.kind | count(*) | +--------------------------+----------+ | android_test | 1379 | | android_test_helper_app | 1678 | | art_cc_test | 56 | | art_cc_test_library | 13 | | cc_benchmark | 68 | | cc_fuzz | 515 | | cc_test | 3519 | | cc_test_host | 6 | | cc_test_library | 484 | | java_library | 2 | | java_test | 773 | | java_test_helper_library | 29 | +--------------------------+----------+ All modules can be seen here: https://docs.google.com/spreadsheets/d/1Zqbh7lDDdlI1xVmrN9fZ8bm8XD7EoORjjiPqbMvAKgQ/edit#gid=396553017 FOLLOW UP cls: *) Add more top level tests, like sh_test and python_test *) Add validation so that only modules currently marked test-only can depend on modules marked test-only *) Remove test_spec, code_metadata, TestModuleProviderKey: aosp/2928500 Test: go test ./java ./cc ./android Test: m blueprint_tests Test: m nothing --no-skip-soong-tests !! android already failing on selects_test Test: m all_teams && gqui from "flatten(out/soong/ownership/all_teams.pb, teams)" Change-Id: Ib97dca60989aa9d7f000727c92af2e354926f072
2024-03-27 14:46:47 +01:00
if teamProto.GetTestOnly() {
actualTests = append(actualTests, teamProto.GetTargetName())
}
if teamProto.GetTopLevelTarget() {
actualTopLevelTests = append(actualTopLevelTests, teamProto.GetTargetName())
}
}
Prefer variants test-only:true attribute when grouping. When looking at more details of modules that are marked test-only, I saw that `java_test_host` modules were not in the list. The test I wrote for it passes, but in a real run, there are two variants (one windows, one linux) which causes it to fail. The `all_teams` code visis all variants, even not enabled ones. The windows variant, for which GenerateAndroidBuildActions was not being called, did not have a provider and its empty data was overriding the variant for which we had data. I changed the code to prefer variants where it is true. Generally for "test-only", the value is logically true independent of variant, so if one variant sets it true, it should be considered true for all variants. I think this is a slightly better check than preferring a variant with a provider or that is enabled. Prev CL % gqui from "flatten(~/aosp-main-with-phones/out/soong/ownership/all_teams.pb, teams)" proto team.proto:AllTeams 'select teams.kind, count(*) where teams.test_only = true and teams.kind not like "%cc_%" group by teams.kind' +--------------------------+----------+ | teams.kind | count(*) | +--------------------------+----------+ | android_test | 1382 | | android_test_helper_app | 1680 | | java_fuzz | 5 | | java_test | 774 | | java_test_helper_library | 29 | +--------------------------+----------+ After gqui from "flatten(~/aosp-main-with-phones/out/soong/ownership/all_teams.pb, teams)" proto ~/aosp-main-with-phones/build/soong/android/team_proto/team.proto:AllTeams ' select teams.kind, count(*) where teams.test_only = true and teams.kind not like "%cc_%" group by teams.kind' +--------------------------+----------+ | teams.kind | count(*) | +--------------------------+----------+ | android_test | 1382 | | android_test_helper_app | 1680 | | csuite_test | 16 | | java_fuzz | 10 | | java_test | 774 | | java_test_helper_library | 35 | | java_test_host | 495 | +--------------------------+----------+ Test: go test ./android Test: m all_teams Test: m blueprint_tests Change-Id: Idc5ed1c0375dc7390a0d58fcb4bf0d7fe1c7ab4f
2024-04-16 16:33:52 +02:00
expectedTeams := map[string]string{
"main_test": "cool_team",
"tool": "22222",
"test-and-team-and-top1": "22222",
"test-and-team-and-top2": "22222",
"test-and-team-and-top3": "22222",
"test-and-team-and-top4": "22222",
"noteam": "",
}
Add test-only and test-target fields to all_teams proto. The `test-only` flag designates the module contains test-only, not production code. In order to generate code-coverage reports, we wanted a way to filter out code (like java_library) that is test-only and doesn't need to be in the report. The XXX_test modules will have test-only set automatically. For modules like `java_library`, users will be a able to set this in the Android.bp file. As a follow-up, I'll run some queries to find modules that are only reachable from top level test targets and mark them test-only as appropriate. `test-only` is being added to the team.proto and will be written via the `all_teams` target. Currently, it is challenging to find "all top level test targets". I'm adding another field to mark the target as a "top level test target" if it is a XXX_test or XXX_test_host module. The goal is to mark all modules the user intended to run as a test, either with tradefed or directly as a native test. I added 'module-type/kind' to the proto so I can do some queries: gqui from "flatten(out/soong/ownership/all_teams.pb, teams)" proto team.proto:AllTeams 'select teams.kind, count(*) where teams.top_level_target = true group by teams.kind' +--------------+----------+ | teams.kind | count(*) | +--------------+----------+ | android_test | 1379 | | art_cc_test | 56 | | cc_benchmark | 68 | | cc_fuzz | 515 | | cc_test | 3519 | | cc_test_host | 6 | | java_fuzz | 5 | | java_test | 773 | +--------------+----------+ % gqui from "flatten(~/aosp-main-with-phones/out/soong/ownership/all_teams.pb, teams)" proto team.proto:AllTeams 'select teams.kind ,count(*) where teams.test_only = true group by teams.kind' +--------------------------+----------+ | teams.kind | count(*) | +--------------------------+----------+ | android_test | 1379 | | android_test_helper_app | 1678 | | art_cc_test | 56 | | art_cc_test_library | 13 | | cc_benchmark | 68 | | cc_fuzz | 515 | | cc_test | 3519 | | cc_test_host | 6 | | cc_test_library | 484 | | java_library | 2 | | java_test | 773 | | java_test_helper_library | 29 | +--------------------------+----------+ All modules can be seen here: https://docs.google.com/spreadsheets/d/1Zqbh7lDDdlI1xVmrN9fZ8bm8XD7EoORjjiPqbMvAKgQ/edit#gid=396553017 FOLLOW UP cls: *) Add more top level tests, like sh_test and python_test *) Add validation so that only modules currently marked test-only can depend on modules marked test-only *) Remove test_spec, code_metadata, TestModuleProviderKey: aosp/2928500 Test: go test ./java ./cc ./android Test: m blueprint_tests Test: m nothing --no-skip-soong-tests !! android already failing on selects_test Test: m all_teams && gqui from "flatten(out/soong/ownership/all_teams.pb, teams)" Change-Id: Ib97dca60989aa9d7f000727c92af2e354926f072
2024-03-27 14:46:47 +01:00
expectedTests := []string{
"noteam",
Prefer variants test-only:true attribute when grouping. When looking at more details of modules that are marked test-only, I saw that `java_test_host` modules were not in the list. The test I wrote for it passes, but in a real run, there are two variants (one windows, one linux) which causes it to fail. The `all_teams` code visis all variants, even not enabled ones. The windows variant, for which GenerateAndroidBuildActions was not being called, did not have a provider and its empty data was overriding the variant for which we had data. I changed the code to prefer variants where it is true. Generally for "test-only", the value is logically true independent of variant, so if one variant sets it true, it should be considered true for all variants. I think this is a slightly better check than preferring a variant with a provider or that is enabled. Prev CL % gqui from "flatten(~/aosp-main-with-phones/out/soong/ownership/all_teams.pb, teams)" proto team.proto:AllTeams 'select teams.kind, count(*) where teams.test_only = true and teams.kind not like "%cc_%" group by teams.kind' +--------------------------+----------+ | teams.kind | count(*) | +--------------------------+----------+ | android_test | 1382 | | android_test_helper_app | 1680 | | java_fuzz | 5 | | java_test | 774 | | java_test_helper_library | 29 | +--------------------------+----------+ After gqui from "flatten(~/aosp-main-with-phones/out/soong/ownership/all_teams.pb, teams)" proto ~/aosp-main-with-phones/build/soong/android/team_proto/team.proto:AllTeams ' select teams.kind, count(*) where teams.test_only = true and teams.kind not like "%cc_%" group by teams.kind' +--------------------------+----------+ | teams.kind | count(*) | +--------------------------+----------+ | android_test | 1382 | | android_test_helper_app | 1680 | | csuite_test | 16 | | java_fuzz | 10 | | java_test | 774 | | java_test_helper_library | 35 | | java_test_host | 495 | +--------------------------+----------+ Test: go test ./android Test: m all_teams Test: m blueprint_tests Change-Id: Idc5ed1c0375dc7390a0d58fcb4bf0d7fe1c7ab4f
2024-04-16 16:33:52 +02:00
"test-and-team-and-top1",
"test-and-team-and-top2",
"test-and-team-and-top3",
// There should be no test-and-team-top4 as we skip writing all variants
// test-only for all variants
Add test-only and test-target fields to all_teams proto. The `test-only` flag designates the module contains test-only, not production code. In order to generate code-coverage reports, we wanted a way to filter out code (like java_library) that is test-only and doesn't need to be in the report. The XXX_test modules will have test-only set automatically. For modules like `java_library`, users will be a able to set this in the Android.bp file. As a follow-up, I'll run some queries to find modules that are only reachable from top level test targets and mark them test-only as appropriate. `test-only` is being added to the team.proto and will be written via the `all_teams` target. Currently, it is challenging to find "all top level test targets". I'm adding another field to mark the target as a "top level test target" if it is a XXX_test or XXX_test_host module. The goal is to mark all modules the user intended to run as a test, either with tradefed or directly as a native test. I added 'module-type/kind' to the proto so I can do some queries: gqui from "flatten(out/soong/ownership/all_teams.pb, teams)" proto team.proto:AllTeams 'select teams.kind, count(*) where teams.top_level_target = true group by teams.kind' +--------------+----------+ | teams.kind | count(*) | +--------------+----------+ | android_test | 1379 | | art_cc_test | 56 | | cc_benchmark | 68 | | cc_fuzz | 515 | | cc_test | 3519 | | cc_test_host | 6 | | java_fuzz | 5 | | java_test | 773 | +--------------+----------+ % gqui from "flatten(~/aosp-main-with-phones/out/soong/ownership/all_teams.pb, teams)" proto team.proto:AllTeams 'select teams.kind ,count(*) where teams.test_only = true group by teams.kind' +--------------------------+----------+ | teams.kind | count(*) | +--------------------------+----------+ | android_test | 1379 | | android_test_helper_app | 1678 | | art_cc_test | 56 | | art_cc_test_library | 13 | | cc_benchmark | 68 | | cc_fuzz | 515 | | cc_test | 3519 | | cc_test_host | 6 | | cc_test_library | 484 | | java_library | 2 | | java_test | 773 | | java_test_helper_library | 29 | +--------------------------+----------+ All modules can be seen here: https://docs.google.com/spreadsheets/d/1Zqbh7lDDdlI1xVmrN9fZ8bm8XD7EoORjjiPqbMvAKgQ/edit#gid=396553017 FOLLOW UP cls: *) Add more top level tests, like sh_test and python_test *) Add validation so that only modules currently marked test-only can depend on modules marked test-only *) Remove test_spec, code_metadata, TestModuleProviderKey: aosp/2928500 Test: go test ./java ./cc ./android Test: m blueprint_tests Test: m nothing --no-skip-soong-tests !! android already failing on selects_test Test: m all_teams && gqui from "flatten(out/soong/ownership/all_teams.pb, teams)" Change-Id: Ib97dca60989aa9d7f000727c92af2e354926f072
2024-03-27 14:46:47 +01:00
}
AssertDeepEquals(t, "compare maps", expectedTeams, actualTeams)
Add test-only and test-target fields to all_teams proto. The `test-only` flag designates the module contains test-only, not production code. In order to generate code-coverage reports, we wanted a way to filter out code (like java_library) that is test-only and doesn't need to be in the report. The XXX_test modules will have test-only set automatically. For modules like `java_library`, users will be a able to set this in the Android.bp file. As a follow-up, I'll run some queries to find modules that are only reachable from top level test targets and mark them test-only as appropriate. `test-only` is being added to the team.proto and will be written via the `all_teams` target. Currently, it is challenging to find "all top level test targets". I'm adding another field to mark the target as a "top level test target" if it is a XXX_test or XXX_test_host module. The goal is to mark all modules the user intended to run as a test, either with tradefed or directly as a native test. I added 'module-type/kind' to the proto so I can do some queries: gqui from "flatten(out/soong/ownership/all_teams.pb, teams)" proto team.proto:AllTeams 'select teams.kind, count(*) where teams.top_level_target = true group by teams.kind' +--------------+----------+ | teams.kind | count(*) | +--------------+----------+ | android_test | 1379 | | art_cc_test | 56 | | cc_benchmark | 68 | | cc_fuzz | 515 | | cc_test | 3519 | | cc_test_host | 6 | | java_fuzz | 5 | | java_test | 773 | +--------------+----------+ % gqui from "flatten(~/aosp-main-with-phones/out/soong/ownership/all_teams.pb, teams)" proto team.proto:AllTeams 'select teams.kind ,count(*) where teams.test_only = true group by teams.kind' +--------------------------+----------+ | teams.kind | count(*) | +--------------------------+----------+ | android_test | 1379 | | android_test_helper_app | 1678 | | art_cc_test | 56 | | art_cc_test_library | 13 | | cc_benchmark | 68 | | cc_fuzz | 515 | | cc_test | 3519 | | cc_test_host | 6 | | cc_test_library | 484 | | java_library | 2 | | java_test | 773 | | java_test_helper_library | 29 | +--------------------------+----------+ All modules can be seen here: https://docs.google.com/spreadsheets/d/1Zqbh7lDDdlI1xVmrN9fZ8bm8XD7EoORjjiPqbMvAKgQ/edit#gid=396553017 FOLLOW UP cls: *) Add more top level tests, like sh_test and python_test *) Add validation so that only modules currently marked test-only can depend on modules marked test-only *) Remove test_spec, code_metadata, TestModuleProviderKey: aosp/2928500 Test: go test ./java ./cc ./android Test: m blueprint_tests Test: m nothing --no-skip-soong-tests !! android already failing on selects_test Test: m all_teams && gqui from "flatten(out/soong/ownership/all_teams.pb, teams)" Change-Id: Ib97dca60989aa9d7f000727c92af2e354926f072
2024-03-27 14:46:47 +01:00
AssertDeepEquals(t, "test matchup", expectedTests, actualTests)
}
func getTeamProtoOutput(t *testing.T, ctx *TestResult) *team_proto.AllTeams {
teams := new(team_proto.AllTeams)
config := ctx.SingletonForTests("all_teams")
allOutputs := config.AllOutputs()
protoPath := allOutputs[0]
out := config.MaybeOutput(protoPath)
outProto := []byte(ContentFromFileRuleForTests(t, ctx.TestContext, out))
if err := proto.Unmarshal(outProto, teams); err != nil {
log.Fatalln("Failed to parse teams proto:", err)
}
return teams
}
// Android.bp
//
// team: team_top
//
// # dir1 has no modules with teams,
// # but has a dir with no Android.bp
// dir1/Android.bp
//
// module_dir1
//
// # dirs without and Android.bp should be fine.
// dir1/dir2/dir3/Android.bp
//
// package {}
// module_dir123
//
// teams_dir/Android.bp
//
// module_with_team1: team1
// team1: 111
//
// # team comes from upper package default
// teams_dir/deeper/Android.bp
//
// module2_with_team1: team1
//
// package_defaults/Android.bp
// package_defaults/pd2/Android.bp
//
// package{ default_team: team_top}
// module_pd2 ## should get team_top
//
// package_defaults/pd2/pd3/Android.bp
//
// module_pd3 ## should get team_top
func TestPackageLookup(t *testing.T) {
t.Parallel()
rootBp := `
team {
name: "team_top",
trendy_team_id: "trendy://team_top",
} `
dir1Bp := `
fake {
name: "module_dir1",
} `
dir3Bp := `
package {}
fake {
name: "module_dir123",
} `
teamsDirBp := `
fake {
name: "module_with_team1",
team: "team1"
}
team {
name: "team1",
trendy_team_id: "111",
} `
teamsDirDeeper := `
fake {
name: "module2_with_team1",
team: "team1"
} `
// create an empty one.
packageDefaultsBp := ""
packageDefaultspd2 := `
package { default_team: "team_top"}
fake {
name: "modulepd2",
} `
packageDefaultspd3 := `
fake {
name: "modulepd3",
}
fake {
name: "modulepd3b",
team: "team1"
} `
ctx := GroupFixturePreparers(
Add test-only and test-target fields to all_teams proto. The `test-only` flag designates the module contains test-only, not production code. In order to generate code-coverage reports, we wanted a way to filter out code (like java_library) that is test-only and doesn't need to be in the report. The XXX_test modules will have test-only set automatically. For modules like `java_library`, users will be a able to set this in the Android.bp file. As a follow-up, I'll run some queries to find modules that are only reachable from top level test targets and mark them test-only as appropriate. `test-only` is being added to the team.proto and will be written via the `all_teams` target. Currently, it is challenging to find "all top level test targets". I'm adding another field to mark the target as a "top level test target" if it is a XXX_test or XXX_test_host module. The goal is to mark all modules the user intended to run as a test, either with tradefed or directly as a native test. I added 'module-type/kind' to the proto so I can do some queries: gqui from "flatten(out/soong/ownership/all_teams.pb, teams)" proto team.proto:AllTeams 'select teams.kind, count(*) where teams.top_level_target = true group by teams.kind' +--------------+----------+ | teams.kind | count(*) | +--------------+----------+ | android_test | 1379 | | art_cc_test | 56 | | cc_benchmark | 68 | | cc_fuzz | 515 | | cc_test | 3519 | | cc_test_host | 6 | | java_fuzz | 5 | | java_test | 773 | +--------------+----------+ % gqui from "flatten(~/aosp-main-with-phones/out/soong/ownership/all_teams.pb, teams)" proto team.proto:AllTeams 'select teams.kind ,count(*) where teams.test_only = true group by teams.kind' +--------------------------+----------+ | teams.kind | count(*) | +--------------------------+----------+ | android_test | 1379 | | android_test_helper_app | 1678 | | art_cc_test | 56 | | art_cc_test_library | 13 | | cc_benchmark | 68 | | cc_fuzz | 515 | | cc_test | 3519 | | cc_test_host | 6 | | cc_test_library | 484 | | java_library | 2 | | java_test | 773 | | java_test_helper_library | 29 | +--------------------------+----------+ All modules can be seen here: https://docs.google.com/spreadsheets/d/1Zqbh7lDDdlI1xVmrN9fZ8bm8XD7EoORjjiPqbMvAKgQ/edit#gid=396553017 FOLLOW UP cls: *) Add more top level tests, like sh_test and python_test *) Add validation so that only modules currently marked test-only can depend on modules marked test-only *) Remove test_spec, code_metadata, TestModuleProviderKey: aosp/2928500 Test: go test ./java ./cc ./android Test: m blueprint_tests Test: m nothing --no-skip-soong-tests !! android already failing on selects_test Test: m all_teams && gqui from "flatten(out/soong/ownership/all_teams.pb, teams)" Change-Id: Ib97dca60989aa9d7f000727c92af2e354926f072
2024-03-27 14:46:47 +01:00
prepareForTestWithTeamAndFakes,
PrepareForTestWithPackageModule,
FixtureRegisterWithContext(func(ctx RegistrationContext) {
ctx.RegisterParallelSingletonType("all_teams", AllTeamsFactory)
}),
FixtureAddTextFile("Android.bp", rootBp),
FixtureAddTextFile("dir1/Android.bp", dir1Bp),
FixtureAddTextFile("dir1/dir2/dir3/Android.bp", dir3Bp),
FixtureAddTextFile("teams_dir/Android.bp", teamsDirBp),
FixtureAddTextFile("teams_dir/deeper/Android.bp", teamsDirDeeper),
FixtureAddTextFile("package_defaults/Android.bp", packageDefaultsBp),
FixtureAddTextFile("package_defaults/pd2/Android.bp", packageDefaultspd2),
FixtureAddTextFile("package_defaults/pd2/pd3/Android.bp", packageDefaultspd3),
).RunTest(t)
var teams *team_proto.AllTeams
teams = getTeamProtoOutput(t, ctx)
// map of module name -> trendy team name.
actualTeams := make(map[string]*string)
for _, teamProto := range teams.Teams {
actualTeams[teamProto.GetTargetName()] = teamProto.TrendyTeamId
}
expectedTeams := map[string]*string{
"module_with_team1": proto.String("111"),
"module2_with_team1": proto.String("111"),
"modulepd2": proto.String("trendy://team_top"),
"modulepd3": proto.String("trendy://team_top"),
"modulepd3b": proto.String("111"),
"module_dir1": nil,
"module_dir123": nil,
}
AssertDeepEquals(t, "compare maps", expectedTeams, actualTeams)
}
Add test-only and test-target fields to all_teams proto. The `test-only` flag designates the module contains test-only, not production code. In order to generate code-coverage reports, we wanted a way to filter out code (like java_library) that is test-only and doesn't need to be in the report. The XXX_test modules will have test-only set automatically. For modules like `java_library`, users will be a able to set this in the Android.bp file. As a follow-up, I'll run some queries to find modules that are only reachable from top level test targets and mark them test-only as appropriate. `test-only` is being added to the team.proto and will be written via the `all_teams` target. Currently, it is challenging to find "all top level test targets". I'm adding another field to mark the target as a "top level test target" if it is a XXX_test or XXX_test_host module. The goal is to mark all modules the user intended to run as a test, either with tradefed or directly as a native test. I added 'module-type/kind' to the proto so I can do some queries: gqui from "flatten(out/soong/ownership/all_teams.pb, teams)" proto team.proto:AllTeams 'select teams.kind, count(*) where teams.top_level_target = true group by teams.kind' +--------------+----------+ | teams.kind | count(*) | +--------------+----------+ | android_test | 1379 | | art_cc_test | 56 | | cc_benchmark | 68 | | cc_fuzz | 515 | | cc_test | 3519 | | cc_test_host | 6 | | java_fuzz | 5 | | java_test | 773 | +--------------+----------+ % gqui from "flatten(~/aosp-main-with-phones/out/soong/ownership/all_teams.pb, teams)" proto team.proto:AllTeams 'select teams.kind ,count(*) where teams.test_only = true group by teams.kind' +--------------------------+----------+ | teams.kind | count(*) | +--------------------------+----------+ | android_test | 1379 | | android_test_helper_app | 1678 | | art_cc_test | 56 | | art_cc_test_library | 13 | | cc_benchmark | 68 | | cc_fuzz | 515 | | cc_test | 3519 | | cc_test_host | 6 | | cc_test_library | 484 | | java_library | 2 | | java_test | 773 | | java_test_helper_library | 29 | +--------------------------+----------+ All modules can be seen here: https://docs.google.com/spreadsheets/d/1Zqbh7lDDdlI1xVmrN9fZ8bm8XD7EoORjjiPqbMvAKgQ/edit#gid=396553017 FOLLOW UP cls: *) Add more top level tests, like sh_test and python_test *) Add validation so that only modules currently marked test-only can depend on modules marked test-only *) Remove test_spec, code_metadata, TestModuleProviderKey: aosp/2928500 Test: go test ./java ./cc ./android Test: m blueprint_tests Test: m nothing --no-skip-soong-tests !! android already failing on selects_test Test: m all_teams && gqui from "flatten(out/soong/ownership/all_teams.pb, teams)" Change-Id: Ib97dca60989aa9d7f000727c92af2e354926f072
2024-03-27 14:46:47 +01:00
type fakeForTests struct {
ModuleBase
sourceProperties SourceProperties
Prefer variants test-only:true attribute when grouping. When looking at more details of modules that are marked test-only, I saw that `java_test_host` modules were not in the list. The test I wrote for it passes, but in a real run, there are two variants (one windows, one linux) which causes it to fail. The `all_teams` code visis all variants, even not enabled ones. The windows variant, for which GenerateAndroidBuildActions was not being called, did not have a provider and its empty data was overriding the variant for which we had data. I changed the code to prefer variants where it is true. Generally for "test-only", the value is logically true independent of variant, so if one variant sets it true, it should be considered true for all variants. I think this is a slightly better check than preferring a variant with a provider or that is enabled. Prev CL % gqui from "flatten(~/aosp-main-with-phones/out/soong/ownership/all_teams.pb, teams)" proto team.proto:AllTeams 'select teams.kind, count(*) where teams.test_only = true and teams.kind not like "%cc_%" group by teams.kind' +--------------------------+----------+ | teams.kind | count(*) | +--------------------------+----------+ | android_test | 1382 | | android_test_helper_app | 1680 | | java_fuzz | 5 | | java_test | 774 | | java_test_helper_library | 29 | +--------------------------+----------+ After gqui from "flatten(~/aosp-main-with-phones/out/soong/ownership/all_teams.pb, teams)" proto ~/aosp-main-with-phones/build/soong/android/team_proto/team.proto:AllTeams ' select teams.kind, count(*) where teams.test_only = true and teams.kind not like "%cc_%" group by teams.kind' +--------------------------+----------+ | teams.kind | count(*) | +--------------------------+----------+ | android_test | 1382 | | android_test_helper_app | 1680 | | csuite_test | 16 | | java_fuzz | 10 | | java_test | 774 | | java_test_helper_library | 35 | | java_test_host | 495 | +--------------------------+----------+ Test: go test ./android Test: m all_teams Test: m blueprint_tests Change-Id: Idc5ed1c0375dc7390a0d58fcb4bf0d7fe1c7ab4f
2024-04-16 16:33:52 +02:00
props struct {
// If true, don't write test-only value in provider
Skip bool `android:"arch_variant"`
}
Add test-only and test-target fields to all_teams proto. The `test-only` flag designates the module contains test-only, not production code. In order to generate code-coverage reports, we wanted a way to filter out code (like java_library) that is test-only and doesn't need to be in the report. The XXX_test modules will have test-only set automatically. For modules like `java_library`, users will be a able to set this in the Android.bp file. As a follow-up, I'll run some queries to find modules that are only reachable from top level test targets and mark them test-only as appropriate. `test-only` is being added to the team.proto and will be written via the `all_teams` target. Currently, it is challenging to find "all top level test targets". I'm adding another field to mark the target as a "top level test target" if it is a XXX_test or XXX_test_host module. The goal is to mark all modules the user intended to run as a test, either with tradefed or directly as a native test. I added 'module-type/kind' to the proto so I can do some queries: gqui from "flatten(out/soong/ownership/all_teams.pb, teams)" proto team.proto:AllTeams 'select teams.kind, count(*) where teams.top_level_target = true group by teams.kind' +--------------+----------+ | teams.kind | count(*) | +--------------+----------+ | android_test | 1379 | | art_cc_test | 56 | | cc_benchmark | 68 | | cc_fuzz | 515 | | cc_test | 3519 | | cc_test_host | 6 | | java_fuzz | 5 | | java_test | 773 | +--------------+----------+ % gqui from "flatten(~/aosp-main-with-phones/out/soong/ownership/all_teams.pb, teams)" proto team.proto:AllTeams 'select teams.kind ,count(*) where teams.test_only = true group by teams.kind' +--------------------------+----------+ | teams.kind | count(*) | +--------------------------+----------+ | android_test | 1379 | | android_test_helper_app | 1678 | | art_cc_test | 56 | | art_cc_test_library | 13 | | cc_benchmark | 68 | | cc_fuzz | 515 | | cc_test | 3519 | | cc_test_host | 6 | | cc_test_library | 484 | | java_library | 2 | | java_test | 773 | | java_test_helper_library | 29 | +--------------------------+----------+ All modules can be seen here: https://docs.google.com/spreadsheets/d/1Zqbh7lDDdlI1xVmrN9fZ8bm8XD7EoORjjiPqbMvAKgQ/edit#gid=396553017 FOLLOW UP cls: *) Add more top level tests, like sh_test and python_test *) Add validation so that only modules currently marked test-only can depend on modules marked test-only *) Remove test_spec, code_metadata, TestModuleProviderKey: aosp/2928500 Test: go test ./java ./cc ./android Test: m blueprint_tests Test: m nothing --no-skip-soong-tests !! android already failing on selects_test Test: m all_teams && gqui from "flatten(out/soong/ownership/all_teams.pb, teams)" Change-Id: Ib97dca60989aa9d7f000727c92af2e354926f072
2024-03-27 14:46:47 +01:00
}
func fakeFactory() Module {
module := &fakeForTests{}
Prefer variants test-only:true attribute when grouping. When looking at more details of modules that are marked test-only, I saw that `java_test_host` modules were not in the list. The test I wrote for it passes, but in a real run, there are two variants (one windows, one linux) which causes it to fail. The `all_teams` code visis all variants, even not enabled ones. The windows variant, for which GenerateAndroidBuildActions was not being called, did not have a provider and its empty data was overriding the variant for which we had data. I changed the code to prefer variants where it is true. Generally for "test-only", the value is logically true independent of variant, so if one variant sets it true, it should be considered true for all variants. I think this is a slightly better check than preferring a variant with a provider or that is enabled. Prev CL % gqui from "flatten(~/aosp-main-with-phones/out/soong/ownership/all_teams.pb, teams)" proto team.proto:AllTeams 'select teams.kind, count(*) where teams.test_only = true and teams.kind not like "%cc_%" group by teams.kind' +--------------------------+----------+ | teams.kind | count(*) | +--------------------------+----------+ | android_test | 1382 | | android_test_helper_app | 1680 | | java_fuzz | 5 | | java_test | 774 | | java_test_helper_library | 29 | +--------------------------+----------+ After gqui from "flatten(~/aosp-main-with-phones/out/soong/ownership/all_teams.pb, teams)" proto ~/aosp-main-with-phones/build/soong/android/team_proto/team.proto:AllTeams ' select teams.kind, count(*) where teams.test_only = true and teams.kind not like "%cc_%" group by teams.kind' +--------------------------+----------+ | teams.kind | count(*) | +--------------------------+----------+ | android_test | 1382 | | android_test_helper_app | 1680 | | csuite_test | 16 | | java_fuzz | 10 | | java_test | 774 | | java_test_helper_library | 35 | | java_test_host | 495 | +--------------------------+----------+ Test: go test ./android Test: m all_teams Test: m blueprint_tests Change-Id: Idc5ed1c0375dc7390a0d58fcb4bf0d7fe1c7ab4f
2024-04-16 16:33:52 +02:00
module.AddProperties(&module.sourceProperties, &module.props)
InitAndroidArchModule(module, HostAndDeviceSupported, MultilibBoth)
Add test-only and test-target fields to all_teams proto. The `test-only` flag designates the module contains test-only, not production code. In order to generate code-coverage reports, we wanted a way to filter out code (like java_library) that is test-only and doesn't need to be in the report. The XXX_test modules will have test-only set automatically. For modules like `java_library`, users will be a able to set this in the Android.bp file. As a follow-up, I'll run some queries to find modules that are only reachable from top level test targets and mark them test-only as appropriate. `test-only` is being added to the team.proto and will be written via the `all_teams` target. Currently, it is challenging to find "all top level test targets". I'm adding another field to mark the target as a "top level test target" if it is a XXX_test or XXX_test_host module. The goal is to mark all modules the user intended to run as a test, either with tradefed or directly as a native test. I added 'module-type/kind' to the proto so I can do some queries: gqui from "flatten(out/soong/ownership/all_teams.pb, teams)" proto team.proto:AllTeams 'select teams.kind, count(*) where teams.top_level_target = true group by teams.kind' +--------------+----------+ | teams.kind | count(*) | +--------------+----------+ | android_test | 1379 | | art_cc_test | 56 | | cc_benchmark | 68 | | cc_fuzz | 515 | | cc_test | 3519 | | cc_test_host | 6 | | java_fuzz | 5 | | java_test | 773 | +--------------+----------+ % gqui from "flatten(~/aosp-main-with-phones/out/soong/ownership/all_teams.pb, teams)" proto team.proto:AllTeams 'select teams.kind ,count(*) where teams.test_only = true group by teams.kind' +--------------------------+----------+ | teams.kind | count(*) | +--------------------------+----------+ | android_test | 1379 | | android_test_helper_app | 1678 | | art_cc_test | 56 | | art_cc_test_library | 13 | | cc_benchmark | 68 | | cc_fuzz | 515 | | cc_test | 3519 | | cc_test_host | 6 | | cc_test_library | 484 | | java_library | 2 | | java_test | 773 | | java_test_helper_library | 29 | +--------------------------+----------+ All modules can be seen here: https://docs.google.com/spreadsheets/d/1Zqbh7lDDdlI1xVmrN9fZ8bm8XD7EoORjjiPqbMvAKgQ/edit#gid=396553017 FOLLOW UP cls: *) Add more top level tests, like sh_test and python_test *) Add validation so that only modules currently marked test-only can depend on modules marked test-only *) Remove test_spec, code_metadata, TestModuleProviderKey: aosp/2928500 Test: go test ./java ./cc ./android Test: m blueprint_tests Test: m nothing --no-skip-soong-tests !! android already failing on selects_test Test: m all_teams && gqui from "flatten(out/soong/ownership/all_teams.pb, teams)" Change-Id: Ib97dca60989aa9d7f000727c92af2e354926f072
2024-03-27 14:46:47 +01:00
return module
}
var prepareForTestWithTeamAndFakes = GroupFixturePreparers(
FixtureRegisterWithContext(RegisterTeamBuildComponents),
FixtureRegisterWithContext(func(ctx RegistrationContext) {
ctx.RegisterModuleType("fake", fakeFactory)
}),
)
func (f *fakeForTests) GenerateAndroidBuildActions(ctx ModuleContext) {
if Bool(f.sourceProperties.Test_only) {
SetProvider(ctx, TestOnlyProviderKey, TestModuleInformation{
Prefer variants test-only:true attribute when grouping. When looking at more details of modules that are marked test-only, I saw that `java_test_host` modules were not in the list. The test I wrote for it passes, but in a real run, there are two variants (one windows, one linux) which causes it to fail. The `all_teams` code visis all variants, even not enabled ones. The windows variant, for which GenerateAndroidBuildActions was not being called, did not have a provider and its empty data was overriding the variant for which we had data. I changed the code to prefer variants where it is true. Generally for "test-only", the value is logically true independent of variant, so if one variant sets it true, it should be considered true for all variants. I think this is a slightly better check than preferring a variant with a provider or that is enabled. Prev CL % gqui from "flatten(~/aosp-main-with-phones/out/soong/ownership/all_teams.pb, teams)" proto team.proto:AllTeams 'select teams.kind, count(*) where teams.test_only = true and teams.kind not like "%cc_%" group by teams.kind' +--------------------------+----------+ | teams.kind | count(*) | +--------------------------+----------+ | android_test | 1382 | | android_test_helper_app | 1680 | | java_fuzz | 5 | | java_test | 774 | | java_test_helper_library | 29 | +--------------------------+----------+ After gqui from "flatten(~/aosp-main-with-phones/out/soong/ownership/all_teams.pb, teams)" proto ~/aosp-main-with-phones/build/soong/android/team_proto/team.proto:AllTeams ' select teams.kind, count(*) where teams.test_only = true and teams.kind not like "%cc_%" group by teams.kind' +--------------------------+----------+ | teams.kind | count(*) | +--------------------------+----------+ | android_test | 1382 | | android_test_helper_app | 1680 | | csuite_test | 16 | | java_fuzz | 10 | | java_test | 774 | | java_test_helper_library | 35 | | java_test_host | 495 | +--------------------------+----------+ Test: go test ./android Test: m all_teams Test: m blueprint_tests Change-Id: Idc5ed1c0375dc7390a0d58fcb4bf0d7fe1c7ab4f
2024-04-16 16:33:52 +02:00
TestOnly: Bool(f.sourceProperties.Test_only) && !f.props.Skip,
Add test-only and test-target fields to all_teams proto. The `test-only` flag designates the module contains test-only, not production code. In order to generate code-coverage reports, we wanted a way to filter out code (like java_library) that is test-only and doesn't need to be in the report. The XXX_test modules will have test-only set automatically. For modules like `java_library`, users will be a able to set this in the Android.bp file. As a follow-up, I'll run some queries to find modules that are only reachable from top level test targets and mark them test-only as appropriate. `test-only` is being added to the team.proto and will be written via the `all_teams` target. Currently, it is challenging to find "all top level test targets". I'm adding another field to mark the target as a "top level test target" if it is a XXX_test or XXX_test_host module. The goal is to mark all modules the user intended to run as a test, either with tradefed or directly as a native test. I added 'module-type/kind' to the proto so I can do some queries: gqui from "flatten(out/soong/ownership/all_teams.pb, teams)" proto team.proto:AllTeams 'select teams.kind, count(*) where teams.top_level_target = true group by teams.kind' +--------------+----------+ | teams.kind | count(*) | +--------------+----------+ | android_test | 1379 | | art_cc_test | 56 | | cc_benchmark | 68 | | cc_fuzz | 515 | | cc_test | 3519 | | cc_test_host | 6 | | java_fuzz | 5 | | java_test | 773 | +--------------+----------+ % gqui from "flatten(~/aosp-main-with-phones/out/soong/ownership/all_teams.pb, teams)" proto team.proto:AllTeams 'select teams.kind ,count(*) where teams.test_only = true group by teams.kind' +--------------------------+----------+ | teams.kind | count(*) | +--------------------------+----------+ | android_test | 1379 | | android_test_helper_app | 1678 | | art_cc_test | 56 | | art_cc_test_library | 13 | | cc_benchmark | 68 | | cc_fuzz | 515 | | cc_test | 3519 | | cc_test_host | 6 | | cc_test_library | 484 | | java_library | 2 | | java_test | 773 | | java_test_helper_library | 29 | +--------------------------+----------+ All modules can be seen here: https://docs.google.com/spreadsheets/d/1Zqbh7lDDdlI1xVmrN9fZ8bm8XD7EoORjjiPqbMvAKgQ/edit#gid=396553017 FOLLOW UP cls: *) Add more top level tests, like sh_test and python_test *) Add validation so that only modules currently marked test-only can depend on modules marked test-only *) Remove test_spec, code_metadata, TestModuleProviderKey: aosp/2928500 Test: go test ./java ./cc ./android Test: m blueprint_tests Test: m nothing --no-skip-soong-tests !! android already failing on selects_test Test: m all_teams && gqui from "flatten(out/soong/ownership/all_teams.pb, teams)" Change-Id: Ib97dca60989aa9d7f000727c92af2e354926f072
2024-03-27 14:46:47 +01:00
TopLevelTarget: false,
})
}
}