summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2022-04-02 10:33:19 +0800
committerruki <[email protected]>2022-04-02 10:33:19 +0800
commit3261ecb32c7c5c0c4c71e5b78a03b0cd203652f1 (patch)
treeb4c4f25787d4cb9c8c1c98897cb9c299eca84b31
parent8b687b4bff48f28bcd991408b0ca0fece7605515 (diff)
add cargo tests
-rw-r--r--tests/projects/rust/cargo_deps_with_toml/Cargo.toml9
-rw-r--r--tests/projects/rust/cargo_deps_with_toml/src/main.rs12
-rw-r--r--tests/projects/rust/cargo_deps_with_toml/xmake.lua7
3 files changed, 28 insertions, 0 deletions
diff --git a/tests/projects/rust/cargo_deps_with_toml/Cargo.toml b/tests/projects/rust/cargo_deps_with_toml/Cargo.toml
new file mode 100644
index 000000000..81919c567
--- /dev/null
+++ b/tests/projects/rust/cargo_deps_with_toml/Cargo.toml
@@ -0,0 +1,9 @@
+[package]
+name = "test"
+version = "0.1.0"
+edition = "2021"
+
+[dependencies]
+base64 = "0.13.0"
+flate2 = {version = "1.0.17", features = ["zlib"]}
+
diff --git a/tests/projects/rust/cargo_deps_with_toml/src/main.rs b/tests/projects/rust/cargo_deps_with_toml/src/main.rs
new file mode 100644
index 000000000..f1ec987bf
--- /dev/null
+++ b/tests/projects/rust/cargo_deps_with_toml/src/main.rs
@@ -0,0 +1,12 @@
+extern crate base64;
+
+use base64::{encode, decode};
+
+fn main() {
+ let a = b"hello world";
+ let b = "aGVsbG8gd29ybGQ=";
+
+ assert_eq!(encode(a), b);
+ assert_eq!(a, &decode(b).unwrap()[..]);
+ println!("{}", encode(a));
+}
diff --git a/tests/projects/rust/cargo_deps_with_toml/xmake.lua b/tests/projects/rust/cargo_deps_with_toml/xmake.lua
new file mode 100644
index 000000000..c2837b813
--- /dev/null
+++ b/tests/projects/rust/cargo_deps_with_toml/xmake.lua
@@ -0,0 +1,7 @@
+add_rules("mode.release", "mode.debug")
+add_requires("cargo::test", {configs = {tomlfile = path.join(os.projectdir(), "Cargo.toml")}})
+
+target("test")
+ set_kind("binary")
+ add_files("src/main.rs")
+ add_packages("cargo::test")