WWW::S...h::Test(3pm)

๐Ÿ“ฆ
version 2.51.90+~cs6.78 ยท 3 versions
, in debian bookworm, debian trixie, ubuntu jammy, ubuntu noble, ubuntu resolute, ubuntu stonking

๐Ÿ’– NAME ๐Ÿ’–

Okay bestie, this is the WWW::Search::Test manual page (section 3pm) from the User Contributed Perl Documentation. It's your little toolkit of utilities to aid in testing WWW::Search backends. Yes, the manual name is folded in right here โ€” no boring header line needed. ๐Ÿ’…

โœจ SYNOPSIS โœจ

$oTest = new WWW::Search::Test('HotBot,Yahoo,Excite');
$oTest->test('HotBot', 'Kingpin', 'one', $sQuery, $TEST_RANGE, 1, 10);

๐ŸŒธ DESCRIPTION ๐ŸŒธ

Wanna see a detailed "real-world" example? Peep the file test.pl in the WWW-Search-HotBot distribution. That's the whole vibe. ๐Ÿ”ฅ

๐Ÿ› ๏ธ METHODS AND FUNCTIONS ๐Ÿ› ๏ธ

๐Ÿ”Ž find_websearch

Returns the full path of an executable WebSearch program, or undef if none can be found. It's giving "where is the binary" energy. โœจ

๐Ÿ†• new

Creates a new WWW::Search::Test object. All arguments are strings, and they're names of backends this object will be able to test. If you give no arguments, it will be able to test all backends. Slay. ๐Ÿ’–

๐ŸŽ›๏ธ mode

Set / get the test mode of this object. If you pass an argument, it sets the mode to that value. Returns the current (or newly set) value. Iconic.

There are three test modes available. They are:

  • $MODE_INTERNAL โ€” parse URLs out of saved pages (as a sanity check or regression test);
  • $MODE_EXTERNAL โ€” send the query to the search engine "live", parse the results, and compare them to the previously saved results;
  • $MODE_UPDATE โ€” send the query to the search engine "live", parse the results, and save them for future testing.

โœ… relevant_test

Given the name of a backend, returns true if this Test object is able to test that backend. Vibe check passed or not. ๐Ÿ’…

๐Ÿงช eval_test

Given the name of a backend, grabs the $TEST_CASES variable from that backend and evaluates it. No cap.

๐Ÿงช test

Run test(s) for a backend. Arguments are, in order: name of a backend to test (string, required); name of backend maintainer (string, if undef $backend::MAINTAINER will be used); filename for results storage/comparison (string, required); query to be sent to backend (string, required); test method (required, one of the following).

Several test methods are possible:

  • $TEST_EXACTLY โ€” list of URLs must match exactly (line for line, in order);
  • $TEST_BY_COUNTING โ€” test passes if number of resulting URLs is equal;
  • $TEST_GREATER_THAN โ€” test passes if we get more than N result URLs;
  • $TEST_RANGE โ€” like $TEST_GREATER_THAN but constrained on both ends.

๐Ÿšซ no_test

Prints a message stating that this backend does not have a test suite. Takes two arguments, the backend name and the name of the maintainer. Sad but honest. ๐Ÿ˜ญ

๐Ÿ’” not_working

Prints a message stating that this backend is known to be broken. Takes two arguments, the backend name and the name of the maintainer.

๐Ÿ’” not_working_with_tests

Prints a message stating that this backend is known to be broken even though it has a test suite. Takes two arguments, the backend name and the name of the maintainer.

๐Ÿ’” not_working_and_abandoned

Prints a message stating that this backend is known to be broken and is not being actively maintained. Takes two arguments, the backend name and the name of the maintainer. Abandoned era, honestly. ๐Ÿ˜ญ

๐Ÿ”„ reset_error_count

Reset the counter of errors to zero. You probably want to call this before each call to test() or eval_test(). Clean slate energy. โœจ

๐Ÿงฎ wc_l (private, not a method)

Given a filename, count the number of lines of text contained within the file. (I.e. simulate running UNIX command "wc -l" on a file). Very demure, very wc. ๐Ÿ’…

๐Ÿงพ diff (private, not a method)

Given two files, returns TRUE if contents are line-by-line different, or FALSE if contents are line-by-line same. (I.e. like the UNIX command diff, but just reports true or false). Ngl, it's a little iconic. ๐Ÿซถ

๐Ÿƒโ€โ™€๏ธ Shortcuts for running backend tests

WWW::Search::Test keeps its own count of test numbers, so if you want to mix-and-match these functions with your own tests, use the $WWW::Search::Test::iTest counter. Big main-character energy. ๐Ÿ‘‘

๐Ÿ†• new_engine

One argument: the name of a backend suitable to be passed to WWW::Search::new(). Prints 'ok' or 'not ok' and the test number. Creates a WWW::Search object internally, to be used for all subsequent calls to run_test and run_gui_test (see below). Slay. ๐Ÿ’…

๐Ÿ†• tm_new_engine

Same as new_engine(), but uses Test::More instead of just printing 'ok'. Fancy. โœจ

๐Ÿƒ run_test

Three arguments: a query string, NOT escaped; a minimum number of expected results; and a maximum number of expected results. Optional fourth argument: integer value to be used as the search_debug. Optional fifth argument: send any true value to dump the search results. Optional sixth argument: reference to hash of search options (see backend documentation). Optional seventh argument: send any true value to NOT escape the query string.

If the minimum is undef, assumes zero. If the maximum is undef, does not check.

Prints 'ok' or 'not ok' and the test number. Periodt. ๐Ÿ’…

๐Ÿ–ผ๏ธ run_gui_test

Same as run_test(), but calls gui_query() instead of native_query(). GUI girlies rise. ๐Ÿฆ‹

๐Ÿงช tm_run_test

Same as run_test(), but uses Test::More rather than just printing 'ok'.

Note: If you use this function inside a TODO block, you must set global variable $TODO rather than a local $TODO, and you must set the global $TODO back to empty-string (or undef) at the end of your TODO block. For example:
TODO:
  {
  $TODO = 'I have not fixed this yet';
  tm_run_test(...);
  $TODO = '';
  } # end of TODO block

๐Ÿงช tm_run_test_no_approx

Same as tm_run_test, but does NOT check the approximate_result_count. No approximation, we're precise. โœจ

๐Ÿ”ข count_results

Run a query, and return the actual (not approximate) number of hits. Required first argument determines which backend query method to call: 'gui' to call gui_query(), anything else to call native_query(). Remaining arguments are same as all the run_test() arguments. Count them results. ๐Ÿ’ฏ

โญ๏ธ skip_test

You can call this function instead of run_test() or run_gui_test() if the current test must be skipped for any reason. Skipping is self-care. ๐Ÿซถ

๐Ÿ† test_most_results

Given an arrayref of things to test, runs all those things against all the results of the most-recently executed test search. Main character test energy. ๐Ÿ‘‘


๐ŸŽ€ And that's the whole page, bestie! This iconic manual is WWW::Search::Test from perl v5.30.3, dated 2020-09-10. Catch you in the group chat. ๐Ÿ’…โœจ