> ## Documentation Index
> Fetch the complete documentation index at: https://docs.stoutdata.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Select Test

> Run a Lager test from your GitHub repository on a box, or run a one-off Python script, and watch the output live.

**Select Test** runs a Python test on a box and streams its output to the page. The test comes from your GitHub repository, at the branch or commit that you select.

You can also run a one-off script that is not in the repository. Use **Import Test** for this.

## Before you start

An owner or admin must set up two things once for the organization:

1. Connect the GitHub App. See [GitHub](/source/integrations/github).
2. On **Settings** > **Integrations**, fill in the **Repo Tests** card.

| Field          | Value                                                                                                     |
| -------------- | --------------------------------------------------------------------------------------------------------- |
| **Repository** | The repository that holds your Lager tests, in `owner/repo` form                                          |
| **Tests path** | The directory that Stout searches for `.py` files, with its subdirectories. The default is `tests/lager`. |

An organization has one Repo Tests setup. If the setup is not complete, the Select Test page shows a notice.

Each person who runs a test needs a display name, because Stout locks the box under that name. See [Account](/source/organizations/account).

## Run a test

1. In Workbench, select a box. Then select **Select Test**.
2. In **Box**, select an online box.
3. In **Branch or commit**, select a branch, or type a commit SHA.
4. Find the test in the list. To filter the list by path, type in **Search tests…**.
5. Select **Run** next to the test.

The page starts on the default branch of the repository. The branch list shows up to 100 branches. You can type any other branch name.

The **Output** card streams the output of the test. Its heading shows the test path, the branch or commit, and the box.

## What happens during a run

* Stout gets the test file from GitHub, at the branch or commit that you selected.
* Stout locks the box under your display name. It releases the lock when the run ends.
* If you already hold the lock, Stout uses your lock and does not release it.
* Stout gives the test the variables and secrets for the organization and the box. See [Variables and secrets](/source/organizations/variables-and-secrets).
* The test stops after 300 seconds.

If the box runs a Lager version without lock support, the test runs without a lock.

Stout refuses the run in these cases:

| Condition                                            | Result                                           |
| ---------------------------------------------------- | ------------------------------------------------ |
| The box is offline.                                  | Stout refuses the run.                           |
| Another person holds the lock on the box.            | Stout refuses the run and names the lock holder. |
| You have no display name.                            | Stout refuses the run.                           |
| The file is not a `.py` file under the tests path.   | Stout refuses the run.                           |
| The file is larger than 10 MB.                       | Stout refuses the run.                           |
| GitHub is not connected, or Repo Tests has no setup. | Stout refuses the run.                           |

## Stop watching a run

While a test runs, the **Output** card shows **Abort**. **Abort** stops the output stream in your browser.

<Warning>
  **Abort** does not stop the test on the box. Before you select **Abort**, make sure that the test can finish safely. The test continues until it ends or reaches 300 seconds, and the lock stays until then.
</Warning>

## Import a one-off script

**Import Test** runs a Python script that is not in the repository. The button becomes available after you select a box.

1. Select **Import Test**. The **Run Python Script** dialog opens, with the box from the page selected.
2. Paste the script on the **Code Editor** tab, or drop a `.py` file on the **Upload File** tab.
3. Optional: In **Arguments**, type the arguments, with spaces between them.
4. Optional: Under **Environment Variables**, select **Add**, and then type a name and a value.
5. Select **Run Script**.

The dialog shows the output of the script. Stout also gives the script the variables and secrets for the organization and the box.

The box must be online. A script can be up to 10 MB.

The **Timeout (seconds)** field starts at 3600. The box stops a script after 300 seconds, even when the field has a larger value.

<Warning>
  **Import Test** does not check the box lock, and it does not take a lock. Before you run a script, check the lock state of the box in the **Box** field of the Select Test page.
</Warning>

## Who can run tests

* Owners and admins can run tests and scripts on every box in the organization.
* Members can run tests and scripts only on the boxes that they can access.
* Only owners and admins can change the Repo Tests setup.

See [Roles and permissions](/source/concepts/roles-and-permissions).

<CardGroup cols={2}>
  <Card title="GitHub" href="/source/integrations/github">
    Connect the GitHub App and set up Repo Tests.
  </Card>

  <Card title="lager python" href="https://docs.lagerdata.com/source/reference/cli/python">
    Run the same scripts from the Lager CLI.
  </Card>
</CardGroup>
