let state = {
script_name: pkg.name,
- is_tty: false,
output_queue: '',
fw4_restart: false,
};
let msg = join('', args);
if (level != null && (cfg.verbosity & level) == 0) return;
- // Print to stderr (terminal)
- if (state.is_tty)
- warn(replace(msg, /\\n/g, '\n'));
+ // Print to stderr (terminal / console)
+ warn(replace(msg, /\\n/g, '\n'));
// Queue for logger: flush on newline
if (index(msg, '\\n') >= 0 || index(msg, '\n') >= 0) {
// ── env.load_config ─────────────────────────────────────────────────
env.load_config = function() {
- if (state.is_tty == null)
- state.is_tty = system('[ -t 2 ]') == 0 ? true : false;
let raw = uci(pkg.name, true).get_all(pkg.name, 'config') || {};
cfg = parse_options(raw, config_schema);
env.dns_set_output_values(cfg.dns);
output.info('Starting ' + pkg.service_name + '...\\n');
output.verbose('[INIT] Starting ' + pkg.service_name + '...\\n');
status_data.status = 'statusStarting';
+ // Ensure cache/output directories exist (on_boot skips _setup_directories)
+ for (let f in [dns_output.file, dns_output.cache]) {
+ if (f) mkdir_p(dirname(f));
+ }
if (adb_file('test_gzip') && !adb_file('test_cache') && !adb_file('test')) {
output.info('Found compressed cache file, unpacking it ');
output.verbose('[INIT] Found compressed cache file, unpacking it ');
Test that check() correctly identifies blocked and unblocked domains.
-check() output goes to stderr via output.info/output.print when is_tty=true.
+check() output goes to stderr via output.info/output.print.
-- Testcase --
import adb from 'adblock-fast';
let ti = adb._test_internals;
-// Build the blocklist
+// Build the blocklist with verbosity=0 (from mock config) to suppress progress
adb.env.load_config();
ti.set_cfg('dns', 'dnsmasq.servers');
ti.set_cfg('dnsmasq_sanity_check', false);
ti.append_urls();
ti.download_lists();
-// Enable tty mode so output goes to stderr (captured by test framework)
-// Use verbosity=2 to get verbose output (which includes [PROC] prefix)
-ti.state.is_tty = true;
+// Set verbosity=2 for check() output, then call check() directly
+// (bypassing check()'s internal load_config() which would reset to 0)
ti.set_cfg('verbosity', 2);
-
-// Now test check()
+adb.env.load_config = function() {};
adb.check('ad.doubleclick.test.example.com this-domain-not-in-list.test.example.com');
-- End --