Remi NGUYEN VAN | 11f162b | 2022-05-24 16:47:33 +0900 | [diff] [blame^] | 1 | # Copyright (C) 2022 The Android Open Source Project |
| 2 | # |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | # you may not use this file except in compliance with the License. |
| 5 | # You may obtain a copy of the License at |
| 6 | # |
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | # See the License for the specific language governing permissions and |
| 13 | # limitations under the License. |
| 14 | # |
| 15 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 16 | # you may not use this file except in compliance with the License. |
| 17 | # You may obtain a copy of the License at |
| 18 | # |
| 19 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 20 | # |
| 21 | # Unless required by applicable law or agreed to in writing, software |
| 22 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 23 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 24 | # See the License for the specific language governing permissions and |
| 25 | # limitations under the License. |
| 26 | |
| 27 | import gen_jarjar |
| 28 | import unittest |
| 29 | |
| 30 | |
| 31 | class TestGenJarjar(unittest.TestCase): |
| 32 | def test_gen_rules(self): |
| 33 | args = gen_jarjar.parse_arguments([ |
| 34 | "--jars", "jarjar-rules-generator-testjavalib.jar", |
| 35 | "--prefix", "jarjar.prefix", |
| 36 | "--output", "test-output-rules.txt", |
| 37 | "--apistubs", "framework-connectivity.stubs.module_lib.jar", |
| 38 | "--unsupportedapi", "testdata/test-unsupportedappusage.txt", |
| 39 | "--excludes", "testdata/test-jarjar-excludes.txt", |
| 40 | ]) |
| 41 | gen_jarjar.make_jarjar_rules(args) |
| 42 | |
| 43 | with open(args.output) as out: |
| 44 | lines = out.readlines() |
| 45 | |
| 46 | self.assertListEqual([ |
| 47 | 'rule test.utils.TestUtilClass jarjar.prefix.@0\n', |
| 48 | 'rule test.utils.TestUtilClassTest jarjar.prefix.@0\n', |
| 49 | 'rule test.utils.TestUtilClassTest$* jarjar.prefix.@0\n', |
| 50 | 'rule test.utils.TestUtilClass$TestInnerClass jarjar.prefix.@0\n', |
| 51 | 'rule test.utils.TestUtilClass$TestInnerClassTest jarjar.prefix.@0\n', |
| 52 | 'rule test.utils.TestUtilClass$TestInnerClassTest$* jarjar.prefix.@0\n'], lines) |
| 53 | |
| 54 | |
| 55 | if __name__ == '__main__': |
| 56 | # Need verbosity=2 for the test results parser to find results |
| 57 | unittest.main(verbosity=2) |