|
| 1 | +// Copyright 2023 The Bazel Authors. All rights reserved. |
| 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 | +package com.google.devtools.build.lib.rules.apple; |
| 16 | + |
| 17 | +import com.google.devtools.build.lib.analysis.util.OptionsTestCase; |
| 18 | +import org.junit.Test; |
| 19 | +import org.junit.runner.RunWith; |
| 20 | +import org.junit.runners.JUnit4; |
| 21 | + |
| 22 | +@RunWith(JUnit4.class) |
| 23 | +public final class AppleCommandLineOptionsTest extends OptionsTestCase<AppleCommandLineOptions> { |
| 24 | + |
| 25 | + private static final String IOS_CPUS_PREFIX = "--ios_multi_cpus="; |
| 26 | + private static final String WATCHOS_CPUS_PREFIX = "--watchos_cpus="; |
| 27 | + private static final String MACOS_CPUS_PREFIX = "--macos_cpus="; |
| 28 | + private static final String TVOS_CPUS_PREFIX = "--tvos_cpus="; |
| 29 | + private static final String CATALYST_CPUS_PREFIX = "--catalyst_cpus="; |
| 30 | + |
| 31 | + @Override |
| 32 | + protected Class<AppleCommandLineOptions> getOptionsClass() { |
| 33 | + return AppleCommandLineOptions.class; |
| 34 | + } |
| 35 | + |
| 36 | + @Test |
| 37 | + public void testIosCpus_ordering() throws Exception { |
| 38 | + AppleCommandLineOptions one = createWithPrefix(IOS_CPUS_PREFIX, "foo", "bar"); |
| 39 | + AppleCommandLineOptions two = createWithPrefix(IOS_CPUS_PREFIX, "bar", "foo"); |
| 40 | + assertSame(one, two); |
| 41 | + } |
| 42 | + |
| 43 | + @Test |
| 44 | + public void testIosCpus_duplicates() throws Exception { |
| 45 | + AppleCommandLineOptions one = createWithPrefix(IOS_CPUS_PREFIX, "foo", "foo"); |
| 46 | + AppleCommandLineOptions two = createWithPrefix(IOS_CPUS_PREFIX, "foo"); |
| 47 | + assertSame(one, two); |
| 48 | + } |
| 49 | + |
| 50 | + @Test |
| 51 | + public void testWatchosCpus_ordering() throws Exception { |
| 52 | + AppleCommandLineOptions one = createWithPrefix(WATCHOS_CPUS_PREFIX, "foo", "bar"); |
| 53 | + AppleCommandLineOptions two = createWithPrefix(WATCHOS_CPUS_PREFIX, "bar", "foo"); |
| 54 | + assertSame(one, two); |
| 55 | + } |
| 56 | + |
| 57 | + @Test |
| 58 | + public void testWatchosCpus_duplicates() throws Exception { |
| 59 | + AppleCommandLineOptions one = createWithPrefix(WATCHOS_CPUS_PREFIX, "foo", "foo"); |
| 60 | + AppleCommandLineOptions two = createWithPrefix(WATCHOS_CPUS_PREFIX, "foo"); |
| 61 | + assertSame(one, two); |
| 62 | + } |
| 63 | + |
| 64 | + @Test |
| 65 | + public void testMacosCpus_ordering() throws Exception { |
| 66 | + AppleCommandLineOptions one = createWithPrefix(MACOS_CPUS_PREFIX, "foo", "bar"); |
| 67 | + AppleCommandLineOptions two = createWithPrefix(MACOS_CPUS_PREFIX, "bar", "foo"); |
| 68 | + assertSame(one, two); |
| 69 | + } |
| 70 | + |
| 71 | + @Test |
| 72 | + public void testMacosCpus_duplicates() throws Exception { |
| 73 | + AppleCommandLineOptions one = createWithPrefix(MACOS_CPUS_PREFIX, "foo", "foo"); |
| 74 | + AppleCommandLineOptions two = createWithPrefix(MACOS_CPUS_PREFIX, "foo"); |
| 75 | + assertSame(one, two); |
| 76 | + } |
| 77 | + |
| 78 | + @Test |
| 79 | + public void testTvosCpus_ordering() throws Exception { |
| 80 | + AppleCommandLineOptions one = createWithPrefix(TVOS_CPUS_PREFIX, "foo", "bar"); |
| 81 | + AppleCommandLineOptions two = createWithPrefix(TVOS_CPUS_PREFIX, "bar", "foo"); |
| 82 | + assertSame(one, two); |
| 83 | + } |
| 84 | + |
| 85 | + @Test |
| 86 | + public void testTvosCpus_duplicates() throws Exception { |
| 87 | + AppleCommandLineOptions one = createWithPrefix(TVOS_CPUS_PREFIX, "foo", "foo"); |
| 88 | + AppleCommandLineOptions two = createWithPrefix(TVOS_CPUS_PREFIX, "foo"); |
| 89 | + assertSame(one, two); |
| 90 | + } |
| 91 | + |
| 92 | + @Test |
| 93 | + public void testCatalystCpus_ordering() throws Exception { |
| 94 | + AppleCommandLineOptions one = createWithPrefix(CATALYST_CPUS_PREFIX, "foo", "bar"); |
| 95 | + AppleCommandLineOptions two = createWithPrefix(CATALYST_CPUS_PREFIX, "bar", "foo"); |
| 96 | + assertSame(one, two); |
| 97 | + } |
| 98 | + |
| 99 | + @Test |
| 100 | + public void testCatalystCpus_duplicates() throws Exception { |
| 101 | + AppleCommandLineOptions one = createWithPrefix(CATALYST_CPUS_PREFIX, "foo", "foo"); |
| 102 | + AppleCommandLineOptions two = createWithPrefix(CATALYST_CPUS_PREFIX, "foo"); |
| 103 | + assertSame(one, two); |
| 104 | + } |
| 105 | +} |
0 commit comments