From 2c065a499cde66fc441ceaf71c3fe7ffbf203eb5 Mon Sep 17 00:00:00 2001 From: lifegpc Date: Sun, 20 Jul 2025 22:48:41 +0800 Subject: [PATCH] check features script now also run cargo test --- check_features.py | 23 +++++++++++++++++++---- src/format/fixed.rs | 33 ++++++++++++++++++--------------- 2 files changed, 37 insertions(+), 19 deletions(-) diff --git a/check_features.py b/check_features.py index c8be0fd..d7d6cf0 100644 --- a/check_features.py +++ b/check_features.py @@ -38,6 +38,7 @@ def main(): sys.exit(0) failed_features = [] + test_failed_features = [] print(f"Testing {len(feature_names)} features...") for idx, feature in enumerate(feature_names, 1): @@ -50,11 +51,25 @@ def main(): print(f"❌ Feature '{feature}' failed to compile") else: print(f"✅ Feature '{feature}' compiled successfully") + + cmd = ["cargo", "test", "--no-default-features", "--features", feature, '--target-dir', 'target/features_check'] + try: + subprocess.run(cmd, check=True) + except subprocess.CalledProcessError: + test_failed_features.append(feature) + print(f"❌ Tests for feature '{feature}' failed") + else: + print(f"✅ Tests for feature '{feature}' passed") - if failed_features: - print("\nFailed features:") - for f in failed_features: - print(f" - {f}") + if failed_features or test_failed_features: + if failed_features: + print("\nFailed features:") + for f in failed_features: + print(f" - {f}") + if test_failed_features: + print("\nFailed tests for features:") + for f in test_failed_features: + print(f" - {f}") sys.exit(1) else: print("\nAll features compiled successfully!") diff --git a/src/format/fixed.rs b/src/format/fixed.rs index e4eb9de..eb941aa 100644 --- a/src/format/fixed.rs +++ b/src/format/fixed.rs @@ -114,19 +114,22 @@ fn test_format() { fommater2.format("● Th\n is is a te st."), "● Th\nis is a te\nst." ); - let circus_formatter = FixedFormatter::new(10, false, Some(ScriptType::Circus)); - assert_eq!( - circus_formatter.format("● @cmd1@cmd2@cmd3中文字数是一\n 二三 四五六七八九十"), - "● @cmd1@cmd2@cmd3中文字数是一二三\n四五六七八九十" - ); - assert_eq!( - circus_formatter - .format("● @cmd1@cmd2@cmd3{rubyText/中文}字数是一\n 二三 四五六七八九十"), - "● @cmd1@cmd2@cmd3{rubyText/中文}字数是一二三\n四五六七八九十" - ); - let circus_formatter2 = FixedFormatter::new(32, false, Some(ScriptType::Circus)); - assert_eq!( - circus_formatter2.format("@re1@re2@b1@t30@w1「当然现在我很幸福哦?\n 因为有你在身边」@n\n「@b1@t38@w1当然现在我很幸福哦?\n 因为有敦也君在身边」"), - "@re1@re2@b1@t30@w1「当然现在我很幸福哦?因为有你在身边」@n\n「@b1@t38@w1当然现在我很幸福哦?因为有敦也君在身边」" - ); + #[cfg(feature = "circus")] + { + let circus_formatter = FixedFormatter::new(10, false, Some(ScriptType::Circus)); + assert_eq!( + circus_formatter.format("● @cmd1@cmd2@cmd3中文字数是一\n 二三 四五六七八九十"), + "● @cmd1@cmd2@cmd3中文字数是一二三\n四五六七八九十" + ); + assert_eq!( + circus_formatter + .format("● @cmd1@cmd2@cmd3{rubyText/中文}字数是一\n 二三 四五六七八九十"), + "● @cmd1@cmd2@cmd3{rubyText/中文}字数是一二三\n四五六七八九十" + ); + let circus_formatter2 = FixedFormatter::new(32, false, Some(ScriptType::Circus)); + assert_eq!( + circus_formatter2.format("@re1@re2@b1@t30@w1「当然现在我很幸福哦?\n 因为有你在身边」@n\n「@b1@t38@w1当然现在我很幸福哦?\n 因为有敦也君在身边」"), + "@re1@re2@b1@t30@w1「当然现在我很幸福哦?因为有你在身边」@n\n「@b1@t38@w1当然现在我很幸福哦?因为有敦也君在身边」" + ); + } }