other: add another test to validate default config (#1553)

* update changelog

* add another lib test to make sure valid integration configs are actually valid

* only test these on default config

* clippy

* add extra CI fail check

* fix windows
This commit is contained in:
Clement Tsang 2024-08-08 08:44:48 +00:00 committed by GitHub
parent cf47cb9fae
commit 96ed26d87a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 42 additions and 9 deletions

View File

@ -267,16 +267,16 @@ jobs:
completion:
name: "CI Pass Check"
needs: [supported, other-check]
if: ${{ success() || failure() }}
if: ${{ always() }}
runs-on: "ubuntu-latest"
steps:
- name: CI Passed
if: ${{ (needs.supported.result == 'success' && needs.other-check.result == 'success') || (needs.supported.result == 'skipped' && needs.other-check.result == 'skipped') }}
run: |
echo "CI workflow completed successfully.";
echo "CI workflow completed successfully or was skipped.";
- name: CI Failed
if: ${{ needs.supported.result == 'failure' && needs.other-check.result == 'failure' }}
if: ${{ needs.supported.result == 'failure' && needs.other-check.result == 'failure' || (needs.supported.result == 'cancelled' && needs.other-check.result == 'cancelled') }}
run: |
echo "CI workflow failed at some point.";
echo "CI workflow failed or was cancelled at some point.";
exit 1;

View File

@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [0.11.0]/[0.10.3] - Unreleased
### Bug Fixes
- [#1551](https://github.com/ClementTsang/bottom/pull/1551): Fix missing parent section names in default config.
- [#1552](https://github.com/ClementTsang/bottom/pull/1552): Fix typo in default config.
## [0.10.2] - 2024-08-05
### Features

View File

@ -486,10 +486,6 @@ pub const CONFIG_TOP_HEAD: &str = r##"# This is bottom's config file.
#[cfg(test)]
mod test {
use regex::Regex;
use crate::options::Config;
use super::*;
#[test]
@ -524,7 +520,12 @@ mod test {
/// Checks that the default config is valid.
#[test]
#[cfg(feature = "default")]
fn check_default_config() {
use regex::Regex;
use crate::options::Config;
let default_config = Regex::new(r"(?m)^#([a-zA-Z\[])")
.unwrap()
.replace_all(CONFIG_TEXT, "$1");

View File

@ -56,3 +56,28 @@ impl From<u64> for StringOrNum {
StringOrNum::Num(value)
}
}
#[cfg(test)]
mod test {
// Test all valid configs in the integration test folder and ensure they are accepted.
// We need this separated as only test library code sets `serde(deny_unknown_fields)`.
#[test]
#[cfg(feature = "default")]
fn test_integration_valid_configs() {
use super::Config;
use std::fs;
for config_path in fs::read_dir("./tests/valid_configs").unwrap() {
let config_path = config_path.unwrap();
let config_path_str = config_path.path().display().to_string();
let config_str = fs::read_to_string(config_path.path()).unwrap();
toml_edit::de::from_str::<Config>(&config_str)
.unwrap_or_else(|_| panic!("incorrectly rejected '{config_path_str}'"));
}
}
// I didn't do an invalid config test as a lot of them _are_ valid Config when parsed,
// but fail other checks.
}

View File

@ -13,7 +13,7 @@ pub(crate) struct MemoryStyle {
pub(crate) ram_color: Option<ColorStr>,
/// The colour of the cache label and graph line. Does not do anything on Windows.
#[cfg(not(target_os = "windows"))]
#[cfg_attr(target_os = "windows", allow(dead_code))]
#[serde(alias = "cache_colour")]
pub(crate) cache_color: Option<ColorStr>,