Skip to content

Commit

Permalink
[Test] Break massive ios_test function into factory (#754)
Browse files Browse the repository at this point in the history
Add the ability to override stuff.

Test rules were impossible to extend and difficult reasoning about how
it worked with rules_apple - which led to issues implementing new
features like shard by class.

Test rules simply accept a `test_suite_factory`. On the default one,
which you can override parts if necesary. _The default one could be much
generic - but at some point, I expect people to just make their own
`test_suite_factory` VS adding too many abstractions to it_

Last: normalize all into a single bundle - otherwise it would duplicate
tons of data and be un-useable at scale.
  • Loading branch information
jerrymarino authored Aug 15, 2023
1 parent b17f64e commit f5fd958
Show file tree
Hide file tree
Showing 2 changed files with 279 additions and 67 deletions.
136 changes: 133 additions & 3 deletions docs/test_doc.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,139 @@



<a id="default_test_factory.make_tests"></a>

## default_test_factory.make_tests

<pre>
default_test_factory.make_tests(<a href="#default_test_factory.make_tests-factory">factory</a>, <a href="#default_test_factory.make_tests-name">name</a>, <a href="#default_test_factory.make_tests-test_rule">test_rule</a>, <a href="#default_test_factory.make_tests-kwargs">kwargs</a>)
</pre>

Main entry point of generating tests"

**PARAMETERS**


| Name | Description | Default Value |
| :------------- | :------------- | :------------- |
| <a id="default_test_factory.make_tests-factory"></a>factory | <p align="center"> - </p> | none |
| <a id="default_test_factory.make_tests-name"></a>name | <p align="center"> - </p> | none |
| <a id="default_test_factory.make_tests-test_rule"></a>test_rule | <p align="center"> - </p> | none |
| <a id="default_test_factory.make_tests-kwargs"></a>kwargs | <p align="center"> - </p> | none |


<a id="default_test_factory.make_test_suite"></a>

## default_test_factory.make_test_suite

<pre>
default_test_factory.make_test_suite(<a href="#default_test_factory.make_test_suite-factory">factory</a>, <a href="#default_test_factory.make_test_suite-name">name</a>, <a href="#default_test_factory.make_test_suite-test_rule">test_rule</a>, <a href="#default_test_factory.make_test_suite-test_kwargs">test_kwargs</a>)
</pre>



**PARAMETERS**


| Name | Description | Default Value |
| :------------- | :------------- | :------------- |
| <a id="default_test_factory.make_test_suite-factory"></a>factory | <p align="center"> - </p> | none |
| <a id="default_test_factory.make_test_suite-name"></a>name | <p align="center"> - </p> | none |
| <a id="default_test_factory.make_test_suite-test_rule"></a>test_rule | <p align="center"> - </p> | none |
| <a id="default_test_factory.make_test_suite-test_kwargs"></a>test_kwargs | <p align="center"> - </p> | none |


<a id="default_test_factory.make_test_suite_splits"></a>

## default_test_factory.make_test_suite_splits

<pre>
default_test_factory.make_test_suite_splits(<a href="#default_test_factory.make_test_suite_splits-factory">factory</a>, <a href="#default_test_factory.make_test_suite_splits-name">name</a>, <a href="#default_test_factory.make_test_suite_splits-in_kwargs">in_kwargs</a>)
</pre>

Helper function to split up a test for named splits and runners splits

At the end of the day, we need to able to control how many tests / bundles
there are for sharding by class, otherwise it would recompile many times.

Finally - you can set the splits to be whatever you want.

**PARAMETERS**


| Name | Description | Default Value |
| :------------- | :------------- | :------------- |
| <a id="default_test_factory.make_test_suite_splits-factory"></a>factory | <p align="center"> - </p> | none |
| <a id="default_test_factory.make_test_suite_splits-name"></a>name | <p align="center"> - </p> | none |
| <a id="default_test_factory.make_test_suite_splits-in_kwargs"></a>in_kwargs | <p align="center"> - </p> | none |


<a id="default_test_factory.make_runner_split"></a>

## default_test_factory.make_runner_split

<pre>
default_test_factory.make_runner_split(<a href="#default_test_factory.make_runner_split-name">name</a>, <a href="#default_test_factory.make_runner_split-runner">runner</a>, <a href="#default_test_factory.make_runner_split-in_split">in_split</a>)
</pre>



**PARAMETERS**


| Name | Description | Default Value |
| :------------- | :------------- | :------------- |
| <a id="default_test_factory.make_runner_split-name"></a>name | <p align="center"> - </p> | none |
| <a id="default_test_factory.make_runner_split-runner"></a>runner | <p align="center"> - </p> | none |
| <a id="default_test_factory.make_runner_split-in_split"></a>in_split | <p align="center"> - </p> | none |


<a id="default_test_factory.make_named_split"></a>

## default_test_factory.make_named_split

<pre>
default_test_factory.make_named_split(<a href="#default_test_factory.make_named_split-name">name</a>, <a href="#default_test_factory.make_named_split-split_kwargs">split_kwargs</a>, <a href="#default_test_factory.make_named_split-in_split">in_split</a>)
</pre>



**PARAMETERS**


| Name | Description | Default Value |
| :------------- | :------------- | :------------- |
| <a id="default_test_factory.make_named_split-name"></a>name | <p align="center"> - </p> | none |
| <a id="default_test_factory.make_named_split-split_kwargs"></a>split_kwargs | <p align="center"> - </p> | none |
| <a id="default_test_factory.make_named_split-in_split"></a>in_split | <p align="center"> - </p> | none |


<a id="default_test_factory.make_test"></a>

## default_test_factory.make_test

<pre>
default_test_factory.make_test(<a href="#default_test_factory.make_test-name">name</a>, <a href="#default_test_factory.make_test-test_rule">test_rule</a>, <a href="#default_test_factory.make_test-kwargs">kwargs</a>)
</pre>

Helper to create an individual test

**PARAMETERS**


| Name | Description | Default Value |
| :------------- | :------------- | :------------- |
| <a id="default_test_factory.make_test-name"></a>name | <p align="center"> - </p> | none |
| <a id="default_test_factory.make_test-test_rule"></a>test_rule | <p align="center"> - </p> | none |
| <a id="default_test_factory.make_test-kwargs"></a>kwargs | <p align="center"> - </p> | none |


<a id="ios_ui_test"></a>

## ios_ui_test

<pre>
ios_ui_test(<a href="#ios_ui_test-name">name</a>, <a href="#ios_ui_test-apple_library">apple_library</a>, <a href="#ios_ui_test-kwargs">kwargs</a>)
ios_ui_test(<a href="#ios_ui_test-name">name</a>, <a href="#ios_ui_test-apple_library">apple_library</a>, <a href="#ios_ui_test-test_factory">test_factory</a>, <a href="#ios_ui_test-kwargs">kwargs</a>)
</pre>

Builds and packages iOS UI Tests.
Expand All @@ -19,6 +146,7 @@ ios_ui_test(<a href="#ios_ui_test-name">name</a>, <a href="#ios_ui_test-apple_li
| :------------- | :------------- | :------------- |
| <a id="ios_ui_test-name"></a>name | The name of the UI test. | none |
| <a id="ios_ui_test-apple_library"></a>apple_library | The macro used to package sources into a library. | <code>&lt;function apple_library&gt;</code> |
| <a id="ios_ui_test-test_factory"></a>test_factory | Use this to generate other variations of tests. | <code>struct(make_named_split = &lt;function _make_named_split&gt;, make_runner_split = &lt;function _make_runner_split&gt;, make_test = &lt;function _make_test&gt;, make_test_suite = &lt;function _make_test_suite&gt;, make_test_suite_splits = &lt;function _make_test_suite_splits&gt;, make_tests = &lt;function _make_tests&gt;)</code> |
| <a id="ios_ui_test-kwargs"></a>kwargs | Arguments passed to the apple_library and ios_ui_test rules as appropriate. | none |


Expand All @@ -27,7 +155,7 @@ ios_ui_test(<a href="#ios_ui_test-name">name</a>, <a href="#ios_ui_test-apple_li
## ios_unit_snapshot_test

<pre>
ios_unit_snapshot_test(<a href="#ios_unit_snapshot_test-name">name</a>, <a href="#ios_unit_snapshot_test-apple_library">apple_library</a>, <a href="#ios_unit_snapshot_test-kwargs">kwargs</a>)
ios_unit_snapshot_test(<a href="#ios_unit_snapshot_test-name">name</a>, <a href="#ios_unit_snapshot_test-apple_library">apple_library</a>, <a href="#ios_unit_snapshot_test-test_factory">test_factory</a>, <a href="#ios_unit_snapshot_test-kwargs">kwargs</a>)
</pre>

Builds and packages iOS Unit Snapshot Tests.
Expand All @@ -39,6 +167,7 @@ ios_unit_snapshot_test(<a href="#ios_unit_snapshot_test-name">name</a>, <a href=
| :------------- | :------------- | :------------- |
| <a id="ios_unit_snapshot_test-name"></a>name | The name of the UI test. | none |
| <a id="ios_unit_snapshot_test-apple_library"></a>apple_library | The macro used to package sources into a library. | <code>&lt;function apple_library&gt;</code> |
| <a id="ios_unit_snapshot_test-test_factory"></a>test_factory | Use this to generate other variations of tests. | <code>struct(make_named_split = &lt;function _make_named_split&gt;, make_runner_split = &lt;function _make_runner_split&gt;, make_test = &lt;function _make_test&gt;, make_test_suite = &lt;function _make_test_suite&gt;, make_test_suite_splits = &lt;function _make_test_suite_splits&gt;, make_tests = &lt;function _make_tests&gt;)</code> |
| <a id="ios_unit_snapshot_test-kwargs"></a>kwargs | Arguments passed to the apple_library and ios_unit_test rules as appropriate. | none |


Expand All @@ -47,7 +176,7 @@ ios_unit_snapshot_test(<a href="#ios_unit_snapshot_test-name">name</a>, <a href=
## ios_unit_test

<pre>
ios_unit_test(<a href="#ios_unit_test-name">name</a>, <a href="#ios_unit_test-apple_library">apple_library</a>, <a href="#ios_unit_test-kwargs">kwargs</a>)
ios_unit_test(<a href="#ios_unit_test-name">name</a>, <a href="#ios_unit_test-apple_library">apple_library</a>, <a href="#ios_unit_test-test_factory">test_factory</a>, <a href="#ios_unit_test-kwargs">kwargs</a>)
</pre>

Builds and packages iOS Unit Tests.
Expand All @@ -59,6 +188,7 @@ ios_unit_test(<a href="#ios_unit_test-name">name</a>, <a href="#ios_unit_test-ap
| :------------- | :------------- | :------------- |
| <a id="ios_unit_test-name"></a>name | The name of the unit test. | none |
| <a id="ios_unit_test-apple_library"></a>apple_library | The macro used to package sources into a library. | <code>&lt;function apple_library&gt;</code> |
| <a id="ios_unit_test-test_factory"></a>test_factory | Use this to generate other variations of tests. | <code>struct(make_named_split = &lt;function _make_named_split&gt;, make_runner_split = &lt;function _make_runner_split&gt;, make_test = &lt;function _make_test&gt;, make_test_suite = &lt;function _make_test_suite&gt;, make_test_suite_splits = &lt;function _make_test_suite_splits&gt;, make_tests = &lt;function _make_tests&gt;)</code> |
| <a id="ios_unit_test-kwargs"></a>kwargs | Arguments passed to the apple_library and ios_unit_test rules as appropriate. | none |


Loading

0 comments on commit f5fd958

Please sign in to comment.