aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe
diff options
context:
space:
mode:
Diffstat (limited to 'crates/shirabe')
-rw-r--r--crates/shirabe/src/package/archiver/base_exclude_filter.rs14
-rw-r--r--crates/shirabe/tests/all_functional_test.rs15
-rw-r--r--crates/shirabe/tests/package/archiver/archivable_files_finder_test.rs28
-rw-r--r--crates/shirabe/tests/package/archiver/archive_manager_test.rs2
-rw-r--r--crates/shirabe/tests/package/archiver/git_exclude_filter_test.rs4
-rw-r--r--crates/shirabe/tests/package/archiver/phar_archiver_test.rs1
6 files changed, 32 insertions, 32 deletions
diff --git a/crates/shirabe/src/package/archiver/base_exclude_filter.rs b/crates/shirabe/src/package/archiver/base_exclude_filter.rs
index fa2007fb..05bd7adc 100644
--- a/crates/shirabe/src/package/archiver/base_exclude_filter.rs
+++ b/crates/shirabe/src/package/archiver/base_exclude_filter.rs
@@ -59,14 +59,14 @@ impl BaseExcludeFilterBase {
let rule = rule.trim_matches('/');
- let glob_regex = Glob::to_regex(rule, true, true);
- let rule_regex = &glob_regex[2..glob_regex.len() - 2];
+ // Regex pattern compatibility:
+ // PHP strips the delimiters/anchors off Glob::toRegex output and appends the
+ // `(?=$|/)` look-ahead, which the regex crate cannot compile. The boundary has
+ // to participate in Glob's no-dot union expansion, so it is woven into the
+ // body by to_regex_dir_boundary instead of being appended here.
+ let rule_regex = Glob::to_regex_dir_boundary(rule, true, true);
- (
- format!("{{{}{}(?=$|/)}}", pattern, rule_regex),
- negate,
- false,
- )
+ (format!("{{{}{}}}", pattern, rule_regex), negate, false)
}
}
diff --git a/crates/shirabe/tests/all_functional_test.rs b/crates/shirabe/tests/all_functional_test.rs
index 2bd81e11..72e1cbec 100644
--- a/crates/shirabe/tests/all_functional_test.rs
+++ b/crates/shirabe/tests/all_functional_test.rs
@@ -259,16 +259,11 @@ fn test_integration_create_project_command() {
#[test]
#[serial]
-#[ignore = "the former blocker (scheme-less packages.json read via RemoteFilesystem::\
- get_remote_contents) is fixed and the EXPECT-REGEX assertion itself now passes, but \
- only incidentally: the run needs live network (real git clone from github.com) and \
- still panics with exit 101 (Composer exits 0) during CreateProjectCommand's keep-vcs \
- cleanup, whose Symfony Finder name patterns go through Glob::to_regex, which \
- faithfully emits PCRE lookaheads ((?=[^\\.])) the regex crate cannot compile; the \
- fixture just never asserts the exit code. Making Glob::to_regex regex-crate-compatible \
- would change the pattern text git_exclude_filter_test::test_pattern_escape asserts \
- verbatim, so both that rewrite and un-ignoring this green-but-crashing test need a \
- user decision"]
+#[ignore = "needs live network (real git clone from github.com). The two former in-process \
+ blockers are fixed: the scheme-less packages.json read via RemoteFilesystem::\
+ get_remote_contents, and the exit-101 panic during CreateProjectCommand's keep-vcs \
+ cleanup, whose Symfony Finder name patterns go through Glob::to_regex (now \
+ regex-crate-compatible); a full green run is unverified because it requires network"]
fn test_integration_create_project_shows_full_hash_for_dev_packages() {
run_integration("create-project-shows-full-hash-for-dev-packages.test");
}
diff --git a/crates/shirabe/tests/package/archiver/archivable_files_finder_test.rs b/crates/shirabe/tests/package/archiver/archivable_files_finder_test.rs
index ae9784ee..50e6a66a 100644
--- a/crates/shirabe/tests/package/archiver/archivable_files_finder_test.rs
+++ b/crates/shirabe/tests/package/archiver/archivable_files_finder_test.rs
@@ -105,9 +105,6 @@ fn assert_archivable_files(set_up: &SetUp, finder: ArchivableFilesFinder, expect
assert_eq!(expected_files, actual_files);
}
-// The manual exclude patterns (e.g. `.*`, `prefixC.*`) compile, via ComposerExcludeFilter, to
-// look-ahead regexes like `(?=[^\.])...(?=$|/)`, which the regex crate cannot compile.
-#[ignore = "ComposerExcludeFilter builds look-ahead regexes the regex crate does not support"]
#[test]
fn test_manual_excludes() {
let set_up = set_up();
@@ -211,15 +208,26 @@ fn get_archived_files(set_up: &SetUp, command: &str) -> Vec<String> {
files
}
-// Faithful port, but blocked at runtime by the same look-ahead regex limitation as
-// test_manual_excludes: the finder applies .gitattributes export-ignore rules through
-// BaseExcludeFilter::generate_pattern, which builds `(?=$|/)` patterns the regex crate cannot
-// compile. It additionally requires a `git` executable (PHP guards with skipIfNotExecutable).
-#[ignore = "finder applies .gitattributes rules via BaseExcludeFilter::generate_pattern, whose \
- (?=$|/) look-ahead regexes the regex crate cannot compile (same blocker as \
- test_manual_excludes); also requires a git executable"]
+/// PHP's `skipIfNotExecutable('git')`.
+fn git_is_executable() -> bool {
+ Process::from_shell_commandline(
+ "git --version",
+ None,
+ None,
+ PhpMixed::Bool(false),
+ Some(60.0),
+ )
+ .and_then(|mut p| p.run(None, IndexMap::new()))
+ .map(|code| code == 0)
+ .unwrap_or(false)
+}
+
#[test]
fn test_git_excludes() {
+ if !git_is_executable() {
+ return;
+ }
+
let set_up = set_up();
file_put_contents(
diff --git a/crates/shirabe/tests/package/archiver/archive_manager_test.rs b/crates/shirabe/tests/package/archiver/archive_manager_test.rs
index 3db1e734..a7235bf9 100644
--- a/crates/shirabe/tests/package/archiver/archive_manager_test.rs
+++ b/crates/shirabe/tests/package/archiver/archive_manager_test.rs
@@ -167,7 +167,6 @@ fn test_unknown_format() {
// ref: ArchiveManagerTest::testArchiveTar / testArchiveCustomFileName.
#[test]
-#[ignore = "ArchiveManager::archive always passes buildExcludePatterns' glob excludes (e.g. 'name-*.zip'), which BaseExcludeFilter::generate_pattern turns into look-ahead regexes the regex crate cannot compile"]
fn test_archive_tar() {
if !git_is_executable() {
return;
@@ -204,7 +203,6 @@ fn test_archive_tar() {
}
#[test]
-#[ignore = "ArchiveManager::archive always passes buildExcludePatterns' glob excludes (e.g. 'name-*.zip'), which BaseExcludeFilter::generate_pattern turns into look-ahead regexes the regex crate cannot compile"]
fn test_archive_custom_file_name() {
if !git_is_executable() {
return;
diff --git a/crates/shirabe/tests/package/archiver/git_exclude_filter_test.rs b/crates/shirabe/tests/package/archiver/git_exclude_filter_test.rs
index ab1d6093..4fe3d331 100644
--- a/crates/shirabe/tests/package/archiver/git_exclude_filter_test.rs
+++ b/crates/shirabe/tests/package/archiver/git_exclude_filter_test.rs
@@ -16,7 +16,7 @@ fn provide_patterns() -> Vec<(&'static str, Option<(String, bool, bool)>)> {
(
"app/config/parameters.yml export-ignore",
Some((
- r"{(?=[^\.])app/(?=[^\.])config/(?=[^\.])parameters\.yml(?=$|/)}".to_string(),
+ r"{app/config/parameters\.yml(?:$|/)}".to_string(),
false,
false,
)),
@@ -24,7 +24,7 @@ fn provide_patterns() -> Vec<(&'static str, Option<(String, bool, bool)>)> {
(
"app/config/parameters.yml -export-ignore",
Some((
- r"{(?=[^\.])app/(?=[^\.])config/(?=[^\.])parameters\.yml(?=$|/)}".to_string(),
+ r"{app/config/parameters\.yml(?:$|/)}".to_string(),
true,
false,
)),
diff --git a/crates/shirabe/tests/package/archiver/phar_archiver_test.rs b/crates/shirabe/tests/package/archiver/phar_archiver_test.rs
index 39c5087a..7d879973 100644
--- a/crates/shirabe/tests/package/archiver/phar_archiver_test.rs
+++ b/crates/shirabe/tests/package/archiver/phar_archiver_test.rs
@@ -64,7 +64,6 @@ impl ArchiverTestCase {
}
}
-#[ignore = "the excludes passed here make BaseExcludeFilter::generate_pattern emit look-ahead regexes ((?=$|/) and Glob's (?=[^\\.])) that the regex crate cannot compile"]
#[test]
#[serial]
fn test_tar_archive() {