From dae54cd84fff352cd1479314758cfd077da79e16 Mon Sep 17 00:00:00 2001 From: Anton Hansson Date: Wed, 21 Apr 2021 16:30:10 +0100 Subject: Add new stub_only_static_libs attr for sdk_library Allow java_sdk_libraries to include libraries statically into their stubs. The immediate use-case of this is to embed libcore notice files into their stubs. Also extend the java_sdk_library tests for impl/stub-only-libs, plus some not assert utils. Bug: 173186484 Bug: 184839599 Test: soong tests Change-Id: I1ebf2f35c048eab5cec5125482a0304fe660f188 --- android/test_asserts.go | 37 ++++++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) (limited to 'android/test_asserts.go') diff --git a/android/test_asserts.go b/android/test_asserts.go index bfb88ab17..edeb40889 100644 --- a/android/test_asserts.go +++ b/android/test_asserts.go @@ -126,13 +126,44 @@ func AssertStringDoesNotContain(t *testing.T, message string, s string, unexpect } } +// AssertStringContainsEquals checks if the string contains or does not contain the substring, given +// the value of the expected bool. If the expectation does not hold it reports an error prefixed with +// the supplied message and including a reason for why it failed. +func AssertStringContainsEquals(t *testing.T, message string, s string, substring string, expected bool) { + if expected { + AssertStringDoesContain(t, message, s, substring) + } else { + AssertStringDoesNotContain(t, message, s, substring) + } +} + // AssertStringListContains checks if the list of strings contains the expected string. If it does // not then it reports an error prefixed with the supplied message and including a reason for why it // failed. -func AssertStringListContains(t *testing.T, message string, list []string, expected string) { +func AssertStringListContains(t *testing.T, message string, list []string, s string) { + t.Helper() + if !InList(s, list) { + t.Errorf("%s: could not find %q within %q", message, s, list) + } +} + +// AssertStringListDoesNotContain checks if the list of strings contains the expected string. If it does +// then it reports an error prefixed with the supplied message and including a reason for why it failed. +func AssertStringListDoesNotContain(t *testing.T, message string, list []string, s string) { t.Helper() - if !InList(expected, list) { - t.Errorf("%s: could not find %q within %q", message, expected, list) + if InList(s, list) { + t.Errorf("%s: unexpectedly found %q within %q", message, s, list) + } +} + +// AssertStringContainsEquals checks if the string contains or does not contain the substring, given +// the value of the expected bool. If the expectation does not hold it reports an error prefixed with +// the supplied message and including a reason for why it failed. +func AssertStringListContainsEquals(t *testing.T, message string, list []string, s string, expected bool) { + if expected { + AssertStringListContains(t, message, list, s) + } else { + AssertStringListDoesNotContain(t, message, list, s) } } -- cgit v1.2.3-59-g8ed1b