Skip to content

Commit dc63be8

Browse files
committed
Arrange to pass more tests on windows.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1937130 13f79535-47bb-0310-9956-ffa450edef68
1 parent 0b6fd62 commit dc63be8

8 files changed

Lines changed: 42 additions & 27 deletions

File tree

test/pytest_suite/apache_pytest/config.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,7 @@ def _getfiles_aliases(self) -> str:
588588
var = self._GETFILES_ALIASES[label]
589589
val = self.vars.get(var)
590590
if val:
591-
lines.append(f" Alias /getfiles-{label} {val}")
591+
lines.append(f' Alias /getfiles-{label} "{val}"')
592592
lines.append("</IfModule>")
593593
return "\n".join(lines)
594594

@@ -845,8 +845,10 @@ def generate(self, cmodule_loads: list[tuple[str, Path]] | None = None) -> Path:
845845
# Register the module in the modules set so <VirtualHost mod_X>
846846
# rewriting recognizes it (TestConfigC.pm:308 $self->{modules}{$cname}=1).
847847
self.info.modules.add(f"mod_{sym}.c")
848-
# so is <src_dir>/.libs/mod_<sym>.so; source is <src_dir>/mod_<sym>.c
848+
# so is <src_dir>/.libs/mod_<sym>.so (apxs) or <prefix>/modules/ (CMake).
849849
c_source = so.parent.parent / f"mod_{sym}.c"
850+
if not c_source.is_file():
851+
c_source = Path(self.vars["top_dir"]) / "c-modules" / sym / f"mod_{sym}.c"
850852
if c_source.is_file():
851853
self.add_module_config(c_source, cmodule_args)
852854
if cmodule_args:

test/pytest_suite/conftest.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -168,13 +168,11 @@ def _probed_info(config: pytest.Config) -> HttpdInfo | None:
168168
# fixture, so need_module("authany") etc. should be satisfied at collection
169169
# time too. Augment the probed set with the C modules that WILL be built
170170
# (honoring the same HTTPD_TEST_REQUIRE_APACHE gating discover() applies).
171-
# Without apxs the modules can't be compiled, so don't promise them.
172-
if _apxs is not None:
173-
from apache_pytest.cmodules import discover
171+
from apache_pytest.cmodules import discover
174172

175-
cmods, _skipped = discover(REPO_ROOT / "c-modules", info)
176-
for mod in cmods:
177-
info.modules.add(f"mod_{mod.name}.c")
173+
cmods, _skipped = discover(REPO_ROOT / "c-modules", info)
174+
for mod in cmods:
175+
info.modules.add(f"mod_{mod.name}.c")
178176
_probe_cache = info
179177
return _probe_cache
180178

@@ -263,6 +261,14 @@ def framework(request: pytest.FixtureRequest):
263261
cmodule_loads, _skipped = compile_all(
264262
cmodules_dir, apxs, info, defines=["APACHE2", "APACHE2_4", *defines]
265263
)
264+
else:
265+
from apache_pytest.cmodules import discover
266+
modules_dir = (install_prefix / "modules") if install_prefix else httpd.parent
267+
cmods, _skipped = discover(REPO_ROOT / "c-modules", info)
268+
for mod in cmods:
269+
so = modules_dir / f"mod_{mod.name}.so"
270+
if so.exists():
271+
cmodule_loads.append((mod.symbol, so))
266272

267273
config.generate(cmodule_loads=cmodule_loads)
268274

test/pytest_suite/t/conf/core.conf.in

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44

55
MaxMemFree 1
66

7+
<VirtualHost righthost:core>
8+
ServerName righthost
9+
ServerAlias Righthost 128.0.0.1
10+
</VirtualHost>
11+
712
<VirtualHost strict-default:core>
813
ServerName default-strict
914
<IfVersion >= 2.4.49>

test/pytest_suite/tests/t/apache/test_acceptpathinfo.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,10 @@ def _cases(http):
5959

6060
@need_module("include")
6161
@need_lwp()
62-
@pytest.mark.skipif(sys.platform == "win32", reason="uses shell CGI scripts")
6362
def test_acceptpathinfo(http):
6463
for mode, req, exp_rc, exp_body in _cases(http):
64+
if "/test.sh" in req and sys.platform == "win32":
65+
continue
6566
# Apache::TestRequest's GET follows redirects by default; the bare
6667
# directory request 301-redirects to add a trailing slash before the
6768
# index.shtml (which echoes PATH_INFO) is served.

test/pytest_suite/tests/t/apache/test_mmn.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,14 @@
2020
@need_min_apache_version("2")
2121
def test_mmn(http):
2222
incdir = http.apxs("INCLUDEDIR")
23-
if not incdir:
24-
pytest.skip("apxs INCLUDEDIR unavailable")
25-
filename = os.path.join(incdir, "ap_mmn.h")
26-
if not os.path.isfile(filename):
27-
pytest.skip(f"can't read {filename}")
23+
filename = os.path.join(incdir, "ap_mmn.h") if incdir else None
24+
if not filename or not os.path.isfile(filename):
25+
# Fall back to the source tree include/ directory.
26+
src_inc = os.path.join(http.vars("top_dir"), "..", "..", "include", "ap_mmn.h")
27+
if os.path.isfile(src_inc):
28+
filename = src_inc
29+
else:
30+
pytest.skip("ap_mmn.h not found (no apxs and not in source tree)")
2831

2932
cmajor = cminor = major = minor = None
3033
with open(filename) as fh:

test/pytest_suite/tests/t/modules/test_ratelimit.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,15 @@
1717
from apache_pytest import need_min_apache_version, need_module, t_cmp
1818

1919
CASES = [
20-
("/apache/ratelimit/", 200, "ratelimited small file", False),
21-
("/apache/ratelimit/autoindex/", 200, "ratelimited small autoindex output", False),
22-
("/apache/ratelimit/chunk?0,8192", 200, "ratelimited chunked response", True),
20+
("/apache/ratelimit/", 200, "ratelimited small file"),
21+
("/apache/ratelimit/autoindex/", 200, "ratelimited small autoindex output"),
22+
("/apache/ratelimit/chunk?0,8192", 200, "ratelimited chunked response"),
2323
]
2424

2525

2626
@need_module("ratelimit", "autoindex")
2727
@need_min_apache_version("2.4.35")
28-
@pytest.mark.parametrize("url,code,desc,needs_cmod", CASES, ids=[c[2] for c in CASES])
29-
def test_ratelimit(http, url, code, desc, needs_cmod):
30-
if needs_cmod and not http.have_module("random_chunk"):
31-
pytest.skip("random_chunk C test module not available")
28+
@pytest.mark.parametrize("url,code,desc", CASES, ids=[c[2] for c in CASES])
29+
def test_ratelimit(http, url, code, desc):
3230
r = http.GET(url)
3331
assert t_cmp(r.status_code, code), desc

test/pytest_suite/tests/t/modules/test_substitute.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,16 +68,16 @@ def _docroot_file(http, *parts):
6868

6969

7070
def _write_testfile(http, content):
71-
with open(_docroot_file(http, "test.txt"), "w") as f:
72-
f.write(content)
71+
with open(_docroot_file(http, "test.txt"), "wb") as f:
72+
f.write(content.encode("utf-8"))
7373

7474

7575
def _write_htaccess(http, rules):
7676
content = "SetOutputFilter BUCKETEER;SUBSTITUTE\n"
7777
for rule in rules:
7878
content += f"Substitute {rule}\n"
79-
with open(_docroot_file(http, ".htaccess"), "w") as f:
80-
f.write(content)
79+
with open(_docroot_file(http, ".htaccess"), "wb") as f:
80+
f.write(content.encode("utf-8"))
8181

8282

8383
def _httpd_rule_to_python(content, rule):

test/pytest_suite/tests/test_framework_smoke.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ def test_cmodule_compiled_and_loaded(config) -> None:
3939
config.vars["t_conf_file"]
4040
and open(config.vars["t_conf_file"]).read() # noqa: SIM115
4141
)
42-
if "LoadModule echo_post_module" not in conf_text:
43-
pytest.skip("C test modules not compiled (no --apxs)")
42+
assert "LoadModule echo_post_module" in conf_text
43+
# echo_post.c registers the echo_post handler; the module is now in scope.
4444
assert config.info.has_module("mod_echo_post") or "echo_post" in conf_text
4545

4646

0 commit comments

Comments
 (0)