Skip to content

Commit 020ded4

Browse files
committed
Add subcommands to bigdecimal-property-tests
1 parent 2a054bb commit 020ded4

File tree

3 files changed

+43
-12
lines changed

3 files changed

+43
-12
lines changed

.gitlab-ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ cargo:check:
118118
<<: *script-cargo-check
119119
script:
120120
# enable property tests for the stable 'pipeline'
121-
- scripts/bigdecimal-property-tests cargo check --all-targets
121+
- scripts/bigdecimal-property-tests run cargo check --all-targets
122122

123123
cargo:clippy:
124124
stage: check
@@ -158,7 +158,7 @@ cargo:build-stable:
158158
<<: *script-cargo-build
159159
script:
160160
# enable property tests for the stable 'pipeline'
161-
- scripts/bigdecimal-property-tests cargo build --all-targets
161+
- scripts/bigdecimal-property-tests run cargo build --all-targets
162162

163163

164164
cargo:test-stable:
@@ -171,7 +171,7 @@ cargo:test-stable:
171171
<<: *script-cargo-test
172172
script:
173173
# enable property tests for the stable 'pipeline'
174-
- scripts/bigdecimal-property-tests cargo test
174+
- scripts/bigdecimal-property-tests run cargo test
175175

176176

177177
cargo:build:no-std:

scripts/bigdecimal-property-tests

Lines changed: 39 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,45 @@
55
# Tests are defined in src/lib.tests.property-test.rs
66
#
77

8-
# enable property-test dependencies in Cargo
9-
sed -i.bak -e 's|# PROPERTY-TESTS: ||' Cargo.toml
8+
function enable_property_tests() {
9+
# enable property-test dependencies in Cargo
10+
sed -i.bak -e 's|# PROPERTY-TESTS: ||' Cargo.toml
1011

11-
# include the property-test file in lib.rs
12-
sed -i.bak -e 's|// ::PROPERTY-TESTS:: ||' build.rs
12+
# add the property-test configuration in build.rs
13+
sed -i.bak -e 's|// ::PROPERTY-TESTS:: ||' build.rs
14+
}
1315

14-
# Run commands
15-
"$@"
1616

17-
# Restore Cargo.toml with backup
18-
mv Cargo.toml.bak Cargo.toml
19-
mv src/lib.rs.bak src/lib.rs
17+
function restore_disabled_property_tests() {
18+
# Restore Cargo.toml with backup
19+
mv Cargo.toml.bak Cargo.toml
20+
mv build.rs.bak build.rs
21+
}
22+
23+
24+
DEFAULT_CMD=run
25+
CMD=${1:-$DEFAULT_CMD}
26+
shift
27+
28+
case "${CMD}" in
29+
run)
30+
enable_property_tests
31+
# Run commands
32+
"$@"
33+
restore_disabled_property_tests
34+
;;
35+
36+
test)
37+
enable_property_tests
38+
cargo test $@
39+
restore_disabled_property_tests
40+
;;
41+
42+
enable)
43+
enable_property_tests
44+
;;
45+
46+
disable)
47+
restore_disabled_property_tests
48+
;;
49+
esac

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3364,6 +3364,7 @@ extern crate proptest;
33643364
mod proptests {
33653365
use super::*;
33663366
use paste::paste;
3367+
use proptest::*;
33673368

33683369
include!("lib.tests.property-tests.rs");
33693370
}

0 commit comments

Comments
 (0)