47 lines
2.6 KiB
Python
Executable File
47 lines
2.6 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""0.31.9 source-only regression; does NOT claim Rust compilation or memory profiling."""
|
|
from pathlib import Path
|
|
import json
|
|
import re
|
|
import tomllib
|
|
from html.parser import HTMLParser
|
|
|
|
ROOT = Path(__file__).resolve().parents[2]
|
|
def read(rel): return (ROOT / rel).read_text(encoding='utf-8')
|
|
assert tomllib.loads(read('Cargo.toml'))['package']['version'] == '0.32.2'
|
|
assert 'name = "rust-proxy"\nversion = "0.32.2"' in read('Cargo.lock')
|
|
assert json.loads(read('src/admin/openapi.json'))['info']['version'] == '0.32.2'
|
|
|
|
pages = read('src/pages.rs')
|
|
for code in (400, 401, 403, 404, 408, 410, 413, 429, 500, 502, 503, 504):
|
|
file = f'src/admin/web/error_{code}.html'
|
|
markup = read(file)
|
|
assert markup.lstrip().startswith('<!doctype html>'), file
|
|
assert 'background: #131615' in markup and 'max-width: 620px' in markup, file
|
|
assert re.search(rf'<h1>{code} - [^<]+</h1>', markup), file
|
|
assert f'include_str!("admin/web/error_{code}.html")' in pages, file
|
|
assert 'status_200.html' in pages and '<h1>200 - OK</h1>' in read('src/admin/web/status_200.html')
|
|
assert 'RustProxy generated this response.' in pages and 'background: #131615' in pages
|
|
assert 'matches!(status, StatusCode::NO_CONTENT | StatusCode::RESET_CONTENT | StatusCode::NOT_MODIFIED)' in pages
|
|
|
|
geoip = read('src/geoip.rs')
|
|
assert 'ipv4: Box<[V4Range]>, ipv6: Box<[V6Range]>' in geoip
|
|
assert 'ipv4.into_boxed_slice()' in geoip and 'ipv6.into_boxed_slice()' in geoip
|
|
assert 'start: [u8; 16]' in geoip and 'end: [u8; 16]' in geoip
|
|
assert 'u128::from(ip).to_be_bytes()' in geoip and 'ip <= item.end' in geoip
|
|
assert 'size_of::<V6Range>(), 34' in read('src/geoip/tests.rs')
|
|
|
|
cached = read('src/cache/fill.rs') + read('src/cache/lookup/tiered.rs')
|
|
for marker in ('bytes.try_into_mut()', 'mutable.capacity()', 'candidate.shared = Some(bytes.clone())',
|
|
'shared_allocated', 'candidate.fill_gauge.grow(allocation', 'if transformed { 0 }',
|
|
'candidate.data.extend_from_slice(data)'):
|
|
assert marker in cached, marker
|
|
|
|
q = read('src/admin/file_logs.rs') + read('src/admin/file_logs_query.rs')
|
|
for marker in ('sort_by: Option<String>', 'sort_descending: Option<bool>', 'valid_raw_field_key(field)',
|
|
'fn sort_file_log_records(', 'stored_log_sort_key(&record, field)',
|
|
'file_log_field(record, field)', 'None, Some(_)', 'sort_file_log_records(&mut records'):
|
|
assert marker in q, marker
|
|
assert q.index('sort_file_log_records(&mut records') < q.index('let page = records')
|
|
print('PASS: 0.31.9 versions, 13 matching HTML pages, GeoIP packed/boxed sources, cache ownership/accounting and bounded server sorting (static only).')
|