Skip to content

Commit 28fa2fa

Browse files
committed
Use examples to hack for integration tests.
1 parent 94c1f3a commit 28fa2fa

File tree

14 files changed

+75
-34
lines changed

14 files changed

+75
-34
lines changed

examples/hello/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ crate-type = ["lib", "cdylib"]
1414

1515
# This example is hack to used for integration tests.
1616
[[example]]
17-
name = "hello_reexport"
17+
name = "hello"
1818
path = "src/_reexport.rs"
1919
crate-type = ["cdylib"]
2020

examples/hello/tests/integration.rs

Lines changed: 3 additions & 3 deletions
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;
11+
use phper_test::{cli::{test_php_scripts, test_php_scripts_with_lib}, utils::get_lib_path_by_example};
1212
use std::{env, path::Path};
1313

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

examples/http-client/Cargo.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ license = "MulanPSL-2.0"
1010
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1111

1212
[lib]
13+
crate-type = ["lib", "cdylib"]
14+
15+
# This example is hack to used for integration tests.
16+
[[example]]
17+
name = "http-client"
18+
path = "src/_reexport.rs"
1319
crate-type = ["cdylib"]
1420

1521
[dependencies]

examples/http-client/src/_reexport.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Copyright (c) 2019 jmjoy
2+
// PHPER is licensed under Mulan PSL v2.
3+
// You can use this software according to the terms and conditions of the Mulan
4+
// PSL v2. You may obtain a copy of Mulan PSL v2 at:
5+
// http://license.coscl.org.cn/MulanPSL2
6+
// THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY
7+
// KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
8+
// NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
9+
// See the Mulan PSL v2 for more details.
10+
11+
pub use http_client::*;

examples/http-client/tests/integration.rs

Lines changed: 3 additions & 3 deletions
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;
11+
use phper_test::{cli::{test_php_scripts, test_php_scripts_with_lib}, utils::get_lib_path_by_example};
1212
use std::{env, path::Path};
1313

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

examples/http-server/Cargo.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ license = "MulanPSL-2.0"
1010
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1111

1212
[lib]
13+
crate-type = ["lib", "cdylib"]
14+
15+
# This example is hack to used for integration tests.
16+
[[example]]
17+
name = "http-server"
18+
path = "src/_reexport.rs"
1319
crate-type = ["cdylib"]
1420

1521
[dependencies]

examples/http-server/src/_reexport.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Copyright (c) 2019 jmjoy
2+
// PHPER is licensed under Mulan PSL v2.
3+
// You can use this software according to the terms and conditions of the Mulan
4+
// PSL v2. You may obtain a copy of Mulan PSL v2 at:
5+
// http://license.coscl.org.cn/MulanPSL2
6+
// THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY
7+
// KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
8+
// NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
9+
// See the Mulan PSL v2 for more details.
10+
11+
pub use http_server::*;

examples/http-server/src/server.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ pub fn make_server_class() -> StatefulClass<Option<Builder<AddrIncoming>>> {
5050
|this, arguments| {
5151
let host = arguments[0].expect_z_str()?;
5252
let port = arguments[1].expect_long()?;
53-
this.set_property("host", host);
53+
this.set_property("host", host.to_owned());
5454
this.set_property("port", port);
5555
let addr = format!("{}:{}", host.to_str()?, port).parse::<SocketAddr>()?;
5656
let builder = Server::bind(&addr);

examples/http-server/tests/integration.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@
99
// See the Mulan PSL v2 for more details.
1010

1111
use hyper::header::CONTENT_TYPE;
12-
use phper_test::cli::test_long_term_php_script_with_condition;
12+
use phper_test::{cli::{test_long_term_php_script_with_condition, test_long_term_php_script_with_condition_and_lib}, utils::get_lib_path_by_example};
1313
use reqwest::Client;
1414
use std::{env, path::Path, thread::sleep, time::Duration};
1515
use tokio::runtime;
1616

1717
#[test]
1818
fn test_php() {
19-
test_long_term_php_script_with_condition(
20-
env!("CARGO_BIN_EXE_http-server"),
19+
test_long_term_php_script_with_condition_and_lib(
20+
get_lib_path_by_example(env!("CARGO_BIN_EXE_http-server")),
2121
Path::new(env!("CARGO_MANIFEST_DIR"))
2222
.join("tests")
2323
.join("php")

examples/logging/Cargo.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ license = "MulanPSL-2.0"
1010
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1111

1212
[lib]
13+
crate-type = ["lib", "cdylib"]
14+
15+
# This example is hack to used for integration tests.
16+
[[example]]
17+
name = "logging"
18+
path = "src/_reexport.rs"
1319
crate-type = ["cdylib"]
1420

1521
[dependencies]

0 commit comments

Comments
 (0)