Skip to content

Commit

Permalink
Run datetime GIGO test in CI (#4544)
Browse files Browse the repository at this point in the history
  • Loading branch information
sffc authored Jan 24, 2024
1 parent 9cd26e3 commit 27322e0
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 24 deletions.
64 changes: 51 additions & 13 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ jobs:
- name: Check
run: cargo make ci-job-msrv-${{ matrix.behavior }}


# ci-job-test
test:
strategy:
Expand Down Expand Up @@ -120,7 +121,6 @@ jobs:
if: steps.cargo-make-cache.outputs.cache-hit != 'true'
run: cargo +stable install cargo-make


# Toolchain boilerplate
- name: Potentially override rust version with nightly
run: cargo make set-nightly-version-for-ci
Expand All @@ -131,6 +131,7 @@ jobs:
- name: Run `cargo make ci-job-test`
run: cargo make ci-job-test


# ci-job-test-docs
test-docs:
runs-on: ubuntu-latest
Expand All @@ -155,7 +156,6 @@ jobs:
if: steps.cargo-make-cache.outputs.cache-hit != 'true'
run: cargo +stable install cargo-make


# Toolchain boilerplate
- name: Potentially override rust version with nightly
run: cargo make set-nightly-version-for-ci
Expand All @@ -166,6 +166,42 @@ jobs:
- name: Run `cargo make ci-job-test-docs`
run: cargo make ci-job-test-docs


# ci-job-test-gigo
test-gigo:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

# Cargo-make boilerplate
- name: Get cargo-make version
id: cargo-make-version
run: |
echo "hash=$(cargo search cargo-make | grep '^cargo-make =' | md5sum)" >> $GITHUB_OUTPUT
shell: bash
- name: Attempt to load cached cargo-make
uses: actions/cache@v3
id: cargo-make-cache
with:
path: |
~/.cargo/bin/cargo-make
~/.cargo/bin/cargo-make.exe
key: ${{ runner.os }}-make-${{ steps.cargo-make-version.outputs.hash }}
- name: Install cargo-make
if: steps.cargo-make-cache.outputs.cache-hit != 'true'
run: cargo +stable install cargo-make

# Toolchain boilerplate
- name: Potentially override rust version with nightly
run: cargo make set-nightly-version-for-ci
- name: Show the selected Rust toolchain
run: rustup show

# Actual job
- name: Run `cargo make ci-job-test-gigo`
run: cargo make ci-job-test-gigo


# ci-job-test-tutorials
test-tutorials:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -194,7 +230,6 @@ jobs:
if: steps.cargo-make-cache.outputs.cache-hit != 'true'
run: cargo +stable install cargo-make


# Toolchain boilerplate
- name: Potentially override rust version with nightly
run: cargo make set-nightly-version-for-ci
Expand All @@ -212,6 +247,7 @@ jobs:
- name: Run `cargo make ci-job-test-tutorials-${{ matrix.behavior }}`
run: cargo make ci-job-test-tutorials-${{ matrix.behavior }}


# ci-job-testdata
testdata:
strategy:
Expand Down Expand Up @@ -257,6 +293,7 @@ jobs:
- name: Run `cargo make ci-job-testdata`
run: cargo make ci-job-testdata


# ci-job-testdata-legacy
testdata-legacy:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -317,6 +354,7 @@ jobs:
- name: Run `cargo make ci-job-testdata-legacy`
run: cargo make ci-job-testdata-legacy


# ci-job-full-datagen
full-datagen:
runs-on: ubuntu-latest
Expand All @@ -341,7 +379,6 @@ jobs:
if: steps.cargo-make-cache.outputs.cache-hit != 'true'
run: cargo +stable install cargo-make


# Toolchain boilerplate
- name: Potentially override rust version with nightly
run: cargo make set-nightly-version-for-ci
Expand All @@ -361,6 +398,7 @@ jobs:
- name: Run `cargo make ci-job-full-datagen`
run: cargo make ci-job-full-datagen


# ci-job-test-c
test-c:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -394,7 +432,6 @@ jobs:
if: steps.cargo-make-cache.outputs.cache-hit != 'true'
run: cargo +stable install cargo-make


# Toolchain boilerplate
- name: Potentially override rust version with nightly
run: cargo make set-nightly-version-for-ci
Expand Down Expand Up @@ -426,6 +463,7 @@ jobs:
env:
CXX: "g++-11"


# ci-job-test-js
test-js:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -459,7 +497,6 @@ jobs:
if: steps.cargo-make-cache.outputs.cache-hit != 'true'
run: cargo +stable install cargo-make


# Toolchain boilerplate
- name: Potentially override rust version with nightly
run: cargo make set-nightly-version-for-ci
Expand Down Expand Up @@ -487,6 +524,7 @@ jobs:
- name: Run `cargo make ci-job-test-js`
run: cargo make ci-job-test-js


# ci-job-test-dart
test-dart:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -518,7 +556,6 @@ jobs:
if: steps.cargo-make-cache.outputs.cache-hit != 'true'
run: cargo +stable install cargo-make


# Toolchain boilerplate
- name: Potentially override rust version with nightly
run: cargo make set-nightly-version-for-ci
Expand All @@ -534,6 +571,7 @@ jobs:
- name: Run `cargo make ci-job-test-dart`
run: cargo make ci-job-test-dart


# ci-job-nostd
nostd:
runs-on: ubuntu-latest
Expand All @@ -558,7 +596,6 @@ jobs:
if: steps.cargo-make-cache.outputs.cache-hit != 'true'
run: cargo +stable install cargo-make


# Toolchain boilerplate
- name: Potentially override rust version with nightly
run: cargo make set-nightly-version-for-ci
Expand All @@ -569,6 +606,7 @@ jobs:
- name: Run `cargo make ci-job-nostd`
run: cargo make ci-job-nostd


# ci-job-diplomat
diplomat:
runs-on: [ ubuntu-latest ]
Expand All @@ -593,7 +631,6 @@ jobs:
if: steps.cargo-make-cache.outputs.cache-hit != 'true'
run: cargo +stable install cargo-make


# Toolchain boilerplate
- name: Potentially override rust version with nightly
run: cargo make set-nightly-version-for-ci
Expand All @@ -604,6 +641,7 @@ jobs:
- name: Run `cargo make ci-job-diplomat`
run: cargo make ci-job-diplomat


# ci-job-gn
gn:
runs-on: ubuntu-latest
Expand All @@ -629,7 +667,6 @@ jobs:
if: steps.cargo-make-cache.outputs.cache-hit != 'true'
run: cargo +stable install cargo-make


# Toolchain boilerplate
- name: Potentially override rust version with nightly
run: cargo make set-nightly-version-for-ci
Expand Down Expand Up @@ -672,6 +709,7 @@ jobs:
- name: Run `cargo make ci-job-gn`
run: cargo make ci-job-gn


# ci-job-fmt
fmt:
runs-on: ubuntu-latest
Expand All @@ -696,7 +734,6 @@ jobs:
if: steps.cargo-make-cache.outputs.cache-hit != 'true'
run: cargo +stable install cargo-make


# Toolchain boilerplate
- name: Potentially override rust version with nightly
run: cargo make set-nightly-version-for-ci
Expand All @@ -711,6 +748,7 @@ jobs:
- name: Check Format
run: cargo make ci-job-fmt


# ci-job-tidy
tidy:
runs-on: ubuntu-latest
Expand All @@ -735,7 +773,6 @@ jobs:
if: steps.cargo-make-cache.outputs.cache-hit != 'true'
run: cargo +stable install cargo-make


# Toolchain boilerplate
- name: Potentially override rust version with nightly
run: cargo make set-nightly-version-for-ci
Expand Down Expand Up @@ -767,6 +804,7 @@ jobs:
- name: Tidy
run: cargo make ci-job-tidy


# ci-job-clippy
clippy:
# We don't expect to be clippy-clean on nightly cronjob.
Expand Down Expand Up @@ -808,6 +846,7 @@ jobs:
- name: Run `ci-job-clippy`
run: cargo make ci-job-clippy


# ci-job-doc
doc:
runs-on: ubuntu-latest
Expand All @@ -833,7 +872,6 @@ jobs:
if: steps.cargo-make-cache.outputs.cache-hit != 'true'
run: cargo +stable install cargo-make


# Toolchain boilerplate
- name: Potentially override rust version with nightly
run: cargo make set-nightly-version-for-ci
Expand Down
6 changes: 6 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,12 @@ opt-level = "s"
panic = "abort"
codegen-units = 1

# Builds with debug metadata but not debug assertions
# for testing GIGO code paths
[profile.debug-without-assertions]
inherits = "dev"
debug-assertions = false

# Enable debug information specifically for memory profiling.
# https://docs.rs/dhat/0.2.1/dhat/#configuration
#
Expand Down
7 changes: 7 additions & 0 deletions Makefile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,13 @@ dependencies = [
"test-all-features",
]

[tasks.ci-job-test-gigo]
description = "Run specific tests with debug assertions disabled"
category = "CI"
dependencies = [
"test-debug-without-assertions",
]

[tasks.ci-job-test-tutorials-local]
description = "Run all checks for the CI 'test-tutorials' job"
category = "CI"
Expand Down
18 changes: 9 additions & 9 deletions components/datetime/tests/datetime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ use patterns::{
};
use std::str::FromStr;
use tinystr::tinystr;
use writeable::{assert_writeable_eq, Writeable};
use writeable::assert_writeable_eq;

mod mock;

Expand Down Expand Up @@ -565,20 +565,20 @@ fn test_time_zone_format_gmt_offset_not_set_debug_assert_panic() {
zone_variant: Some(ZoneVariant::daylight()),
};
let tzf = TimeZoneFormatter::try_new(&langid!("en").into(), Default::default()).unwrap();
tzf.format(&time_zone).write_to_string();
tzf.format_to_string(&time_zone);
}

#[test]
#[cfg(not(debug_assertions))]
fn test_time_zone_format_gmt_offset_not_set_no_debug_assert() {
let time_zone = MockTimeZone::new(
None,
Some(TimeZoneBcp47Id(tinystr!(8, "uslax"))),
Some(MetazoneId(tinystr!(4, "ampa"))),
Some(tinystr!(8, "daylight")),
);
let time_zone = CustomTimeZone {
gmt_offset: None,
time_zone_id: Some(TimeZoneBcp47Id(tinystr!(8, "uslax"))),
metazone_id: Some(MetazoneId(tinystr!(4, "ampa"))),
zone_variant: Some(ZoneVariant::daylight()),
};
let tzf = TimeZoneFormatter::try_new(&langid!("en").into(), Default::default()).unwrap();
assert_writeable_eq!(tzf.format(&time_zone).unwrap(), "GMT+?");
assert_writeable_eq!(tzf.format(&time_zone), "GMT+?");
}

#[test]
Expand Down
4 changes: 2 additions & 2 deletions provider/core/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,9 @@ impl DataError {
/// This does not modify the error, but if the "logging" Cargo feature is enabled,
/// it will print out the context.
#[cfg(feature = "std")]
pub fn with_path_context<P: AsRef<std::path::Path> + ?Sized>(self, path: &P) -> Self {
pub fn with_path_context<P: AsRef<std::path::Path> + ?Sized>(self, _path: &P) -> Self {
if !self.silent {
log::warn!("{} (path: {:?})", self, path.as_ref());
log::warn!("{} (path: {:?})", self, _path.as_ref());
}
self
}
Expand Down
6 changes: 6 additions & 0 deletions tools/make/tests.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ env = { RUSTFLAGS = "--cfg=icu4x_run_size_tests" }
command = "cargo"
args = ["test", "--all-features", "--all-targets", "--no-fail-fast"]

[tasks.test-debug-without-assertions]
description = "Run all Rust unit and integration tests without debug assertions (GIGO mode)"
category = "ICU4X Development"
command = "cargo"
args = ["test", "--profile=debug-without-assertions", "--all-features", "--tests", "--no-fail-fast"]

[tasks.test-docs]
description = "Run all Rust doctests with all features"
category = "ICU4X Development"
Expand Down

0 comments on commit 27322e0

Please sign in to comment.