rustc/debian/tests/create-and-build-crate
liushuyu 31b21ffe0e d/tests: add a new smoke test for Cargo ...
... the test has been adapted by Zixing to include some new CLI
functions introduced in newer version of Cargo (like `cargo add`)

Co-Authored-By: Nick Rosbrook <nick.rosbrook@canonical.com>
2024-05-02 17:57:42 +02:00

40 lines
494 B
Bash
Executable File

#!/bin/bash
set -euo pipefail
tmpdir=$(mktemp -d)
cd "$tmpdir"
cargo new hello
cd hello
cat <<EOF > src/main.rs
use anyhow::Result;
fn main() -> Result<()> {
println!("Hello, World!");
Ok(())
}
#[test]
fn test() {
assert_eq!(1 + 1, 2);
}
EOF
cargo add 'anyhow@^1'
cargo vendor
mkdir -p .cargo
cat <<EOF > .cargo/config.toml
[source.crates-io]
replace-with = "vendored-sources"
[source.vendored-sources]
directory = "vendor"
EOF
cargo check
cargo build
cargo test
cargo run