Skip to content

Not use example in tests. #69

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,3 @@ edition = "2021"
license = "MulanPSL-2.0"
repository = "https://github.com/jmjoy/phper.git"
rust-version = "1.64"

[profile.dev]
lto = true

[profile.release]
lto = true
8 changes: 0 additions & 8 deletions examples/hello/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,9 @@ rust-version.workspace = true
publish = false
license.workspace = true

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[lib]
crate-type = ["lib", "cdylib"]

# This example is hack to used for integration tests.
[[example]]
name = "hello"
path = "src/_reexport.rs"
crate-type = ["cdylib"]

[dependencies]
phper = { version = "0.5.1", path = "../../phper" }

Expand Down
11 changes: 0 additions & 11 deletions examples/hello/src/_reexport.rs

This file was deleted.

4 changes: 2 additions & 2 deletions examples/hello/tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
// NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
// See the Mulan PSL v2 for more details.

use phper_test::{cli::test_php_scripts_with_lib, utils::get_lib_path_by_example};
use phper_test::{cli::test_php_scripts_with_lib, utils::get_lib_path};
use std::{env, path::Path};

#[test]
fn test_php() {
test_php_scripts_with_lib(
get_lib_path_by_example(env!("CARGO_BIN_EXE_hello")),
get_lib_path(env!("CARGO_BIN_EXE_hello")),
&[&Path::new(env!("CARGO_MANIFEST_DIR"))
.join("tests")
.join("php")
Expand Down
8 changes: 0 additions & 8 deletions examples/http-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,9 @@ rust-version.workspace = true
publish = false
license.workspace = true

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[lib]
crate-type = ["lib", "cdylib"]

# This example is hack to used for integration tests.
[[example]]
name = "http-client"
path = "src/_reexport.rs"
crate-type = ["cdylib"]

[dependencies]
anyhow = "1.0.65"
bytes = "1.2.1"
Expand Down
11 changes: 0 additions & 11 deletions examples/http-client/src/_reexport.rs

This file was deleted.

4 changes: 2 additions & 2 deletions examples/http-client/tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
// NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
// See the Mulan PSL v2 for more details.

use phper_test::{cli::test_php_scripts_with_lib, utils::get_lib_path_by_example};
use phper_test::{cli::test_php_scripts_with_lib, utils::get_lib_path};
use std::{env, path::Path};

#[test]
fn test_php() {
test_php_scripts_with_lib(
get_lib_path_by_example(env!("CARGO_BIN_EXE_http-client")),
get_lib_path(env!("CARGO_BIN_EXE_http-client")),
&[&Path::new(env!("CARGO_MANIFEST_DIR"))
.join("tests")
.join("php")
Expand Down
8 changes: 0 additions & 8 deletions examples/http-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,9 @@ rust-version.workspace = true
publish = false
license.workspace = true

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[lib]
crate-type = ["lib", "cdylib"]

# This example is hack to used for integration tests.
[[example]]
name = "http-server"
path = "src/_reexport.rs"
crate-type = ["cdylib"]

[dependencies]
hyper = { version = "0.14.20", features = ["http1", "runtime", "server"] }
phper = { version = "0.5.1", path = "../../phper" }
Expand Down
11 changes: 0 additions & 11 deletions examples/http-server/src/_reexport.rs

This file was deleted.

6 changes: 2 additions & 4 deletions examples/http-server/tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,15 @@
// See the Mulan PSL v2 for more details.

use hyper::header::CONTENT_TYPE;
use phper_test::{
cli::test_long_term_php_script_with_condition_and_lib, utils::get_lib_path_by_example,
};
use phper_test::{cli::test_long_term_php_script_with_condition_and_lib, utils::get_lib_path};
use reqwest::Client;
use std::{env, path::Path, thread::sleep, time::Duration};
use tokio::runtime;

#[test]
fn test_php() {
test_long_term_php_script_with_condition_and_lib(
get_lib_path_by_example(env!("CARGO_BIN_EXE_http-server")),
get_lib_path(env!("CARGO_BIN_EXE_http-server")),
Path::new(env!("CARGO_MANIFEST_DIR"))
.join("tests")
.join("php")
Expand Down
8 changes: 0 additions & 8 deletions examples/logging/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,9 @@ rust-version.workspace = true
publish = false
license.workspace = true

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[lib]
crate-type = ["lib", "cdylib"]

# This example is hack to used for integration tests.
[[example]]
name = "logging"
path = "src/_reexport.rs"
crate-type = ["cdylib"]

[dependencies]
anyhow = "1.0.65"
phper = { version = "0.5.1", path = "../../phper" }
Expand Down
11 changes: 0 additions & 11 deletions examples/logging/src/_reexport.rs

This file was deleted.

4 changes: 2 additions & 2 deletions examples/logging/tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
// See the Mulan PSL v2 for more details.

use phper_test::{cli::test_php_scripts_with_condition_and_lib, utils::get_lib_path_by_example};
use phper_test::{cli::test_php_scripts_with_condition_and_lib, utils::get_lib_path};
use std::{env, path::Path, str};

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

test_php_scripts_with_condition_and_lib(
get_lib_path_by_example(env!("CARGO_BIN_EXE_logging")),
get_lib_path(env!("CARGO_BIN_EXE_logging")),
&[
(&base_dir.join("test_php_say.php"), &|output| {
let stdout = str::from_utf8(&output.stdout).unwrap();
Expand Down
2 changes: 0 additions & 2 deletions phper-alloc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ repository.workspace = true
license.workspace = true
keywords = ["php", "alloc"]

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
phper-sys = { version = "0.5.1", path = "../phper-sys" }

Expand Down
2 changes: 0 additions & 2 deletions phper-build/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,5 @@ repository.workspace = true
license.workspace = true
keywords = ["php", "binding"]

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
phper-sys = { version = "0.5.1", path = "../phper-sys" }
2 changes: 0 additions & 2 deletions phper-macros/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ repository.workspace = true
license.workspace = true
keywords = ["php", "proc-macro"]

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[lib]
proc-macro = true

Expand Down
6 changes: 3 additions & 3 deletions phper-macros/src/derives.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ fn parse_throwable_input(
Some(attr) => {
if attr.tokens.to_string() != "(transparent)" {
return Err(syn::Error::new_spanned(
&attr,
attr,
"now only support #[throwable(transparent)] for variant",
));
}
Expand All @@ -56,7 +56,7 @@ fn parse_throwable_input(
}
_ => {
return Err(syn::Error::new_spanned(
&variant,
variant,
"now only support unnamed field with one item mark attribute \
#[throwable]",
));
Expand Down Expand Up @@ -123,7 +123,7 @@ fn parse_throwable_input(
})
.into()),
Data::Union(_) => Err(syn::Error::new_spanned(
&input,
input,
"union auto derive Throwable is not supported",
)),
}
Expand Down
2 changes: 0 additions & 2 deletions phper-test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ repository.workspace = true
license.workspace = true
keywords = ["php", "binding"]

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[features]
fpm = ["fastcgi-client", "tokio/full"]

Expand Down
4 changes: 2 additions & 2 deletions phper-test/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pub fn test_php_scripts(exe_path: impl AsRef<Path>, scripts: &[&dyn AsRef<Path>]
.iter()
.map(|s| (*s, &condition as _))
.collect::<Vec<_>>();
test_php_scripts_with_condition(exe_path, &*scripts);
test_php_scripts_with_condition(exe_path, &scripts);
}

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

/// Script and condition pair.
Expand Down
14 changes: 1 addition & 13 deletions phper-test/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,6 @@ pub(crate) fn spawn_command<S: AsRef<OsStr> + Debug>(
}

pub fn get_lib_path(exe_path: impl AsRef<Path>) -> PathBuf {
get_lib_path_inner(exe_path, false)
}

pub fn get_lib_path_by_example(exe_path: impl AsRef<Path>) -> PathBuf {
get_lib_path_inner(exe_path, true)
}

fn get_lib_path_inner(exe_path: impl AsRef<Path>, use_example: bool) -> PathBuf {
let exe_path = exe_path.as_ref();
let exe_stem = exe_path
.file_stem()
Expand All @@ -88,9 +80,5 @@ fn get_lib_path_inner(exe_path: impl AsRef<Path>, use_example: bool) -> PathBuf
#[cfg(target_os = "windows")]
ext_name.push(".dll");

if use_example {
target_dir.join("examples").join(ext_name)
} else {
target_dir.join(ext_name)
}
target_dir.join(ext_name)
}
2 changes: 0 additions & 2 deletions phper/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ license.workspace = true
readme = "README.md"
keywords = ["php", "binding", "extension", "module"]

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
anyhow = "1.0.65"
clap = { version = "3.2.22", features = ["derive"] }
Expand Down
6 changes: 0 additions & 6 deletions tests/integration/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,6 @@ license.workspace = true
[lib]
crate-type = ["lib", "cdylib"]

# This example is hack to used for integration tests.
[[example]]
name = "integration"
path = "src/_reexport.rs"
crate-type = ["cdylib"]

[dependencies]
indexmap = "1.9.1"
phper = { version = "0.5.1", path = "../../phper" }
Expand Down
11 changes: 0 additions & 11 deletions tests/integration/src/_reexport.rs

This file was deleted.

8 changes: 3 additions & 5 deletions tests/integration/tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
// NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
// See the Mulan PSL v2 for more details.

use phper_test::{
cli::test_php_scripts_with_lib, fpm, fpm::test_fpm_request, utils::get_lib_path_by_example,
};
use phper_test::{cli::test_php_scripts_with_lib, fpm, fpm::test_fpm_request, utils::get_lib_path};
use std::{env, path::Path};

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

test_php_scripts_with_lib(
get_lib_path_by_example(env!("CARGO_BIN_EXE_integration")),
get_lib_path(env!("CARGO_BIN_EXE_integration")),
&[
&tests_php_dir.join("arguments.php"),
&tests_php_dir.join("arrays.php"),
Expand All @@ -41,7 +39,7 @@ fn test_fpm() {
.join("tests")
.join("php");

fpm::setup_lib(get_lib_path_by_example(env!("CARGO_BIN_EXE_integration")));
fpm::setup_lib(get_lib_path(env!("CARGO_BIN_EXE_integration")));

test_fpm_request("GET", &tests_php_dir, "/arguments.php", None, None);
test_fpm_request("GET", &tests_php_dir, "/arrays.php", None, None);
Expand Down