Skip to content

Commit ea50fa4

Browse files
authored
Not use example in tests. (#69)
1 parent fc5a2bb commit ea50fa4

File tree

24 files changed

+17
-142
lines changed

24 files changed

+17
-142
lines changed

Cargo.toml

-6
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,3 @@ edition = "2021"
3131
license = "MulanPSL-2.0"
3232
repository = "https://github.com/jmjoy/phper.git"
3333
rust-version = "1.64"
34-
35-
[profile.dev]
36-
lto = true
37-
38-
[profile.release]
39-
lto = true

examples/hello/Cargo.toml

-8
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,9 @@ rust-version.workspace = true
1717
publish = false
1818
license.workspace = true
1919

20-
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
21-
2220
[lib]
2321
crate-type = ["lib", "cdylib"]
2422

25-
# This example is hack to used for integration tests.
26-
[[example]]
27-
name = "hello"
28-
path = "src/_reexport.rs"
29-
crate-type = ["cdylib"]
30-
3123
[dependencies]
3224
phper = { version = "0.5.1", path = "../../phper" }
3325

examples/hello/src/_reexport.rs

-11
This file was deleted.

examples/hello/tests/integration.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88
// NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
99
// See the Mulan PSL v2 for more details.
1010

11-
use phper_test::{cli::test_php_scripts_with_lib, utils::get_lib_path_by_example};
11+
use phper_test::{cli::test_php_scripts_with_lib, utils::get_lib_path};
1212
use std::{env, path::Path};
1313

1414
#[test]
1515
fn test_php() {
1616
test_php_scripts_with_lib(
17-
get_lib_path_by_example(env!("CARGO_BIN_EXE_hello")),
17+
get_lib_path(env!("CARGO_BIN_EXE_hello")),
1818
&[&Path::new(env!("CARGO_MANIFEST_DIR"))
1919
.join("tests")
2020
.join("php")

examples/http-client/Cargo.toml

-8
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,9 @@ rust-version.workspace = true
1717
publish = false
1818
license.workspace = true
1919

20-
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
21-
2220
[lib]
2321
crate-type = ["lib", "cdylib"]
2422

25-
# This example is hack to used for integration tests.
26-
[[example]]
27-
name = "http-client"
28-
path = "src/_reexport.rs"
29-
crate-type = ["cdylib"]
30-
3123
[dependencies]
3224
anyhow = "1.0.65"
3325
bytes = "1.2.1"

examples/http-client/src/_reexport.rs

-11
This file was deleted.

examples/http-client/tests/integration.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88
// NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
99
// See the Mulan PSL v2 for more details.
1010

11-
use phper_test::{cli::test_php_scripts_with_lib, utils::get_lib_path_by_example};
11+
use phper_test::{cli::test_php_scripts_with_lib, utils::get_lib_path};
1212
use std::{env, path::Path};
1313

1414
#[test]
1515
fn test_php() {
1616
test_php_scripts_with_lib(
17-
get_lib_path_by_example(env!("CARGO_BIN_EXE_http-client")),
17+
get_lib_path(env!("CARGO_BIN_EXE_http-client")),
1818
&[&Path::new(env!("CARGO_MANIFEST_DIR"))
1919
.join("tests")
2020
.join("php")

examples/http-server/Cargo.toml

-8
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,9 @@ rust-version.workspace = true
1717
publish = false
1818
license.workspace = true
1919

20-
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
21-
2220
[lib]
2321
crate-type = ["lib", "cdylib"]
2422

25-
# This example is hack to used for integration tests.
26-
[[example]]
27-
name = "http-server"
28-
path = "src/_reexport.rs"
29-
crate-type = ["cdylib"]
30-
3123
[dependencies]
3224
hyper = { version = "0.14.20", features = ["http1", "runtime", "server"] }
3325
phper = { version = "0.5.1", path = "../../phper" }

examples/http-server/src/_reexport.rs

-11
This file was deleted.

examples/http-server/tests/integration.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,15 @@
99
// See the Mulan PSL v2 for more details.
1010

1111
use hyper::header::CONTENT_TYPE;
12-
use phper_test::{
13-
cli::test_long_term_php_script_with_condition_and_lib, utils::get_lib_path_by_example,
14-
};
12+
use phper_test::{cli::test_long_term_php_script_with_condition_and_lib, utils::get_lib_path};
1513
use reqwest::Client;
1614
use std::{env, path::Path, thread::sleep, time::Duration};
1715
use tokio::runtime;
1816

1917
#[test]
2018
fn test_php() {
2119
test_long_term_php_script_with_condition_and_lib(
22-
get_lib_path_by_example(env!("CARGO_BIN_EXE_http-server")),
20+
get_lib_path(env!("CARGO_BIN_EXE_http-server")),
2321
Path::new(env!("CARGO_MANIFEST_DIR"))
2422
.join("tests")
2523
.join("php")

examples/logging/Cargo.toml

-8
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,9 @@ rust-version.workspace = true
1717
publish = false
1818
license.workspace = true
1919

20-
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
21-
2220
[lib]
2321
crate-type = ["lib", "cdylib"]
2422

25-
# This example is hack to used for integration tests.
26-
[[example]]
27-
name = "logging"
28-
path = "src/_reexport.rs"
29-
crate-type = ["cdylib"]
30-
3123
[dependencies]
3224
anyhow = "1.0.65"
3325
phper = { version = "0.5.1", path = "../../phper" }

examples/logging/src/_reexport.rs

-11
This file was deleted.

examples/logging/tests/integration.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
99
// See the Mulan PSL v2 for more details.
1010

11-
use phper_test::{cli::test_php_scripts_with_condition_and_lib, utils::get_lib_path_by_example};
11+
use phper_test::{cli::test_php_scripts_with_condition_and_lib, utils::get_lib_path};
1212
use std::{env, path::Path, str};
1313

1414
#[test]
@@ -18,7 +18,7 @@ fn test_php() {
1818
.join("php");
1919

2020
test_php_scripts_with_condition_and_lib(
21-
get_lib_path_by_example(env!("CARGO_BIN_EXE_logging")),
21+
get_lib_path(env!("CARGO_BIN_EXE_logging")),
2222
&[
2323
(&base_dir.join("test_php_say.php"), &|output| {
2424
let stdout = str::from_utf8(&output.stdout).unwrap();

phper-alloc/Cargo.toml

-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ repository.workspace = true
1919
license.workspace = true
2020
keywords = ["php", "alloc"]
2121

22-
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
23-
2422
[dependencies]
2523
phper-sys = { version = "0.5.1", path = "../phper-sys" }
2624

phper-build/Cargo.toml

-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,5 @@ repository.workspace = true
1919
license.workspace = true
2020
keywords = ["php", "binding"]
2121

22-
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
23-
2422
[dependencies]
2523
phper-sys = { version = "0.5.1", path = "../phper-sys" }

phper-macros/Cargo.toml

-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ repository.workspace = true
1919
license.workspace = true
2020
keywords = ["php", "proc-macro"]
2121

22-
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
23-
2422
[lib]
2523
proc-macro = true
2624

phper-macros/src/derives.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ fn parse_throwable_input(
4646
Some(attr) => {
4747
if attr.tokens.to_string() != "(transparent)" {
4848
return Err(syn::Error::new_spanned(
49-
&attr,
49+
attr,
5050
"now only support #[throwable(transparent)] for variant",
5151
));
5252
}
@@ -56,7 +56,7 @@ fn parse_throwable_input(
5656
}
5757
_ => {
5858
return Err(syn::Error::new_spanned(
59-
&variant,
59+
variant,
6060
"now only support unnamed field with one item mark attribute \
6161
#[throwable]",
6262
));
@@ -123,7 +123,7 @@ fn parse_throwable_input(
123123
})
124124
.into()),
125125
Data::Union(_) => Err(syn::Error::new_spanned(
126-
&input,
126+
input,
127127
"union auto derive Throwable is not supported",
128128
)),
129129
}

phper-test/Cargo.toml

-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ repository.workspace = true
1919
license.workspace = true
2020
keywords = ["php", "binding"]
2121

22-
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
23-
2422
[features]
2523
fpm = ["fastcgi-client", "tokio/full"]
2624

phper-test/src/cli.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ pub fn test_php_scripts(exe_path: impl AsRef<Path>, scripts: &[&dyn AsRef<Path>]
3434
.iter()
3535
.map(|s| (*s, &condition as _))
3636
.collect::<Vec<_>>();
37-
test_php_scripts_with_condition(exe_path, &*scripts);
37+
test_php_scripts_with_condition(exe_path, &scripts);
3838
}
3939

4040
/// Check your extension by executing the php script, if the all executing
@@ -53,7 +53,7 @@ pub fn test_php_scripts_with_lib(lib_path: impl AsRef<Path>, scripts: &[&dyn AsR
5353
.iter()
5454
.map(|s| (*s, &condition as _))
5555
.collect::<Vec<_>>();
56-
test_php_scripts_with_condition_and_lib(lib_path, &*scripts);
56+
test_php_scripts_with_condition_and_lib(lib_path, &scripts);
5757
}
5858

5959
/// Script and condition pair.

phper-test/src/utils.rs

+1-13
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,6 @@ pub(crate) fn spawn_command<S: AsRef<OsStr> + Debug>(
6060
}
6161

6262
pub fn get_lib_path(exe_path: impl AsRef<Path>) -> PathBuf {
63-
get_lib_path_inner(exe_path, false)
64-
}
65-
66-
pub fn get_lib_path_by_example(exe_path: impl AsRef<Path>) -> PathBuf {
67-
get_lib_path_inner(exe_path, true)
68-
}
69-
70-
fn get_lib_path_inner(exe_path: impl AsRef<Path>, use_example: bool) -> PathBuf {
7163
let exe_path = exe_path.as_ref();
7264
let exe_stem = exe_path
7365
.file_stem()
@@ -88,9 +80,5 @@ fn get_lib_path_inner(exe_path: impl AsRef<Path>, use_example: bool) -> PathBuf
8880
#[cfg(target_os = "windows")]
8981
ext_name.push(".dll");
9082

91-
if use_example {
92-
target_dir.join("examples").join(ext_name)
93-
} else {
94-
target_dir.join(ext_name)
95-
}
83+
target_dir.join(ext_name)
9684
}

phper/Cargo.toml

-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ license.workspace = true
2121
readme = "README.md"
2222
keywords = ["php", "binding", "extension", "module"]
2323

24-
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
25-
2624
[dependencies]
2725
anyhow = "1.0.65"
2826
clap = { version = "3.2.22", features = ["derive"] }

tests/integration/Cargo.toml

-6
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,6 @@ license.workspace = true
2020
[lib]
2121
crate-type = ["lib", "cdylib"]
2222

23-
# This example is hack to used for integration tests.
24-
[[example]]
25-
name = "integration"
26-
path = "src/_reexport.rs"
27-
crate-type = ["cdylib"]
28-
2923
[dependencies]
3024
indexmap = "1.9.1"
3125
phper = { version = "0.5.1", path = "../../phper" }

tests/integration/src/_reexport.rs

-11
This file was deleted.

tests/integration/tests/integration.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@
88
// NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
99
// See the Mulan PSL v2 for more details.
1010

11-
use phper_test::{
12-
cli::test_php_scripts_with_lib, fpm, fpm::test_fpm_request, utils::get_lib_path_by_example,
13-
};
11+
use phper_test::{cli::test_php_scripts_with_lib, fpm, fpm::test_fpm_request, utils::get_lib_path};
1412
use std::{env, path::Path};
1513

1614
#[test]
@@ -20,7 +18,7 @@ fn test_cli() {
2018
.join("php");
2119

2220
test_php_scripts_with_lib(
23-
get_lib_path_by_example(env!("CARGO_BIN_EXE_integration")),
21+
get_lib_path(env!("CARGO_BIN_EXE_integration")),
2422
&[
2523
&tests_php_dir.join("arguments.php"),
2624
&tests_php_dir.join("arrays.php"),
@@ -41,7 +39,7 @@ fn test_fpm() {
4139
.join("tests")
4240
.join("php");
4341

44-
fpm::setup_lib(get_lib_path_by_example(env!("CARGO_BIN_EXE_integration")));
42+
fpm::setup_lib(get_lib_path(env!("CARGO_BIN_EXE_integration")));
4543

4644
test_fpm_request("GET", &tests_php_dir, "/arguments.php", None, None);
4745
test_fpm_request("GET", &tests_php_dir, "/arrays.php", None, None);

0 commit comments

Comments
 (0)