Skip to content

Commit

Permalink
Merge pull request #111 from duchess-rs/test-other-os
Browse files Browse the repository at this point in the history
Run tests on macOS and Windows
  • Loading branch information
fpoli authored Oct 3, 2023
2 parents 5def1a4 + 3feeec3 commit 85c5bad
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 12 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,12 @@ env:

jobs:
build:

runs-on: ubuntu-latest
strategy:
matrix:
# windows-latest does not work because of https://github.com/oli-obk/ui_test/issues/147
os: [ubuntu-latest, macos-latest]
fail-fast: false
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v3
Expand All @@ -21,6 +25,7 @@ jobs:
distribution: 'corretto'
java-version: '17'
- name: Install mdBook
if: matrix.os == 'ubuntu-latest'
run: curl -sSL https://github.com/rust-lang/mdBook/releases/download/v0.4.28/mdbook-v0.4.28-x86_64-unknown-linux-gnu.tar.gz | tar -xz
- name: Build
run: cargo build --verbose
Expand All @@ -29,4 +34,5 @@ jobs:
- name: Test client crates
run: cargo test --all-targets --verbose --manifest-path=test-crates/Cargo.toml
- name: Test book
if: matrix.os == 'ubuntu-latest'
run: ./mdbook test book
2 changes: 1 addition & 1 deletion test-crates/duchess-java-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ duchess = { path = "../.." }
thiserror = "1.0.40"

[dev-dependencies]
ui_test = "0.10.0"
ui_test = "0.17.0"

[build_dependencies]
walkdir = "2.3"
Expand Down
33 changes: 24 additions & 9 deletions test-crates/duchess-java-tests/tests/ui.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use std::path::Path;
use ui_test::*;

fn main() -> color_eyre::eyre::Result<()> {
Expand All @@ -6,25 +7,34 @@ fn main() -> color_eyre::eyre::Result<()> {
// Tests can be blessed with `cargo test -- -- --bless`.
let bless = std::env::args().any(|arg| arg == "--bless");

let mut config = Config::default();
config.root_dir = "tests/ui".into();
let mut config = Config {
..Config::rustc(Path::new("tests").join("ui"))
};
let args = Args::test()?;

if bless {
config.output_conflict_handling = OutputConflictHandling::Bless;
}

// Place the build artifacts in the `target/ui` directory instead of in the
// Place the build artifacts in the `../target/ui` directory instead of in the
// crate root.
config.out_dir = Some("../target/ui".into());
config.out_dir = Path::new("..").join("target").join("ui");

// Make sure we can depend on duchess itself in our tests
config.dependencies_crate_manifest_path = Some("Cargo.toml".into());
config.dependencies_crate_manifest_path = Some(Path::new("Cargo.toml").into());

let test_name = std::env::var_os("TESTNAME");

let text = if args.quiet {
ui_test::status_emitter::Text::quiet()
} else {
ui_test::status_emitter::Text::verbose()
};

run_tests_generic(
config,
move |path| {
vec![config],
args,
move |path, _, _| {
test_name
.as_ref()
.and_then(|name| {
Expand All @@ -37,7 +47,12 @@ fn main() -> color_eyre::eyre::Result<()> {
.unwrap_or(true)
&& path.extension().map(|ext| ext == "rs").unwrap_or(false)
},
|_, _| None,
status_emitter::TextAndGha,
default_per_file_config,
(
text,
ui_test::status_emitter::Gha::<true> {
name: "ui tests".into(),
},
)
)
}

0 comments on commit 85c5bad

Please sign in to comment.