Skip to content

Commit 31d0a80

Browse files
committed
Document define_platforms and browser settings
See flutter#391
1 parent d65bbbb commit 31d0a80

File tree

1 file changed

+90
-0
lines changed

1 file changed

+90
-0
lines changed

doc/configuration.md

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ tags:
5252
* [Configuring Platforms](#configuring-platforms)
5353
* [`on_os`](#on_os)
5454
* [`on_platform`](#on_platform)
55+
* [`define_platform`](#define_platform)
56+
* [Browser Settings](#browser-settings)
57+
* [`executable`](#executable)
5558
* [Configuration Presets](#configuration-presets)
5659
* [`presets`](#presets)
5760
* [`add_preset`](#add_preset)
@@ -567,6 +570,93 @@ when running on a particular operating system, use [`on_os`](#on_os) instead.
567570

568571
This field counts as [test configuration](#test-configuration).
569572

573+
### `define_platforms`
574+
575+
You can define new platforms in terms of old ones using the `define_platforms`
576+
field. This lets you define variants of existing platforms without overriding
577+
the old ones. This field takes a map from the new platform identifiers to
578+
definitions for those platforms. For example:
579+
580+
```yaml
581+
define_platforms:
582+
# This identifier is used to select the platform with the --platform flag.
583+
chromium:
584+
# A human-friendly name for the platform.
585+
name: Chromium
586+
587+
# The identifier for the platform that this is based on.
588+
extends: chrome
589+
590+
# Settings for the new child platform.
591+
settings:
592+
executable: chromium
593+
```
594+
595+
Once this is defined, you can run `pub run test -p chromium` and it will run
596+
those tests in the Chromium browser, using the same logic it normally uses for
597+
Chrome. You can even use `chromium` in platform selectors; for example, you
598+
might pass `testOn: "chromium"` to declare that a test is Chromium-specific.
599+
User-defined platforms also count as their parents, so Chromium will run tests
600+
that say `testOn: "chrome"` as well.
601+
602+
Each platform can define exactly which settings it supports. All browsers
603+
support [the same settings](#browser-settings), but the VM doesn't support any
604+
settings and so can't be extended.
605+
606+
This field is not supported in the
607+
[global configuration file](#global-configuration).
608+
609+
### Browser Settings
610+
611+
All built-in browser platforms provide the same settings that can be set using
612+
[`define_platforms`](#define_platforms), which control how the browser
613+
executable is invoked.
614+
615+
#### `executable`
616+
617+
The `executable` field tells the test runner where to look for the executable to
618+
use to start the browser. It has three sub-keys, one for each supported operating
619+
system, which each take a path or an executable name:
620+
621+
```yaml
622+
define_platforms:
623+
chromium:
624+
name: Chromium
625+
extends: chrome
626+
627+
settings:
628+
executable:
629+
linux: chromium
630+
mac_os: /Applications/Chromium.app/Contents/MacOS/Chromium
631+
windows: Chromium\Application\chrome.exe
632+
```
633+
634+
Executables can be defined in three ways:
635+
636+
* As a plain basename, with no path separators. These executables are passed
637+
directly to the OS, which looks them up using the `PATH` environment variable.
638+
639+
* As an absolute path, which is used as-is.
640+
641+
* **Only on Windows**, as a relative path. The test runner will look up this
642+
path relative to the `LOCALAPPATA`, `PROGRAMFILES`, and `PROGRAMFILES(X86)`
643+
environment variables, in that order.
644+
645+
If a platform is omitted, it defaults to using the built-in executable location.
646+
647+
As a shorthand, you can also define the same executable for all operating
648+
systems:
649+
650+
```yaml
651+
define_platforms:
652+
chromium:
653+
name: Chromium
654+
extends: chrome
655+
656+
settings:
657+
executable: chromium
658+
```
659+
570660
## Configuration Presets
571661

572662
*Presets* are collections of configuration that can be explicitly selected on

0 commit comments

Comments
 (0)