summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2024-05-01 19:40:14 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2024-05-01 19:40:14 +0000
commitff87d5812db06995927aac8632ce1ad26ecd6d7a (patch)
tree3f463815d531fc31bea74072a7d6aa489b3adcda
parent5e6f103c616029220267ff7523aad38344a88411 (diff)
parent975e23097d141aedbf8da4da6b4bcb60c19d9f67 (diff)
downloadn2-ff87d5812db06995927aac8632ce1ad26ecd6d7a.tar.gz
Snap for 11788943 from 975e23097d141aedbf8da4da6b4bcb60c19d9f67 to build-tools-release
Change-Id: Ia74ef141f295ccd42f568ffd6575144c0c8a1154
-rw-r--r--.github/workflows/ci.yml2
-rw-r--r--Android.bp32
-rw-r--r--Cargo.toml2
-rw-r--r--tests/e2e/mod.rs21
4 files changed, 45 insertions, 12 deletions
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 654296c..e95c1ef 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -20,7 +20,7 @@ jobs:
steps:
- uses: actions/checkout@v2
- - uses: dtolnay/rust-toolchain@1.70.0
+ - uses: dtolnay/rust-toolchain@1.75.0
with:
components: rustfmt
- name: Check formatting
diff --git a/Android.bp b/Android.bp
index a1b1b4b..bf1534d 100644
--- a/Android.bp
+++ b/Android.bp
@@ -1,5 +1,6 @@
-
-// TODO: Add a module for the tests. The tests require libfiletime, which is not in android.
+package {
+ default_visibility: ["//visibility:private"],
+}
rust_library_host {
name: "libn2",
@@ -31,3 +32,30 @@ rust_binary_host {
"librustc_hash",
],
}
+
+rust_test_host {
+ name: "n2_unit_tests",
+ srcs: ["src/lib.rs"],
+ edition: "2018",
+ cargo_env_compat: true,
+ // n2 prints the value of CARGO_PKG_VERSION when using the --version argument, we need to set
+ // this property to define the environment variable, but don't actually care about the value.
+ cargo_pkg_version: "android",
+ rustlibs: [
+ "libtempfile",
+ "libanyhow",
+ "libargh",
+ "liblibc",
+ "librustc_hash",
+ ],
+}
+
+rust_test_host {
+ name: "n2_e2e_tests",
+ srcs: ["tests/e2e_test.rs"],
+ edition: "2018",
+ rustlibs: [
+ "libtempfile",
+ "libanyhow",
+ ],
+}
diff --git a/Cargo.toml b/Cargo.toml
index b91b120..8f10b28 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -11,7 +11,7 @@ readme = "README.md"
repository = "https://github.com/evmar/n2"
# https://github.com/evmar/n2/issues/74
# Note: if we bump this, may need to bump .github/workflows/ci.yml version too.
-rust-version = "1.70.0"
+rust-version = "1.75.0"
description = "a ninja compatible build system"
[dependencies]
diff --git a/tests/e2e/mod.rs b/tests/e2e/mod.rs
index a1e7e7f..c788d0c 100644
--- a/tests/e2e/mod.rs
+++ b/tests/e2e/mod.rs
@@ -10,13 +10,17 @@ mod validations;
use anyhow::anyhow;
pub fn n2_binary() -> std::path::PathBuf {
- std::env::current_exe()
- .expect("test binary path")
- .parent()
- .expect("test binary directory")
- .parent()
- .expect("binary directory")
- .join("n2")
+ if let Ok(n2_path) = std::env::var("N2_PATH") {
+ std::path::PathBuf::from(n2_path).canonicalize().expect("could not canonicalize")
+ } else {
+ std::env::current_exe()
+ .expect("test binary path")
+ .parent()
+ .expect("test binary directory")
+ .parent()
+ .expect("binary directory")
+ .join("n2")
+ }
}
pub fn n2_command(args: Vec<&str>) -> std::process::Command {
@@ -80,7 +84,8 @@ impl TestSpace {
pub fn sub_mtime(&self, path: &str, dur: std::time::Duration) -> anyhow::Result<()> {
let path = self.dir.path().join(path);
let t = std::time::SystemTime::now() - dur;
- filetime::set_file_mtime(path, filetime::FileTime::from_system_time(t))?;
+ let f = std::fs::File::options().write(true).open(path)?;
+ f.set_modified(t)?;
Ok(())
}