-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Port Project Keter's test runner to this project #3
Open
notgull
wants to merge
23
commits into
rust-windowing:main
Choose a base branch
from
forkgull:test-runner
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
7913179
chore: Set up keter-test
notgull 45e7bab
feat(test): Add test harness
notgull e883d78
chore: Use keter-test in keter-reactor
notgull dd43095
feat(test): Asyncify the Reporter trait
notgull 263493c
feat(test): Add TCP test harness backend
notgull e98ce17
chore: Beginnings of test runner crate
notgull 01ece7f
feat(test-runner): Add clippy support
notgull 8444c3a
feat(test-runner): Different host environments
notgull dba508f
chore: Put a bow on functionality testing
notgull b60d170
chore: Fix minor warts
notgull 9863aa0
m(test-runner): Cache test environments
notgull 739e8a1
feat(test): Add Unix socket test harness
notgull 14792a5
chore: Rearrange project so xbuild works
notgull 15e682e
feat(test-runner): Android environment setup
notgull 920be7f
feat(test-runner): Setup Docker test harness
notgull 7347f7f
chore(test-runner): Test runner fixes
notgull 1cc6d8b
chore: Setup android runner and keter tests
notgull edc3006
feat(test-runner): Pwd arg for HostEnvironment
notgull f6fa977
feat(test-runner): Add pwd option to Command
notgull 74aebc4
bugfix(test-harness): Fix Android harness
notgull ac3208d
chore(test-runner): Fix some warnings
notgull e1a0643
bugfix(test-runner): Tests now appear in docker
notgull 2221c78
chore(test): keter -> winit
notgull File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
/target | ||
Cargo.lock | ||
/Cargo.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/bin/sh | ||
|
||
set -eu | ||
|
||
rx() { | ||
echo >&2 "+ $*" | ||
"$@" | ||
} | ||
build_dockerfile() { | ||
tag="$1" | ||
name="$2" | ||
|
||
rx docker build . -f dockerfiles/"$name" \ | ||
-t ghcr.io/notgull/winit_test:"$tag" | ||
} | ||
|
||
build_dockerfile ubuntu Dockerfile.ubuntu |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#!/bin/sh | ||
# MIT/Apache2 License | ||
|
||
set -eu | ||
|
||
rx() { | ||
echo >&2 "+ $*" | ||
"$@" | ||
} | ||
no_out() { | ||
cmd_noout="$1" | ||
shift | ||
"$cmd_noout" "$@" > /dev/null 2> /dev/null | ||
} | ||
bail() { | ||
echo "[fatal] $*" | ||
exit 1 | ||
} | ||
info() { | ||
echo "[info] $*" | ||
} | ||
bail_if_absent() { | ||
if ! no_out command -v "$1"; then | ||
bail "could not find $1" | ||
fi | ||
} | ||
test_runner() { | ||
bail_if_absent "${CARGO:-cargo}" | ||
rx "${CARGO:-cargo}" run --release -p winit-test-runner -- "$@" | ||
} | ||
|
||
basedir="$(dirname -- "$(dirname -- "$0")")" | ||
cd "$basedir" || exit 1 | ||
|
||
config_path="${1:-basedir/ci/tests_linux.json}" | ||
|
||
# Tell which level of test we're running. | ||
case "${2:-2}" in | ||
0) info "running level 0 (style) tests"; level=0 ;; | ||
1) info "running level 1 (function) tests"; level=1 ;; | ||
2) info "running level 2 (full) tests"; level=2 ;; | ||
*) bail "unknown test level $1" ;; | ||
esac | ||
|
||
# Always run style tests. | ||
#test_runner style --config "$config_path" | ||
|
||
# At level 1 or higher, run functionality tests. | ||
#if [ "$level" -ge 1 ]; then | ||
# test_runner functionality --config "$config_path" | ||
#fi | ||
|
||
# At level 2 or higher, run full tests. | ||
if [ "$level" -ge 2 ]; then | ||
test_runner full --config "$config_path" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[ | ||
{ | ||
"name": "winit-core", | ||
"checks": [ | ||
{ | ||
"target": "x86_64-linux-android" | ||
} | ||
] | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[ | ||
{ | ||
"name": "winit-core", | ||
"checks": [ | ||
{ | ||
"target": "x86_64-unknown-linux-gnu" | ||
} | ||
] | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Ubuntu testing container | ||
# Usually tagged as ghcr.io/notgull/winit:ubuntu | ||
|
||
FROM rust as final | ||
ARG DEBIAN_FRONTEND=noninteractive | ||
|
||
RUN \ | ||
apt-get -o Acquire::Retries=10 -qq update && \ | ||
apt-get -o Acquire::Retries=10 -o Dpkg::Use-Pty=0 install -y --no-install-recommends \ | ||
xvfb \ | ||
libx11-dev \ | ||
libxcb1-dev \ | ||
libxkbcommon-dev && \ | ||
rm -rf \ | ||
/var/lib/apt/lists/* \ | ||
/var/cache/* \ | ||
/var/log/* \ | ||
/usr/share/{doc,man} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// MIT/Apache2 License | ||
|
||
use futures_lite::future::block_on; | ||
|
||
#[allow(clippy::eq_op)] | ||
fn main() { | ||
winit_test::run_tests(|harness| { | ||
block_on(async move { | ||
harness.test("hello world", async { | ||
assert_eq!(1 + 1, 2) | ||
}).await; | ||
}); | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
[package] | ||
name = "winit-test-runner" | ||
version = "0.1.0" | ||
edition = "2021" | ||
authors = ["John Nunley <[email protected]>"] | ||
publish = false | ||
|
||
[dependencies] | ||
async-channel = "2.1.1" | ||
async-executor = "1.8.0" | ||
async-fs = "2.1.0" | ||
async-io = "2.2.2" | ||
async-lock = "3.2.0" | ||
async-process = "2.0.1" | ||
blocking = "1.5.1" | ||
clap = "4.4.11" | ||
color-eyre = "0.6.2" | ||
eyre = "0.6.11" | ||
futures-lite = "2.1.0" | ||
human-panic = "1.2.2" | ||
ignore = "0.4.21" | ||
winit-test.workspace = true | ||
once_cell = "1.19.0" | ||
owo-colors = "4.0.0" | ||
pin-project-lite = "0.2.13" | ||
regex = "1.10.2" | ||
serde = { version = "1.0.193", features = ["derive"] } | ||
serde_json = "1.0.108" | ||
tracing = { version = "0.1.40", default-features = false, features = ["async-await"] } | ||
tracing-subscriber = "0.3.18" | ||
which = "5.0.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# winit-test-runner | ||
|
||
Test runner for `winit`. | ||
|
||
This binary acts as orchestration for running tests in `winit`. In addition to | ||
what is often used in normal Rust tests (formatting, Clippy, unit tests), it also | ||
runs those tests in cross-compilation environments on other platforms. | ||
|
||
There are different types of tests: | ||
|
||
- **Style tests** make sure that code is formatted and linted properly. | ||
`cargo fmt` and `cargo clippy` are used to inspect Rust code. | ||
- **Functionality tests** run the doctests and unit tests in Rust code. These | ||
often ensure that basic functionality and logic are in working order. | ||
- **Host tests** run the `winit` test suite on the current host. This test suite | ||
fully tests the functionality of `winit` to ensure that it is working properly. | ||
A full CI run with `winit` should be fully bug-free. | ||
- **Cross tests** run the `winit` test suite in Docker containers/virtual | ||
machines in order to ensure `winit` works on all possible hosts. | ||
|
||
## License | ||
|
||
MIT/Apache2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// MIT/Apache2 License | ||
|
||
mod runner; | ||
pub use runner::*; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
// MIT/Apache2 License | ||
|
||
mod runner; | ||
|
||
use std::path::Path; | ||
use std::process::exit; | ||
|
||
use color_eyre::{eyre::bail, Result}; | ||
use owo_colors::OwoColorize; | ||
|
||
fn main() { | ||
// Setup error hooks. | ||
tracing_subscriber::fmt::try_init().ok(); | ||
color_eyre::install().ok(); | ||
|
||
// Get CLI matches. | ||
let matches = cli().get_matches(); | ||
|
||
// Run the main function. | ||
if let Err(e) = async_io::block_on(entry(matches)) { | ||
println!("{}{:?}", "encountered a fatal error: ".red().bold(), e); | ||
exit(1); | ||
} | ||
} | ||
|
||
async fn entry(matches: clap::ArgMatches) -> Result<()> { | ||
match matches.subcommand() { | ||
None => bail!("expected a subcommand"), | ||
Some(("style", matches)) => { | ||
let crates = read_config(matches.get_one::<String>("config").unwrap()).await?; | ||
runner::Test::Style.run(crates).await?; | ||
} | ||
Some(("functionality", matches)) => { | ||
let crates = read_config(matches.get_one::<String>("config").unwrap()).await?; | ||
runner::Test::Functionality.run(crates).await?; | ||
} | ||
Some(("full", matches)) => { | ||
let crates = read_config(matches.get_one::<String>("config").unwrap()).await?; | ||
runner::Test::Host.run(crates).await?; | ||
} | ||
Some((subcommand, _matches)) => bail!("unknown subcommand {subcommand}"), | ||
} | ||
|
||
Ok(()) | ||
} | ||
|
||
async fn read_config(path: impl AsRef<Path>) -> Result<Vec<runner::Crate>> { | ||
let data = async_fs::read(path).await?; | ||
let crates = serde_json::from_slice(&data)?; | ||
Ok(crates) | ||
} | ||
|
||
fn cli() -> clap::Command { | ||
clap::Command::new("winit-test-runner") | ||
.subcommand( | ||
clap::Command::new("style").arg( | ||
clap::Arg::new("config") | ||
.required(true) | ||
.short('c') | ||
.long("config"), | ||
), | ||
) | ||
.subcommand( | ||
clap::Command::new("functionality").arg( | ||
clap::Arg::new("config") | ||
.required(true) | ||
.short('c') | ||
.long("config"), | ||
), | ||
) | ||
.subcommand( | ||
clap::Command::new("full").arg( | ||
clap::Arg::new("config") | ||
.required(true) | ||
.short('c') | ||
.long("config"), | ||
), | ||
) | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really need any tests here? This doesn't have any core logic stuff it should all go into the
winit
crate instead.