Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ jobs:
override: true
components: rustfmt, clippy

- name: install php
uses: shivammathur/setup-php@v2
with:
php-version: 8.1

- name: cache
id: cache
uses: actions/cache@v3
Expand Down
110 changes: 100 additions & 10 deletions tests/third_party_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,18 @@ fn nikic_php_parser() {
test_repository(
"nikic/PHP-Parser",
"https://github.com/nikic/PHP-Parser",
&[],
&[
// Auto-generated parsers with syntax mistakes
"vendor/ircmaxell/php-yacc/examples/00-basic-usage/parser.template.php",
"vendor/ircmaxell/php-yacc/examples/01-expression-support/parser.template.php",
"vendor/ircmaxell/php-yacc/examples/02-complex-expression-support/parser.template.php",
"vendor/ircmaxell/php-yacc/examples/10-php7/parser.kmyacc.php",
"vendor/ircmaxell/php-yacc/examples/10-php7/parser.phpyacc.php",
"vendor/ircmaxell/php-yacc/examples/10-php7/parser.template.php",
"vendor/ircmaxell/php-yacc/examples/20-custom-parser/parser.kmyacc.php",
"vendor/ircmaxell/php-yacc/examples/20-custom-parser/parser.phpyacc.php",
"vendor/ircmaxell/php-yacc/examples/20-custom-parser/parser.template.php",
],
);
}

Expand Down Expand Up @@ -89,6 +100,52 @@ fn symfony_polyfill() {
);
}

#[test]
fn madelineproto() {
test_repository(
"MadelineProto",
"https://github.com/danog/MadelineProto",
&[],
);
}

#[test]
fn phabel() {
test_repository(
"phabel",
"https://github.com/phabelio/phabel",
&[
// Uses non-standard async/await syntax
"tests/TargetFuture/AwaitTest.php",
],
);
}

#[test]
fn psalm() {
test_repository("psalm", "https://github.com/vimeo/psalm", &[]);
}

#[test]
fn phpstan() {
test_repository("phpstan", "https://github.com/phpstan/phpstan", &[]);
}

#[test]
fn phpstan_src() {
test_repository("phpstan-src", "https://github.com/phpstan/phpstan-src", &[]);
}

#[test]
fn rector() {
test_repository("rector", "https://github.com/rectorphp/rector", &[]);
}

#[test]
fn rector_src() {
test_repository("rector-src", "https://github.com/rectorphp/rector-src", &[]);
}

#[test]
fn composer() {
test_repository("composer", "https://github.com/composer/composer", &[]);
Expand Down Expand Up @@ -185,7 +242,16 @@ fn doctrine_orm() {

#[test]
fn doctrine_dbal() {
test_repository("doctrine-dbal", "https://github.com/doctrine/dbal", &[]);
test_repository(
"doctrine-dbal",
"https://github.com/doctrine/dbal",
&[
// Files with invalid syntax meant to be parsed only by phpstorm
"vendor/jetbrains/phpstorm-stubs/Core/Core_c.php",
"vendor/jetbrains/phpstorm-stubs/eio/eio.php",
"vendor/jetbrains/phpstorm-stubs/event/event.php",
],
);
}

fn test_repository(name: &str, repository: &str, ignore: &[&str]) {
Expand All @@ -212,6 +278,29 @@ fn test_repository(name: &str, repository: &str, ignore: &[&str]) {
}
}

let composer_json = out_path.join("composer.json");
let autoload = out_path.join("vendor").join("autoload.php");

if composer_json.exists() && !autoload.exists() {
let output = Command::new("composer")
.arg("update")
.arg("--ignore-platform-reqs")
.arg("--no-plugins")
.arg("--no-scripts")
.arg("--no-interaction")
.arg("--prefer-dist")
.current_dir(&out_path)
.output()
.expect("failed to run composer");

if !output.status.success() {
panic!(
"failed to run composer install in repository: {:#?}",
output
)
}
}

let entries = read_directory(out_path.clone(), out_path, ignore);

let mut threads = vec![];
Expand Down Expand Up @@ -298,16 +387,17 @@ fn read_directory(root: PathBuf, directory: PathBuf, ignore: &[&str]) -> Vec<(St
continue;
}

let path = &entry
.as_path()
.strip_prefix(&root)
.unwrap()
.to_str()
.unwrap();

if entry.is_file()
&& entry.extension().unwrap_or_default() == "php"
&& !ignore.contains(
&entry
.as_path()
.strip_prefix(&root)
.unwrap()
.to_str()
.unwrap(),
)
&& !ignore.contains(path)
&& !path.starts_with("vendor/symfony")
{
let name_entry = entry.clone();
let fullanme_string = name_entry.to_string_lossy();
Expand Down