bacon
bacon copied to clipboard
Failing to render colored space characters
Result with cargo test:
This is the correct output.
The debug-printed string there is "\n\u{1b}[48;2;0;127;0m \u{1b}[49m\n\u{1b}[48;2;0;127;0m \u{1b}[49m\n"
Result with bacon test:
Note that the green rectangle is missing.
Code:
fn main() {
println!("Hello World!");
}
#[cfg(test)]
pub mod test {
#[test]
fn test_a() {
let set_bg = "\u{1b}[48;2;0;127;0m";
let reset_bg = "\u{1b}[49m";
let spaces = " ".repeat(20);
let the_string = format!(
"
{set_bg}{spaces}{reset_bg}
{set_bg}{spaces}{reset_bg}
"
);
dbg!(&the_string);
println!("{}", the_string);
panic!();
}
}
Cargo.toml:
[package]
name = "hello-world"
version = "0.1.0"
edition = "2021"
versions:
bash-5.2$ cargo --version
cargo 1.88.0 (873a06493 2025-05-10)
bash-5.2$ bacon --version
bacon 3.16.0
bash-5.2$ rustc --version
rustc 1.88.0 (6b00bc388 2025-06-23) (built from a source tarball)
flake.nix:
{
description = "rust workspace";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let pkgs = import nixpkgs { inherit system; };
in {
devShells.default = pkgs.mkShell {
buildInputs = with pkgs; [
cargo
rustc
bacon
];
};
});
}
flake.lock file:
{
"nodes": {
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1731533236,
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1753432016,
"narHash": "sha256-cnL5WWn/xkZoyH/03NNUS7QgW5vI7D1i74g48qplCvg=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "6027c30c8e9810896b92429f0092f624f7b1aace",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
}
},
"root": "root",
"version": 7
}