Skip to content

Commit

Permalink
Maze runner tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesLindsay0 committed Aug 6, 2024
1 parent 6bd0164 commit fdc9006
Show file tree
Hide file tree
Showing 9 changed files with 300 additions and 3 deletions.
1 change: 1 addition & 0 deletions .buildkite/block.full.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ steps:
buildkite-agent pipeline upload .buildkite/pipeline.ios.full.yml &&
buildkite-agent pipeline upload .buildkite/pipeline.windows.full.yml &&
buildkite-agent pipeline upload .buildkite/pipeline.macos.full.yml &&
buildkite-agent pipeline upload .buildkite/pipeline.linux.full.yml &&
buildkite-agent pipeline upload .buildkite/pipeline.webgl.full.yml
197 changes: 197 additions & 0 deletions .buildkite/pipeline.linux.full.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,197 @@
aliases:
- &2020 "2020.3.48f1"
- &2021 "2021.3.36f1"
- &2022 "2022.3.22f1"
- &2023 "2023.2.19f1"

agents:
queue: macos-14

steps:
#
# Build Linux test fixtures
#
- label: Build Unity 2020 Linux test fixture
timeout_in_minutes: 30
key: "linux-2020-fixture"
depends_on: "build-artifacts"
env:
UNITY_VERSION: *2020
plugins:
artifacts#v1.9.0:
download:
- Bugsnag.unitypackage
upload:
- unity.log
- features/fixtures/maze_runner/build/linux-release-2020.zip
commands:
- scripts/ci-build-linux-fixture.sh release
retry:
automatic:
- exit_status: "*"
limit: 1

- label: Build Unity 2021 linux test fixture
timeout_in_minutes: 30
key: "linux-2021-fixture"
depends_on: "build-artifacts"
env:
UNITY_VERSION: *2021
commands:
- scripts/ci-build-linux-fixture.sh release
plugins:
artifacts#v1.9.0:
download:
- Bugsnag.unitypackage
upload:
- unity.log
- unity_import.log
- c/linux-release-2021.zip
retry:
automatic:
- exit_status: "*"
limit: 1

- label: Build Unity 2021 linux DEV test fixture
timeout_in_minutes: 30
key: "linux-2021-dev-fixture"
depends_on: "build-artifacts"
env:
UNITY_VERSION: *2021
commands:
- scripts/ci-build-linux-fixture.sh dev
plugins:
artifacts#v1.9.0:
download:
- Bugsnag.unitypackage
upload:
- unity.log
- unity_import.log
- features/fixtures/maze_runner/build/linux-dev-2021.zip
retry:
automatic:
- exit_status: "*"
limit: 1

- label: Build Unity 2022 linux test fixture
timeout_in_minutes: 30
key: "linux-2022-fixture"
depends_on: "build-artifacts"
env:
UNITY_VERSION: *2022
commands:
- scripts/ci-build-linux-fixture.sh release
plugins:
artifacts#v1.9.0:
download:
- Bugsnag.unitypackage
upload:
- unity.log
- unity_import.log
- features/fixtures/maze_runner/build/linux-release-2022.zip
retry:
automatic:
- exit_status: "*"
limit: 1

- label: Build Unity 2023 linux test fixture
skip: Pending PLAT-12072
timeout_in_minutes: 30
key: "linux-2023-fixture"
depends_on: "build-artifacts"
env:
UNITY_VERSION: *2023
commands:
- scripts/ci-build-linux-fixture.sh release
plugins:
artifacts#v1.9.0:
download:
- Bugsnag.unitypackage
upload:
- unity.log
- unity_import.log
- features/fixtures/maze_runner/build/linux-release-2023.zip
retry:
automatic:
- exit_status: "*"
limit: 1

#
# Run linux e2e tests
#
- label: Run linux e2e tests for Unity 2020
timeout_in_minutes: 30
depends_on: "linux-2020-fixture"
env:
UNITY_VERSION: *2020
plugins:
artifacts#v1.9.0:
download:
- features/fixtures/maze_runner/build/linux-release-2020.zip
upload:
- maze_output/**/*
- maze_output/metrics.csv

command:
- scripts/ci-run-linux-tests-wsl.sh release

- label: Run linux e2e tests for Unity 2021
timeout_in_minutes: 30
depends_on: "linux-2021-fixture"
env:
UNITY_VERSION: *2021
plugins:
artifacts#v1.9.0:
download:
- features/fixtures/maze_runner/build/linux-release-2021.zip
upload:
- maze_output/**/*
- maze_output/metrics.csv
commands:
- scripts/ci-run-linux-tests-wsl.sh release

- label: Run linux e2e DEV tests for Unity 2021
timeout_in_minutes: 30
depends_on: "linux-2021-dev-fixture"
env:
UNITY_VERSION: *2021
plugins:
artifacts#v1.9.0:
download:
- features/fixtures/maze_runner/build/linux-dev-2021.zip
upload:
- maze_output/**/*
- maze_output/metrics.csv
commands:
- scripts/ci-run-linux-tests-wsl.sh dev

- label: Run linux e2e tests for Unity 2022
timeout_in_minutes: 30
depends_on: "linux-2022-fixture"
env:
UNITY_VERSION: *2022
plugins:
artifacts#v1.9.0:
download:
- features/fixtures/maze_runner/build/linux-release-2022.zip
upload:
- maze_output/**/*
- maze_output/metrics.csv
commands:
- scripts/ci-run-linux-tests-wsl.sh release

- label: Run linux e2e tests for Unity 2023
skip: Pending PLAT-12072
timeout_in_minutes: 30
depends_on: "linux-2023-fixture"
env:
UNITY_VERSION: *2023
plugins:
artifacts#v1.9.0:
download:
- features/fixtures/maze_runner/build/linux-release-2023.zip
upload:
- maze_output/**/*
- maze_output/metrics.csv
commands:
- scripts/ci-run-linux-tests-wsl.sh release
1 change: 1 addition & 0 deletions .buildkite/pipeline_trigger.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ if [[ "$BUILDKITE_MESSAGE" == *"[full ci]"* ||
buildkite-agent pipeline upload .buildkite/pipeline.ios.full.yml
buildkite-agent pipeline upload .buildkite/pipeline.windows.full.yml
buildkite-agent pipeline upload .buildkite/pipeline.macos.full.yml
buildkite-agent pipeline upload .buildkite/pipeline.linux.full.yml
buildkite-agent pipeline upload .buildkite/pipeline.webgl.full.yml
else
# Basic build, but allow a full build to be triggered
Expand Down
27 changes: 25 additions & 2 deletions TESTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ This will generate the following file:
#### MacOS
1. `UNITY_VERSION=2018.4.36f1 ./features/scripts/build_maze_runner.sh macos`
1. `UNITY_VERSION=2018.4.36f1 ./features/scripts/build_maze_runner.sh release macos`
Where `UNITY_VERSION` corresponds to the Unity installation path, e.g:
```
Expand All @@ -119,7 +119,7 @@ This will generate the test fixture app:
Building the test fixture on Windows requires a Git bash terminal.
In a Git bash terminal:
1. `UNITY_VERSION=2018.4.36f1 ./features/scripts/build_maze_runner.sh windows`
1. `UNITY_VERSION=2018.4.36f1 ./features/scripts/build_maze_runner.sh release windows`
Where `UNITY_VERSION` corresponds to the Unity installation path, e.g:
```
Expand All @@ -132,6 +132,20 @@ dependencies:
./features/fixtures/maze_runner/build/Windows
```
#### Linux
1. `UNITY_VERSION=2021.3.40f1 ./features/scripts/build_maze_runner.sh release linux`
Where `UNITY_VERSION` corresponds to the Unity installation path, e.g:
```
$HOME/Unity/Hub/Editor/$UNITY_VERSION/Editor/Unity
```
This will generate a build folder containing the test fixture executable, together with the UnityPlayer.so and other
dependencies:
```
./features/fixtures/maze_runner/build/linux
```
### Running an end-to-end test
#### MacOS
Expand All @@ -155,6 +169,15 @@ In the Ubuntu terminal:
bundle exec maze-runner --app=features/fixtures/maze_runner/build/Windows/Mazerunner.exe --os=windows
```
#### Linux
1. Check the contents of `Gemfile` to select the version of `maze-runner` to use
1. Run `bundle install` if you haven't run end-to-end tests before
1. To run the tests:
```shell script
bundle exec maze-runner --app=features/fixtures/maze_runner/build/linux/Mazerunner --os=linux
```

#### WebGL

The WebGL e2e tests depend on Chrome and `chromedriver` (available from Homebrew).
Expand Down
15 changes: 15 additions & 0 deletions features/fixtures/maze_runner/Assets/Editor/Builder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ public static void Win64Release()
Win64(false);
}

public static void Linux64Release()
{
Linux64(false);
}

public static void WebGLRelease()
{
WebGL(false);
Expand All @@ -46,6 +51,11 @@ public static void Win64Dev()
Win64(true);
}

public static void Linux64Dev()
{
Linux64(true);
}

public static void WebGLDev()
{
WebGL(true);
Expand All @@ -61,6 +71,11 @@ static void Win64(bool dev)
BuildStandalone(dev ? "build/Windows/Mazerunner_dev.exe" : "build/Windows/Mazerunner.exe", BuildTarget.StandaloneWindows64, dev);
}

static void Linux64(bool dev)
{
BuildStandalone(dev ? "build/linux/Mazerunner_dev" : "build/linux/Mazerunner", BuildTarget.StandaloneLinux64, dev);
}

static void WebGL(bool dev)
{
BuildStandalone("build/WebGL/Mazerunner" + (dev ? "_dev" : ""), BuildTarget.WebGL, dev);
Expand Down
10 changes: 9 additions & 1 deletion features/scripts/build_maze_runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ if [ -z "$UNITY_VERSION" ]; then
fi

if [[ $# != 2 ]]; then
echo "Build type (release/dev) and platform (macos/webgl/windows/wsl) must be passed as parameters"
echo "Build type (release/dev) and platform (macos/webgl/windows/wsl/linux) must be passed as parameters"
exit 2
fi

Expand Down Expand Up @@ -36,6 +36,14 @@ elif [ "$PLATFORM_TYPE" == "wsl" ]; then
fi
set -m
UNITY_PATH="/mnt/c/Program Files/Unity/Hub/Editor/$UNITY_VERSION/Editor/Unity.exe"
elif [ "$PLATFORM_TYPE" == "linux" ]; then
if [ "$BUILD_TYPE" == "release" ]; then
PLATFORM="Linux64Release"
else
PLATFORM="Linux64Dev"
fi
set -m
UNITY_PATH="$HOME/Unity/Hub/Editor/$UNITY_VERSION/Editor/Unity"
elif [ "$PLATFORM_TYPE" == "webgl" ]; then
if [ "$BUILD_TYPE" == "release" ]; then
PLATFORM="WebGLRelease"
Expand Down
13 changes: 13 additions & 0 deletions features/steps/unity_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ def execute_command(action, scenario_name = '')
Maze::Runner.run_command(command, blocking: false)
execute_command('clear_cache')

when 'linux'
log = File.join(Dir.pwd, 'mazerunner.log')
command = "#{Maze.config.app} --args -logfile #{log} > /dev/null"
Maze::Runner.run_command(command, blocking: false)
execute_command('clear_cache')

when 'android', 'ios'
execute_command('clear_cache')
when 'browser'
Expand Down Expand Up @@ -80,6 +86,13 @@ def execute_command(action, scenario_name = '')

execute_command('run_scenario', state)

when 'linux'
log = File.join(Dir.pwd, "#{state}-mazerunner.log")
command = "#{Maze.config.app} --args -logfile #{log} > /dev/null"
Maze::Runner.run_command(command, blocking: false)

execute_command('run_scenario', state)

when 'android', 'ios'
execute_command('run_scenario', state)

Expand Down
10 changes: 10 additions & 0 deletions features/support/env.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@
skip_this_scenario("Skipping scenario") if Maze.config.os == 'windows'
end

Before('@linux_only') do |_scenario|
skip_this_scenario('Skipping scenario') unless Maze.config.os == 'linux'
end
Before('@skip_linux') do |_scenario|
skip_this_scenario("Skipping scenario") if Maze.config.os == 'linux'
end


Before('@switch_only') do |_scenario|
skip_this_scenario('Skipping scenario') unless Maze.config.os == 'switch'
Expand All @@ -71,6 +78,7 @@
elsif Maze.config.os&.downcase == 'windows'
# Allow the necessary environment variables to be passed from Ubuntu (under WSL) to the Windows test fixture
ENV['WSLENV'] = 'BUGSNAG_SCENARIO:BUGSNAG_APIKEY:MAZE_ENDPOINT'
elsif Maze.config.os&.downcase == 'linux'
elsif Maze.config.browser != nil # WebGL

release_path = 'features/fixtures/maze_runner/build/WebGL/Mazerunner'
Expand Down Expand Up @@ -138,6 +146,8 @@
case Maze::Helper.get_current_platform
when 'macos'
`killall Mazerunner`
when 'linux'
`killall Mazerunner`
when 'webgl','windows'
execute_command('close_application')
when 'switch'
Expand Down
Loading

0 comments on commit fdc9006

Please sign in to comment.