Skip to content

Commit 674df63

Browse files
authored
Merge pull request #2748 from PsiACE/datablocks
[test] apply the new test style to common-datablocks
2 parents bf907eb + c2a6d9f commit 674df63

14 files changed

+68
-54
lines changed

common/datablocks/Cargo.toml

+4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ license = "Apache-2.0"
66
publish = false
77
edition = "2021"
88

9+
[lib]
10+
doctest = false
11+
test = false
12+
913
[dependencies] # In alphabetical order
1014
# Workspace dependencies
1115
common-arrow = {path = "../arrow"}

common/datablocks/src/kernels/mod.rs

-17
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,6 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
#[cfg(test)]
16-
mod data_block_concat_test;
17-
#[cfg(test)]
18-
mod data_block_filter_test;
19-
#[cfg(test)]
20-
mod data_block_group_by_hash_test;
21-
#[cfg(test)]
22-
mod data_block_group_by_test;
23-
#[cfg(test)]
24-
mod data_block_scatter_test;
25-
#[cfg(test)]
26-
mod data_block_slice_test;
27-
#[cfg(test)]
28-
mod data_block_sort_test;
29-
#[cfg(test)]
30-
mod data_block_take_test;
31-
3215
mod data_block_concat;
3316
mod data_block_filter;
3417
mod data_block_group_by;

common/datablocks/src/lib.rs

-3
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@
1414

1515
#![feature(hash_raw_entry)]
1616

17-
#[cfg(test)]
18-
mod data_block_test;
19-
2017
mod data_block;
2118
mod data_block_debug;
2219
mod kernels;

common/datablocks/src/data_block_test.rs renamed to common/datablocks/tests/it/data_block.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,11 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15+
use common_datablocks::DataBlock;
1516
use common_datavalues::prelude::*;
1617
use common_exception::Result;
1718
use pretty_assertions::assert_eq;
1819

19-
use crate::DataBlock;
20-
2120
#[test]
2221
fn test_data_block() -> Result<()> {
2322
let schema = DataSchemaRefExt::create(vec![DataField::new("a", DataType::Int64, false)]);

common/datablocks/src/kernels/data_block_concat_test.rs renamed to common/datablocks/tests/it/kernels/data_block_concat.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,12 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15+
use common_datablocks::*;
1516
use common_datavalues::prelude::*;
1617
use common_datavalues::series::Series;
1718
use common_datavalues::series::SeriesFrom;
1819
use common_exception::Result;
1920

20-
use crate::*;
21-
2221
#[test]
2322
fn test_data_block_concat() -> Result<()> {
2423
let schema = DataSchemaRefExt::create(vec![
@@ -59,6 +58,6 @@ fn test_data_block_concat() -> Result<()> {
5958
"| 9 | b3 |",
6059
"+---+----+",
6160
];
62-
crate::assert_blocks_eq(expected, &[results]);
61+
common_datablocks::assert_blocks_eq(expected, &[results]);
6362
Ok(())
6463
}

common/datablocks/src/kernels/data_block_filter_test.rs renamed to common/datablocks/tests/it/kernels/data_block_filter.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15+
use common_datablocks::DataBlock;
1516
use common_datavalues::columns::DataColumn;
1617
use common_datavalues::prelude::SeriesFrom;
1718
use common_datavalues::series::Series;
@@ -21,8 +22,6 @@ use common_datavalues::DataType;
2122
use common_datavalues::DataValue;
2223
use common_exception::Result;
2324

24-
use crate::DataBlock;
25-
2625
#[test]
2726
fn test_filter_non_const_data_block() -> Result<()> {
2827
let schema = DataSchemaRefExt::create(vec![
@@ -38,7 +37,7 @@ fn test_filter_non_const_data_block() -> Result<()> {
3837
let predicate = Series::new(vec![true, false, true, true, false, false]);
3938
let block = DataBlock::filter_block(&block, predicate)?;
4039

41-
crate::assert_blocks_eq(
40+
common_datablocks::assert_blocks_eq(
4241
vec![
4342
"+---+----+",
4443
"| a | b |",
@@ -69,9 +68,10 @@ fn test_filter_all_false_data_block() -> Result<()> {
6968
let predicate = Series::new(vec![false, false, false, false, false, false]);
7069
let block = DataBlock::filter_block(&block, predicate)?;
7170

72-
crate::assert_blocks_eq(vec!["+---+---+", "| a | b |", "+---+---+", "+---+---+"], &[
73-
block,
74-
]);
71+
common_datablocks::assert_blocks_eq(
72+
vec!["+---+---+", "| a | b |", "+---+---+", "+---+---+"],
73+
&[block],
74+
);
7575

7676
Ok(())
7777
}
@@ -91,7 +91,7 @@ fn test_filter_const_data_block() -> Result<()> {
9191
let predicate = Series::new(vec![true, false, true, true, false, false]);
9292
let block = DataBlock::filter_block(&block, predicate)?;
9393

94-
crate::assert_blocks_eq(
94+
common_datablocks::assert_blocks_eq(
9595
vec![
9696
"+---+----+",
9797
"| a | b |",
@@ -122,7 +122,7 @@ fn test_filter_all_const_data_block() -> Result<()> {
122122
let predicate = Series::new(vec![true, false, true, true, false, false]);
123123
let block = DataBlock::filter_block(&block, predicate)?;
124124

125-
crate::assert_blocks_eq(
125+
common_datablocks::assert_blocks_eq(
126126
vec![
127127
"+---+----+",
128128
"| a | b |",

common/datablocks/src/kernels/data_block_group_by_test.rs renamed to common/datablocks/tests/it/kernels/data_block_group_by.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,10 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15+
use common_datablocks::*;
1516
use common_datavalues::prelude::*;
1617
use common_exception::Result;
1718

18-
use crate::*;
19-
2019
#[test]
2120
fn test_data_block_group_by() -> Result<()> {
2221
let schema = DataSchemaRefExt::create(vec![
@@ -41,7 +40,7 @@ fn test_data_block_group_by() -> Result<()> {
4140
"| 3 | x3 |",
4241
"+---+----+",
4342
];
44-
crate::assert_blocks_sorted_eq(expected, &[block]);
43+
common_datablocks::assert_blocks_sorted_eq(expected, &[block]);
4544
}
4645
2 => {
4746
let expected = vec![
@@ -52,7 +51,7 @@ fn test_data_block_group_by() -> Result<()> {
5251
"| 2 | x2 |",
5352
"+---+----+",
5453
];
55-
crate::assert_blocks_sorted_eq(expected, &[block]);
54+
common_datablocks::assert_blocks_sorted_eq(expected, &[block]);
5655
}
5756
3 => {
5857
let expected = vec![
@@ -64,7 +63,7 @@ fn test_data_block_group_by() -> Result<()> {
6463
"| 1 | x1 |",
6564
"+---+----+",
6665
];
67-
crate::assert_blocks_sorted_eq(expected, &[block]);
66+
common_datablocks::assert_blocks_sorted_eq(expected, &[block]);
6867
}
6968
_ => unreachable!(),
7069
}

common/datablocks/src/kernels/data_block_group_by_hash_test.rs renamed to common/datablocks/tests/it/kernels/data_block_group_by_hash.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,10 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15+
use common_datablocks::*;
1516
use common_datavalues::prelude::*;
1617
use common_exception::Result;
1718

18-
use crate::*;
19-
2019
#[test]
2120
fn test_data_block_group_by_hash() -> Result<()> {
2221
let schema = DataSchemaRefExt::create(vec![

common/datablocks/src/kernels/data_block_scatter_test.rs renamed to common/datablocks/tests/it/kernels/data_block_scatter.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,10 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15+
use common_datablocks::*;
1516
use common_datavalues::prelude::*;
1617
use common_exception::Result;
1718

18-
use crate::*;
19-
2019
#[test]
2120
fn test_data_block_scatter() -> Result<()> {
2221
let schema = DataSchemaRefExt::create(vec![
@@ -46,7 +45,7 @@ fn test_data_block_scatter() -> Result<()> {
4645
"| 2 | 2 |",
4746
"+---+---+",
4847
];
49-
crate::assert_blocks_eq(expected, &scattered);
48+
common_datablocks::assert_blocks_eq(expected, &scattered);
5049

5150
Ok(())
5251
}

common/datablocks/src/kernels/data_block_slice_test.rs renamed to common/datablocks/tests/it/kernels/data_block_slice.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,10 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15+
use common_datablocks::*;
1516
use common_datavalues::prelude::*;
1617
use common_exception::Result;
1718

18-
use crate::*;
19-
2019
#[test]
2120
fn test_data_block_slice() -> Result<()> {
2221
let schema = DataSchemaRefExt::create(vec![
@@ -43,6 +42,6 @@ fn test_data_block_slice() -> Result<()> {
4342
"| 5 | 5 |",
4443
"+---+---+",
4544
];
46-
crate::assert_blocks_eq(expected, &sliced);
45+
common_datablocks::assert_blocks_eq(expected, &sliced);
4746
Ok(())
4847
}

common/datablocks/src/kernels/data_block_sort_test.rs renamed to common/datablocks/tests/it/kernels/data_block_sort.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,10 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15+
use common_datablocks::*;
1516
use common_datavalues::prelude::*;
1617
use common_exception::Result;
1718

18-
use crate::*;
19-
2019
#[test]
2120
fn test_data_block_sort() -> Result<()> {
2221
let schema = DataSchemaRefExt::create(vec![
@@ -47,7 +46,7 @@ fn test_data_block_sort() -> Result<()> {
4746
"| 3 | b3 |",
4847
"+---+----+",
4948
];
50-
crate::assert_blocks_eq(expected, &[results]);
49+
common_datablocks::assert_blocks_eq(expected, &[results]);
5150
}
5251

5352
{
@@ -68,7 +67,7 @@ fn test_data_block_sort() -> Result<()> {
6867
"| 4 | b2 |",
6968
"+---+----+",
7069
];
71-
crate::assert_blocks_eq(expected, &[results]);
70+
common_datablocks::assert_blocks_eq(expected, &[results]);
7271
}
7372
Ok(())
7473
}
@@ -112,7 +111,7 @@ fn test_data_block_merge_sort() -> Result<()> {
112111
"| 7 | b3 |",
113112
"+---+----+",
114113
];
115-
crate::assert_blocks_eq(expected, &[results]);
114+
common_datablocks::assert_blocks_eq(expected, &[results]);
116115
}
117116

118117
Ok(())

common/datablocks/src/kernels/data_block_take_test.rs renamed to common/datablocks/tests/it/kernels/data_block_take.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,10 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15+
use common_datablocks::*;
1516
use common_datavalues::prelude::*;
1617
use common_exception::Result;
1718

18-
use crate::*;
19-
2019
#[test]
2120
fn test_data_block_take() -> Result<()> {
2221
let schema = DataSchemaRefExt::create(vec![
@@ -40,7 +39,7 @@ fn test_data_block_take() -> Result<()> {
4039
"| 3 | b3 |",
4140
"+---+----+",
4241
];
43-
crate::assert_blocks_eq(expected, &[take]);
42+
common_datablocks::assert_blocks_eq(expected, &[take]);
4443

4544
Ok(())
4645
}
+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Copyright 2020 Datafuse Labs.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
mod data_block_concat;
16+
mod data_block_filter;
17+
mod data_block_group_by;
18+
mod data_block_group_by_hash;
19+
mod data_block_scatter;
20+
mod data_block_slice;
21+
mod data_block_sort;
22+
mod data_block_take;

common/datablocks/tests/it/main.rs

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright 2020 Datafuse Labs.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
mod data_block;
16+
mod kernels;

0 commit comments

Comments
 (0)