History

run git-odb tests in parallel, too; improved threaded error handling

Sebastian Thiel committed 5 years ago

Commit 40802fd1 parent 2a2fdde5 files · +37 −19Browse files

Unified · Split

5 files
  1. Makefile +1 −0
  2. git-features/src/parallel/mod.rs +1 −1
  3. git-odb/Cargo.toml +11 −0
  4. git-odb/src/pack/data/encode.rs +2 −0
  5. git-odb/tests/pack/data/encode.rs +22 −18
Makefile+1−0
@@ -102,6 +102,7 @@ check: ## Build all code in suitable configurations · 101 unmodified lines
102unit-tests: ## run all unit tests102unit-tests: ## run all unit tests
103 cargo test --all --no-fail-fast103 cargo test --all --no-fail-fast
104 cd git-features && cargo test && cargo test --all-features104 cd git-features && cargo test && cargo test --all-features
105 cd git-odb && cargo test && cargo test --all-features
105 cd git-transport && cargo test && cargo test --features http-client-curl106 cd git-transport && cargo test && cargo test --features http-client-curl
106 cd gitoxide-core && cargo test --lib107 cd gitoxide-core && cargo test --lib
107 108
git-features/src/parallel/mod.rs+1−1
@@ -160,7 +160,7 @@ pub mod reduce { · 159 unmodified lines
160 };160 };
161 }161 }
162 if let Some(thread_err) = last_err {162 if let Some(thread_err) = last_err {
163 std::panic::panic_any(thread_err);163 std::panic::resume_unwind(thread_err);
164 }164 }
165 }165 }
166 }166 }
git-odb/Cargo.toml+11−0
@@ -16,6 +16,17 @@ default = ["flate2/zlib-ng-compat"] · 15 unmodified lines
16pack-cache-lru-static = ["uluru"]16pack-cache-lru-static = ["uluru"]
17pack-cache-lru-dynamic = ["memory-lru"]17pack-cache-lru-dynamic = ["memory-lru"]
18serde1 = ["serde", "git-object/serde1"]18serde1 = ["serde", "git-object/serde1"]
19internal-testing-git-features-parallel = ["git-features/parallel"]
20
21[[test]]
22name = "multi-threaded-odb"
23path = "tests/odb.rs"
24required-features = ["internal-testing-git-features-parallel"]
25
26[[test]]
27name = "single-threaded-odb"
28path = "tests/odb.rs"
29required-features = []
19 30
20[package.metadata.docs.rs]31[package.metadata.docs.rs]
21all-features = true32all-features = true
git-odb/src/pack/data/encode.rs+2−0
@@ -115,6 +115,8 @@ where · 114 unmodified lines
115 move |oid, (buf, cache)| {115 move |oid, (buf, cache)| {
116 let _obj = db.locate(oid.as_ref(), buf, cache)?;116 let _obj = db.locate(oid.as_ref(), buf, cache)?;
117 let _ = version; // currently unused117 let _ = version; // currently unused
118 todo!("entry generation");
119 #[allow(unreachable_code)]
118 Ok(Vec::new())120 Ok(Vec::new())
119 },121 },
120 parallel::reduce::IdentityWithResult::default(),122 parallel::reduce::IdentityWithResult::default(),
git-odb/tests/pack/data/encode.rs+22−18
@@ -17,23 +17,27 @@ mod simple_compression { · 16 unmodified lines
17 }17 }
18 18
19 #[test]19 #[test]
20 fn all_input_objects() -> crate::Result {20 #[should_panic]
21 let db = db(DbKind::AbunchOfRandomObjects)?;21 fn all_input_objects() {
22 let obj_count = db.iter().count();22 (|| -> Result<(), Box<dyn std::error::Error>> {
23 assert_eq!(obj_count, 146);23 let db = db(DbKind::AbunchOfRandomObjects)?;
24 let all_objects = db.arc_iter().flat_map(Result::ok);24 let obj_count = db.iter().count();
25 let entries: Vec<_> = pack::data::encode::entries(25 assert_eq!(obj_count, 146);
26 db.clone(),26 let all_objects = db.arc_iter().flat_map(Result::ok);
27 all_objects,27 let entries: Vec<_> = pack::data::encode::entries(
28 progress::Discard,28 db.clone(),
29 pack::data::encode::Options::default(),29 all_objects,
30 )30 progress::Discard,
31 .collect::<Result<Vec<_>, _>>()?31 pack::data::encode::Options::default(),
32 .into_iter()32 )
33 .flatten()33 .collect::<Result<Vec<_>, _>>()?
34 .collect();34 .into_iter()
35 // assert_eq!(entries.len(), obj_count, "each object gets one entry");35 .flatten()
36 assert_eq!(entries.len(), 0, "each object gets one entry");36 .collect();
37 Ok(())37 // assert_eq!(entries.len(), obj_count, "each object gets one entry");
38 assert_eq!(entries.len(), 0, "each object gets one entry");
39 Ok(())
40 })()
41 .unwrap();
38 }42 }
39}43}