Made vigil into a package with a setup.py file.
This commit is contained in:
parent
49f8d87659
commit
5728e5cff3
135 changed files with 76 additions and 50 deletions
247
tests/__main___test.py
Executable file
247
tests/__main___test.py
Executable file
|
|
@ -0,0 +1,247 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
# Copyright (C) 2015-2017 Andrew Hamilton. All rights reserved.
|
||||
# Licensed under the Artistic License 2.0.
|
||||
|
||||
import asyncio
|
||||
import contextlib
|
||||
import io
|
||||
import os
|
||||
import shutil
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
os.environ["TERM"] = "xterm-256color"
|
||||
|
||||
import vigil.fill3 as fill3
|
||||
import vigil.golden as golden
|
||||
import vigil.__main__ as __main__
|
||||
|
||||
|
||||
_DIMENSIONS = (100, 60)
|
||||
|
||||
|
||||
def _widget_to_string(widget, dimensions=_DIMENSIONS):
|
||||
appearance = (widget.appearance_min() if dimensions is None
|
||||
else widget.appearance(dimensions))
|
||||
return str(fill3.join("\n", appearance))
|
||||
|
||||
|
||||
def _touch(path):
|
||||
open(path, "w").close()
|
||||
|
||||
|
||||
def _assert_widget_appearance(widget, golden_path, dimensions=_DIMENSIONS):
|
||||
golden_path_absolute = os.path.join(os.path.dirname(__file__), golden_path)
|
||||
golden.assertGolden(_widget_to_string(widget, dimensions),
|
||||
golden_path_absolute)
|
||||
|
||||
|
||||
class _MockMainLoop:
|
||||
|
||||
def add_reader(self, foo, bar):
|
||||
pass
|
||||
|
||||
|
||||
class ScreenWidgetTestCase(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.temp_dir = tempfile.mkdtemp()
|
||||
foo_path = os.path.join(self.temp_dir, "foo.py")
|
||||
_touch(foo_path)
|
||||
jobs_added_event = asyncio.Event()
|
||||
appearance_changed_event = asyncio.Event()
|
||||
summary = __main__.Summary(self.temp_dir, jobs_added_event)
|
||||
log = __main__.Log(appearance_changed_event)
|
||||
self.main_widget = __main__.Screen(summary, log, appearance_changed_event,
|
||||
_MockMainLoop())
|
||||
|
||||
def tearDown(self):
|
||||
shutil.rmtree(self.temp_dir)
|
||||
|
||||
# def test_initial_appearance(self):
|
||||
# _assert_widget_appearance(self.main_widget, "golden-files/initial")
|
||||
|
||||
def test_help_appearance(self):
|
||||
self.main_widget.toggle_help()
|
||||
_assert_widget_appearance(self.main_widget, "golden-files/help")
|
||||
|
||||
# def test_log_appearance(self):
|
||||
# log_shown = _widget_to_string(self.main_widget)
|
||||
# self.main_widget.toggle_log()
|
||||
# log_hidden = _widget_to_string(self.main_widget)
|
||||
# actual = "shown:\n%s\nhidden:\n%s" % (log_shown, log_hidden)
|
||||
# golden.assertGolden(actual, "golden-files/log")
|
||||
|
||||
# def test_window_orientation(self):
|
||||
# window_left_right = _widget_to_string(self.main_widget)
|
||||
# self.main_widget.toggle_window_orientation()
|
||||
# window_top_bottom = _widget_to_string(self.main_widget)
|
||||
# actual = ("left-right:\n%s\ntop-bottom:\n%s" %
|
||||
# (window_left_right, window_top_bottom))
|
||||
# golden.assertGolden(actual, "golden-files/window-orientation")
|
||||
|
||||
|
||||
class SummaryCursorTest(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.original_method = __main__.Summary.sync_with_filesystem
|
||||
__main__.Summary.sync_with_filesystem = lambda foo: None
|
||||
self.summary = __main__.Summary(None, None)
|
||||
self.summary._column = [[1, 1, 1], [1, 1], [1, 1, 1]]
|
||||
|
||||
def tearDown(self):
|
||||
__main__.Summary.sync_with_filesystem = self.original_method
|
||||
|
||||
def _assert_movements(self, movements):
|
||||
for movement, expected_position in movements:
|
||||
movement()
|
||||
self.assertEqual(self.summary.cursor_position(), expected_position)
|
||||
|
||||
def test_cursor_movement(self):
|
||||
self.assertEqual(self.summary.cursor_position(), (0, 0))
|
||||
self._assert_movements([(self.summary.cursor_right, (1, 0)),
|
||||
(self.summary.cursor_down, (1, 1)),
|
||||
(self.summary.cursor_left, (0, 1)),
|
||||
(self.summary.cursor_up, (0, 0))])
|
||||
|
||||
def test_cursor_wrapping(self):
|
||||
self._assert_movements([(self.summary.cursor_up, (0, 2)),
|
||||
(self.summary.cursor_down, (0, 0)),
|
||||
(self.summary.cursor_left, (2, 0)),
|
||||
(self.summary.cursor_right, (0, 0))])
|
||||
|
||||
def test_cursor_moving_between_different_sized_rows(self):
|
||||
self.summary._cursor_position = (2, 0)
|
||||
self._assert_movements([(self.summary.cursor_down, (1, 1)),
|
||||
(self.summary.cursor_down, (2, 2))])
|
||||
|
||||
|
||||
class SummarySyncWithFilesystem(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.temp_dir = tempfile.mkdtemp()
|
||||
self.foo_path = os.path.join(self.temp_dir, "foo")
|
||||
self.bar_path = os.path.join(self.temp_dir, "bar")
|
||||
self.zoo_path = os.path.join(self.temp_dir, "zoo")
|
||||
_touch(self.foo_path)
|
||||
_touch(self.bar_path)
|
||||
self.jobs_added_event = asyncio.Event()
|
||||
self.appearance_changed_event = asyncio.Event()
|
||||
self.summary = __main__.Summary(self.temp_dir, self.jobs_added_event)
|
||||
self.jobs_added_event.clear()
|
||||
|
||||
def tearDown(self):
|
||||
shutil.rmtree(self.temp_dir)
|
||||
|
||||
def _assert_paths(self, expected_paths):
|
||||
actual_paths = [entry[0].path for entry in self.summary._column]
|
||||
self.assertEqual(actual_paths, expected_paths)
|
||||
|
||||
def test_summary_initial_state(self):
|
||||
self._assert_paths(["./bar", "./foo"])
|
||||
self.assertFalse(self.jobs_added_event.is_set())
|
||||
|
||||
def test_sync_removed_file(self):
|
||||
os.remove(self.foo_path)
|
||||
self._assert_paths(["./bar", "./foo"])
|
||||
self.summary.sync_with_filesystem()
|
||||
self._assert_paths(["./bar"])
|
||||
self.assertFalse(self.jobs_added_event.is_set())
|
||||
|
||||
def test_sync_added_file(self):
|
||||
_touch(self.zoo_path)
|
||||
self.summary.sync_with_filesystem()
|
||||
self._assert_paths(["./bar", "./foo", "./zoo"])
|
||||
self.assertTrue(self.jobs_added_event.is_set())
|
||||
|
||||
# def test_sync_changed_file_metadata(self):
|
||||
# ids_before = [id(entry) for entry in self.summary._column]
|
||||
# time.sleep(1)
|
||||
# _touch(self.foo_path)
|
||||
# self.summary.sync_with_filesystem()
|
||||
# ids_after = [id(entry) for entry in self.summary._column]
|
||||
# self.assertTrue(ids_before[0] == ids_after[0]) # bar
|
||||
# self.assertTrue(ids_before[1] != ids_after[1]) # foo
|
||||
# self.assertTrue(self.jobs_added_event.is_set())
|
||||
|
||||
# def test_sync_same_objects(self):
|
||||
# ids_before = [id(entry) for entry in self.summary._column]
|
||||
# self.summary.sync_with_filesystem()
|
||||
# ids_after = [id(entry) for entry in self.summary._column]
|
||||
# self.assertTrue(ids_before == ids_after)
|
||||
# self.assertFalse(self.jobs_added_event.is_set())
|
||||
|
||||
def test_sync_linked_files(self):
|
||||
"""Symbolic and hard-linked files are given distinct entry objects"""
|
||||
baz_path = os.path.join(self.temp_dir, "baz")
|
||||
os.symlink(self.foo_path, baz_path)
|
||||
os.link(self.foo_path, self.zoo_path)
|
||||
self.summary.sync_with_filesystem()
|
||||
self._assert_paths(["./bar", "./baz", "./foo", "./zoo"])
|
||||
self.assertTrue(id(self.summary._column[1]) != # baz
|
||||
id(self.summary._column[2])) # foo
|
||||
self.assertTrue(id(self.summary._column[2]) != # foo
|
||||
id(self.summary._column[3])) # zoo
|
||||
self.assertTrue(self.jobs_added_event.is_set())
|
||||
|
||||
|
||||
# class LogTestCase(unittest.TestCase):
|
||||
|
||||
# def test_log(self):
|
||||
# appearance_changed_event = asyncio.Event()
|
||||
# log = __main__.Log(appearance_changed_event)
|
||||
# _assert_widget_appearance(log, "golden-files/log-initial", None)
|
||||
# timestamp = "11:11:11"
|
||||
# self.assertFalse(appearance_changed_event.is_set())
|
||||
# log.log_message("foo", timestamp=timestamp)
|
||||
# self.assertTrue(appearance_changed_event.is_set())
|
||||
# _assert_widget_appearance(log, "golden-files/log-one-message", None)
|
||||
# log.log_message("bar", timestamp=timestamp)
|
||||
# _assert_widget_appearance(log, "golden-files/log-two-messages", None)
|
||||
# _assert_widget_appearance(log, "golden-files/log-appearance")
|
||||
|
||||
|
||||
def _mount_total():
|
||||
with open("/proc/mounts") as proc_mounts:
|
||||
return len(proc_mounts.readlines())
|
||||
|
||||
|
||||
def _tmp_total():
|
||||
return len(os.listdir("/tmp"))
|
||||
|
||||
|
||||
class MainTestCase(unittest.TestCase):
|
||||
|
||||
def test_main_and_restart_and_no_leaks_and_is_relocatable(self):
|
||||
def test_run(root_path, loop):
|
||||
mount_total = _mount_total()
|
||||
# tmp_total = _tmp_total()
|
||||
foo_path = os.path.join(root_path, "foo")
|
||||
open(foo_path, "w").close()
|
||||
__main__.manage_cache(root_path)
|
||||
with __main__.chdir(root_path):
|
||||
with contextlib.redirect_stdout(io.StringIO()):
|
||||
__main__.main(root_path, loop, worker_count=2,
|
||||
is_being_tested=True)
|
||||
for file_name in ["summary.pickle", "creation_time", "log",
|
||||
"foo-metadata", "foo-contents"]:
|
||||
self.assertTrue(os.path.exists(".vigil/" + file_name))
|
||||
self.assertEqual(_mount_total(), mount_total)
|
||||
# self.assertEqual(_tmp_total(), tmp_total)
|
||||
temp_dir = tempfile.mkdtemp()
|
||||
try:
|
||||
loop = asyncio.get_event_loop()
|
||||
first_dir = os.path.join(temp_dir, "first")
|
||||
os.mkdir(first_dir)
|
||||
test_run(first_dir, loop)
|
||||
second_dir = os.path.join(temp_dir, "second")
|
||||
os.rename(first_dir, second_dir)
|
||||
test_run(second_dir, loop)
|
||||
loop.close()
|
||||
finally:
|
||||
shutil.rmtree(temp_dir)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
golden.main()
|
||||
117
tests/fill3_test.py
Executable file
117
tests/fill3_test.py
Executable file
|
|
@ -0,0 +1,117 @@
|
|||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright (C) 2015-2017 Andrew Hamilton. All rights reserved.
|
||||
# Licensed under the Artistic License 2.0.
|
||||
|
||||
import unittest
|
||||
|
||||
import vigil.fill3 as fill3
|
||||
|
||||
|
||||
class WidgetTests(unittest.TestCase):
|
||||
|
||||
TEXT_A = fill3.Text("A")
|
||||
TEXT_B = fill3.Text("B")
|
||||
|
||||
def assert_string(self, appearance, expected_string):
|
||||
self.assertEqual(str(fill3.join("\n", appearance)), expected_string)
|
||||
|
||||
def test_rows_widget(self):
|
||||
rows = fill3.Row([self.TEXT_A, self.TEXT_B])
|
||||
self.assert_string(rows.appearance_min(), "AB")
|
||||
rows = fill3.Row([fill3.Filler(self.TEXT_A),
|
||||
fill3.Filler(self.TEXT_B)])
|
||||
self.assert_string(rows.appearance((4, 1)), "A B ")
|
||||
|
||||
def test_columns_widget(self):
|
||||
columns = fill3.Column([self.TEXT_A, self.TEXT_B])
|
||||
self.assert_string(columns.appearance_min(), "A\n"
|
||||
"B")
|
||||
|
||||
def test_text_widget(self):
|
||||
self.assert_string(self.TEXT_A.appearance_min(), "A")
|
||||
text = "foo\nbar"
|
||||
self.assert_string(fill3.Text(text).appearance_min(), "foo\n"
|
||||
"bar")
|
||||
|
||||
def test_portal_widget(self):
|
||||
row = fill3.Row([fill3.Text("foo"), fill3.Text("bar")])
|
||||
portal = fill3.Portal(row, (1, 0))
|
||||
self.assert_string(portal.appearance((5, 1)), "oobar")
|
||||
portal.position = (0, 10)
|
||||
self.assert_string(portal.appearance((1, 1)), " ")
|
||||
|
||||
def test_border_widget(self):
|
||||
contents = fill3.Filler(self.TEXT_A)
|
||||
self.assert_string(fill3.Border(contents).appearance((3, 3)), "┌─┐\n"
|
||||
"│A│\n"
|
||||
"└─┘")
|
||||
for empty_contents in [fill3.Filler(fill3.Text("")), fill3.Column([])]:
|
||||
self.assert_string(fill3.Border(empty_contents).appearance((2, 2)),
|
||||
"┌┐\n"
|
||||
"└┘")
|
||||
self.assert_string(fill3.Border(fill3.Column([])).appearance_min(),
|
||||
"┌┐\n"
|
||||
"└┘")
|
||||
self.assert_string(fill3.Border(empty_contents).appearance((3, 3)),
|
||||
"┌─┐\n"
|
||||
"│ │\n"
|
||||
"└─┘")
|
||||
text = fill3.Text("abcdef")
|
||||
self.assert_string(fill3.Border(text, title="AB").appearance((8, 3)),
|
||||
"┌─ AB ─┐\n"
|
||||
"│abcdef│\n"
|
||||
"└──────┘")
|
||||
|
||||
def test_placeholder_widget(self):
|
||||
placeholder = fill3.Placeholder(self.TEXT_A)
|
||||
self.assert_string(placeholder.appearance_min(), "A")
|
||||
placeholder.widget = self.TEXT_B
|
||||
self.assert_string(placeholder.appearance_min(), "B")
|
||||
|
||||
def test_scroll_bar(self):
|
||||
scroll_bar = fill3.ScrollBar(is_horizontal=True, bar_char="#")
|
||||
self.assertEqual(scroll_bar.interval, (0, 0))
|
||||
self.assert_string(scroll_bar.appearance((1, 1)), "#")
|
||||
scroll_bar.interval = (0, 0.5)
|
||||
self.assert_string(scroll_bar.appearance((2, 1)), "# ")
|
||||
scroll_bar.interval = (0, 0.1)
|
||||
self.assert_string(scroll_bar.appearance((2, 1)), "# ")
|
||||
scroll_bar.interval = (0.25, 0.75)
|
||||
self.assert_string(scroll_bar.appearance((4, 1)), " ## ")
|
||||
scroll_bar = fill3.ScrollBar(is_horizontal=False, bar_char="#")
|
||||
self.assertEqual(scroll_bar.interval, (0, 0))
|
||||
self.assert_string(scroll_bar.appearance((1, 1)), "#")
|
||||
scroll_bar.interval = (0, 0.5)
|
||||
self.assert_string(scroll_bar.appearance((1, 2)), "#\n"
|
||||
" ")
|
||||
scroll_bar.interval = (0, 0.1)
|
||||
self.assert_string(scroll_bar.appearance((1, 2)), "#\n"
|
||||
" ")
|
||||
scroll_bar.interval = (0.25, 0.75)
|
||||
self.assert_string(scroll_bar.appearance((1, 4)), " \n"
|
||||
"#\n"
|
||||
"#\n"
|
||||
" ")
|
||||
|
||||
def test_table_widget(self):
|
||||
table = fill3.Table([])
|
||||
self.assert_string(table.appearance_min(), "")
|
||||
table = fill3.Table([[self.TEXT_A]])
|
||||
self.assert_string(table.appearance_min(), "A")
|
||||
table = fill3.Table([[self.TEXT_A, self.TEXT_B]])
|
||||
self.assert_string(table.appearance_min(), "AB")
|
||||
table = fill3.Table([[self.TEXT_A, self.TEXT_B],
|
||||
[self.TEXT_B, self.TEXT_A]])
|
||||
self.assert_string(table.appearance_min(), "AB\n"
|
||||
"BA")
|
||||
label_foo = fill3.Text("FOO")
|
||||
table = fill3.Table([[label_foo, self.TEXT_B],
|
||||
[self.TEXT_B, self.TEXT_A]])
|
||||
self.assert_string(table.appearance_min(), "FOOB\n"
|
||||
"B A")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
60
tests/golden-files/help
Normal file
60
tests/golden-files/help
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
(B[m[38;2;255;255;255m[48;2;0;0;0m┌────────────────────────────────────────────── Help ──────────────────────────────────────────────┐
|
||||
│Vigil Code Monitor │
|
||||
│ │
|
||||
│Vigil maintains an up-to-date set of reports for every file in a codebase. │
|
||||
│ │
|
||||
│A status indicator summarises the state of each report, and a report is viewed │
|
||||
│by selecting this status indicator with the cursor. │
|
||||
│ │
|
||||
│The reports are cached in the codebase's root directory in a ".vigil" │
|
||||
│directory. │
|
||||
│ │
|
||||
│Keys: │
|
||||
│ arrow keys, page up/down, mouse - Move the cursor or scroll the result pane. │
|
||||
│ tab - Change the focus between summary and result pane. │
|
||||
│ (B[m[38;2;0;255;0m[48;2;0;0;0mh(B[m[38;2;255;255;255m[48;2;0;0;0m - Show the help screen. (toggle) │
|
||||
│ (B[m[38;2;0;255;0m[48;2;0;0;0mq(B[m[38;2;255;255;255m[48;2;0;0;0m - Quit. │
|
||||
│ (B[m[38;2;0;255;0m[48;2;0;0;0mt(B[m[38;2;255;255;255m[48;2;0;0;0m - Turn the result pane to portrait or landscape orientation. (toggle) │
|
||||
│ (B[m[38;2;0;255;0m[48;2;0;0;0ml(B[m[38;2;255;255;255m[48;2;0;0;0m - Show the activity log. (toggle) │
|
||||
│ (B[m[38;2;0;255;0m[48;2;0;0;0me(B[m[38;2;255;255;255m[48;2;0;0;0m - Edit the current file with an editor defined by -e, $EDITOR or $VISUAL. │
|
||||
│ (B[m[38;2;0;255;0m[48;2;0;0;0mn(B[m[38;2;255;255;255m[48;2;0;0;0m - Move to the next issue. │
|
||||
│ (B[m[38;2;0;255;0m[48;2;0;0;0mN(B[m[38;2;255;255;255m[48;2;0;0;0m - Move to the next issue of the current tool. │
|
||||
│ (B[m[38;2;0;255;0m[48;2;0;0;0mp(B[m[38;2;255;255;255m[48;2;0;0;0m - Pause workers. (toggle) │
|
||||
│ (B[m[38;2;0;255;0m[48;2;0;0;0mo(B[m[38;2;255;255;255m[48;2;0;0;0m - Order files by type, or by directory location. (toggle) │
|
||||
│ (B[m[38;2;0;255;0m[48;2;0;0;0mr(B[m[38;2;255;255;255m[48;2;0;0;0m - Refresh the currently selected report. │
|
||||
│ (B[m[38;2;0;255;0m[48;2;0;0;0mf(B[m[38;2;255;255;255m[48;2;0;0;0m - Resize the focused pane to the full screen. (toggle) │
|
||||
│ │
|
||||
│Statuses: │
|
||||
│ (B[m[38;2;255;255;255m[48;2;255;255;255m (B[m[38;2;255;255;255m[48;2;0;0;0m Normal │
|
||||
│ (B[m[38;2;255;255;255m[48;2;0;255;0m (B[m[38;2;255;255;255m[48;2;0;0;0m Ok │
|
||||
│ (B[m[38;2;255;255;255m[48;2;255;0;0m (B[m[38;2;255;255;255m[48;2;0;0;0m Problem │
|
||||
│ (B[m[38;2;255;255;255m[48;2;100;100;100m (B[m[38;2;255;255;255m[48;2;0;0;0m Not applicable │
|
||||
│ (B[m[38;2;255;255;255m[48;2;90;90;255m (B[m[38;2;255;255;255m[48;2;0;0;0m Running │
|
||||
│ (B[m[38;2;255;255;255m[48;2;255;255;0m (B[m[38;2;255;255;255m[48;2;0;0;0m Paused │
|
||||
│ (B[m[38;2;255;255;255m[48;2;200;0;200m (B[m[38;2;255;255;255m[48;2;0;0;0m Timed out │
|
||||
│ . Pending │
|
||||
│ (B[m[38;2;255;255;255m[48;2;255;0;0mE(B[m[38;2;255;255;255m[48;2;0;0;0m Error │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
└──────────────────────────────────────────────────────────────────────────────────────────────────┘(B[m
|
||||
20
tests/golden-files/initial
Normal file
20
tests/golden-files/initial
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
(B[m[38;2;255;255;255m[48;2;0;0;0m┌──── Summary ─────┐┌ foo.py ─── (B[m[38;2;0;0;255m[48;2;0;0;0mmetada(B[m[38;2;255;255;255m[48;2;0;0;0m┐
|
||||
│(B[m[38;2;0;0;0m[48;2;255;255;255m. (B[m[38;2;255;255;255m[48;2;70;70;70m. . . . .(B[m[38;2;255;255;255m[48;2;0;0;0m││? │
|
||||
│ ││ │
|
||||
│ ││ │
|
||||
│ ││ │
|
||||
│ ││ │
|
||||
│ ││ │
|
||||
│ ││ │
|
||||
│(B[m[38;2;255;255;255m[48;2;100;100;100m (B[m[38;2;255;255;255m[48;2;0;0;0m ││ │
|
||||
└──────────────────┘│ │
|
||||
┌── Activity log ──┐│ │
|
||||
│ ││ │
|
||||
│ ││ │
|
||||
│ ││ │
|
||||
│ ││ │
|
||||
│ ││ │
|
||||
│ ││ │
|
||||
│ ││ │
|
||||
│ ││ │
|
||||
└──────────────────┘└──────────────────┘[0m
|
||||
BIN
tests/golden-files/input/Mcrt1.o
Normal file
BIN
tests/golden-files/input/Mcrt1.o
Normal file
Binary file not shown.
BIN
tests/golden-files/input/circle.bmp
Normal file
BIN
tests/golden-files/input/circle.bmp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
BIN
tests/golden-files/input/circle.gif
Normal file
BIN
tests/golden-files/input/circle.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 108 B |
BIN
tests/golden-files/input/circle.jpg
Normal file
BIN
tests/golden-files/input/circle.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 381 B |
BIN
tests/golden-files/input/circle.png
Normal file
BIN
tests/golden-files/input/circle.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 320 B |
BIN
tests/golden-files/input/circle.ppm
Normal file
BIN
tests/golden-files/input/circle.ppm
Normal file
Binary file not shown.
BIN
tests/golden-files/input/circle.tga
Normal file
BIN
tests/golden-files/input/circle.tga
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1 KiB |
BIN
tests/golden-files/input/circle.tiff
Normal file
BIN
tests/golden-files/input/circle.tiff
Normal file
Binary file not shown.
197
tests/golden-files/input/clojure-util.java
Normal file
197
tests/golden-files/input/clojure-util.java
Normal file
|
|
@ -0,0 +1,197 @@
|
|||
/**
|
||||
* Copyright (c) Rich Hickey. All rights reserved.
|
||||
* The use and distribution terms for this software are covered by the
|
||||
* Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
|
||||
* which can be found in the file epl-v10.html at the root of this distribution.
|
||||
* By using this software in any fashion, you are agreeing to be bound by
|
||||
* the terms of this license.
|
||||
* You must not remove this notice, or any other, from this software.
|
||||
**/
|
||||
|
||||
/* rich Apr 19, 2008 */
|
||||
|
||||
package clojure.lang;
|
||||
|
||||
import java.lang.ref.Reference;
|
||||
import java.math.BigInteger;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.lang.ref.SoftReference;
|
||||
import java.lang.ref.ReferenceQueue;
|
||||
|
||||
public class Util{
|
||||
static public boolean equiv(Object k1, Object k2){
|
||||
if(k1 == k2)
|
||||
return true;
|
||||
if(k1 != null)
|
||||
{
|
||||
if(k1 instanceof Number && k2 instanceof Number)
|
||||
return Numbers.equal((Number)k1, (Number)k2);
|
||||
else if(k1 instanceof IPersistentCollection || k2 instanceof IPersistentCollection)
|
||||
return pcequiv(k1,k2);
|
||||
return k1.equals(k2);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static public boolean equiv(long k1, long k2){
|
||||
return k1 == k2;
|
||||
}
|
||||
|
||||
static public boolean equiv(Object k1, long k2){
|
||||
return equiv(k1, (Object)k2);
|
||||
}
|
||||
|
||||
static public boolean equiv(long k1, Object k2){
|
||||
return equiv((Object)k1, k2);
|
||||
}
|
||||
|
||||
static public boolean equiv(double k1, double k2){
|
||||
return k1 == k2;
|
||||
}
|
||||
|
||||
static public boolean equiv(Object k1, double k2){
|
||||
return equiv(k1, (Object)k2);
|
||||
}
|
||||
|
||||
static public boolean equiv(double k1, Object k2){
|
||||
return equiv((Object)k1, k2);
|
||||
}
|
||||
|
||||
static public boolean equiv(boolean k1, boolean k2){
|
||||
return k1 == k2;
|
||||
}
|
||||
|
||||
static public boolean equiv(Object k1, boolean k2){
|
||||
return equiv(k1, (Object)k2);
|
||||
}
|
||||
|
||||
static public boolean equiv(boolean k1, Object k2){
|
||||
return equiv((Object)k1, k2);
|
||||
}
|
||||
|
||||
static public boolean equiv(char c1, char c2) {
|
||||
return c1 == c2;
|
||||
}
|
||||
|
||||
static public boolean pcequiv(Object k1, Object k2){
|
||||
if(k1 instanceof IPersistentCollection)
|
||||
return ((IPersistentCollection)k1).equiv(k2);
|
||||
return ((IPersistentCollection)k2).equiv(k1);
|
||||
}
|
||||
|
||||
static public boolean equals(Object k1, Object k2){
|
||||
if(k1 == k2)
|
||||
return true;
|
||||
return k1 != null && k1.equals(k2);
|
||||
}
|
||||
|
||||
static public boolean identical(Object k1, Object k2){
|
||||
return k1 == k2;
|
||||
}
|
||||
|
||||
static public Class classOf(Object x){
|
||||
if(x != null)
|
||||
return x.getClass();
|
||||
return null;
|
||||
}
|
||||
|
||||
static public int compare(Object k1, Object k2){
|
||||
if(k1 == k2)
|
||||
return 0;
|
||||
if(k1 != null)
|
||||
{
|
||||
if(k2 == null)
|
||||
return 1;
|
||||
if(k1 instanceof Number)
|
||||
return Numbers.compare((Number) k1, (Number) k2);
|
||||
return ((Comparable) k1).compareTo(k2);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
static public int hash(Object o){
|
||||
if(o == null)
|
||||
return 0;
|
||||
return o.hashCode();
|
||||
}
|
||||
|
||||
static public int hasheq(Object o){
|
||||
if(o == null)
|
||||
return 0;
|
||||
if(o instanceof Number)
|
||||
return Numbers.hasheq((Number)o);
|
||||
else if(o instanceof IHashEq)
|
||||
return ((IHashEq)o).hasheq();
|
||||
return o.hashCode();
|
||||
}
|
||||
|
||||
static public int hashCombine(int seed, int hash){
|
||||
//a la boost
|
||||
seed ^= hash + 0x9e3779b9 + (seed << 6) + (seed >> 2);
|
||||
return seed;
|
||||
}
|
||||
|
||||
static public boolean isPrimitive(Class c){
|
||||
return c != null && c.isPrimitive() && !(c == Void.TYPE);
|
||||
}
|
||||
|
||||
static public boolean isInteger(Object x){
|
||||
return x instanceof Integer
|
||||
|| x instanceof Long
|
||||
|| x instanceof BigInt
|
||||
|| x instanceof BigInteger;
|
||||
}
|
||||
|
||||
static public Object ret1(Object ret, Object nil){
|
||||
return ret;
|
||||
}
|
||||
|
||||
static public ISeq ret1(ISeq ret, Object nil){
|
||||
return ret;
|
||||
}
|
||||
|
||||
static public <K,V> void clearCache(ReferenceQueue rq, ConcurrentHashMap<K, Reference<V>> cache){
|
||||
//cleanup any dead entries
|
||||
if(rq.poll() != null)
|
||||
{
|
||||
while(rq.poll() != null)
|
||||
;
|
||||
for(Map.Entry<K, Reference<V>> e : cache.entrySet())
|
||||
{
|
||||
Reference<V> val = e.getValue();
|
||||
if(val != null && val.get() == null)
|
||||
cache.remove(e.getKey(), val);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static public RuntimeException runtimeException(String s){
|
||||
return new RuntimeException(s);
|
||||
}
|
||||
|
||||
static public RuntimeException runtimeException(String s, Throwable e){
|
||||
return new RuntimeException(s, e);
|
||||
}
|
||||
|
||||
/**
|
||||
* Throw even checked exceptions without being required
|
||||
* to declare them or catch them. Suggested idiom:
|
||||
* <p>
|
||||
* <code>throw sneakyThrow( some exception );</code>
|
||||
*/
|
||||
static public RuntimeException sneakyThrow(Throwable t) {
|
||||
// http://www.mail-archive.com/javaposse@googlegroups.com/msg05984.html
|
||||
if (t == null)
|
||||
throw new NullPointerException();
|
||||
Util.<RuntimeException>sneakyThrow0(t);
|
||||
return null;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
static private <T extends Throwable> void sneakyThrow0(Throwable t) throws T {
|
||||
throw (T) t;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
159
tests/golden-files/input/contents.pod
Normal file
159
tests/golden-files/input/contents.pod
Normal file
|
|
@ -0,0 +1,159 @@
|
|||
$Id: contents.pod,v 1.3 2003/05/04 04:05:14 tower Exp $
|
||||
|
||||
=begin html
|
||||
|
||||
<style = "text/css">
|
||||
code { font-family: sans-serif; font-weight:bold; }
|
||||
</style>
|
||||
|
||||
=end html
|
||||
|
||||
=head1 Net::Z3950::AsyncZ
|
||||
|
||||
=head2 Intro
|
||||
|
||||
Net::Z3950::AsyncZ adds an additional layer of asynchronous support for the Z3950 module through the use
|
||||
of multiple forked processes. I hope that users will also find that it provides a convenient
|
||||
front end to C<Net::Z3950>. My initial idea was to write something that
|
||||
would provide a convenient means of processing and formatting Z39.50 records--which I
|
||||
did, using the C<Z3950> synchronous code. But I also wanted something that could
|
||||
handle queries to large numbers of servers at one session. Working on this part of my
|
||||
project, I found that I had trouble with the C<Z3950> asynchronous features
|
||||
and so ended up with what I have here.
|
||||
|
||||
=begin html
|
||||
|
||||
I give a more detailed account in the <A href="AsyncZ.html#apologia"><B>DESCRIPTION</b></a>
|
||||
section of <code>AsyncZ.html</code>.
|
||||
|
||||
=end html
|
||||
|
||||
=pod
|
||||
|
||||
I give a more detailed account in in the B<DESCRIPTION> section of C<AsyncZ.pod>.
|
||||
|
||||
=cut
|
||||
|
||||
=head2 Documentation
|
||||
|
||||
=pod
|
||||
|
||||
=over 4
|
||||
|
||||
=item AsyncZ.pod
|
||||
|
||||
This is the starting point--it gives an overview of the AsyncZ module,
|
||||
describes the basic mechanics of its asynchronous workings, and details
|
||||
the particulars of the objects and methods. But see
|
||||
L</"Examples.pod> for detailed explanations of the sample
|
||||
scripts which come with the C<Net::Z3950::AsyncZ> distribution.
|
||||
|
||||
=item Options.pod
|
||||
|
||||
This document details the various options that can be set to modify
|
||||
the behavior of AsyncZ Index
|
||||
|
||||
=item Report.pod
|
||||
|
||||
Report.pod deals with how records are treated line by line
|
||||
and how you can affect the apearance of a record's line by line output
|
||||
|
||||
=item Examples.pod
|
||||
|
||||
This document goes through the sample scripts that come with the
|
||||
C<Net::Z3950::AsyncZ> distribution and annotates them
|
||||
in a line-by-line fashion. It's a basic HOW-TO.
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
||||
=begin html
|
||||
|
||||
<UL>
|
||||
<LI>
|
||||
<A href="AsyncZ.html">AsyncZ.html</a>
|
||||
<br>This is the starting point--it gives an overview of the AsyncZ module,
|
||||
describes the basic mechanics of its asynchronous workings, and details
|
||||
the particulars of the objects and methods. But see
|
||||
<a href="#examples">Examples</a> for detailed explanations of the sample
|
||||
scripts which come with the <code>Net::Z3950::AsyncZ</code> distribution.
|
||||
|
||||
<LI>
|
||||
<A href="Options.html">Options.html</a>
|
||||
<br> This document details the various options that can be set to modify
|
||||
the behavior of <code>AsyncZ</code>
|
||||
|
||||
<LI>
|
||||
<A href="Report.html">Report.html</a>
|
||||
<br><Code>Report.html</code> deals with how records are treated line by line
|
||||
and how you can affect the apearance of a record's line by line output
|
||||
|
||||
<LI><A name = "examples"></a>
|
||||
<A href="Examples.html">Examples.html</a>
|
||||
This document goes through the sample scripts that come with the
|
||||
<code>Net::Z3950::AsyncZ</code> distribution and annotates them
|
||||
in a line-by-line fashion. It's a basic HOW-TO.
|
||||
|
||||
</UL>
|
||||
|
||||
=end html
|
||||
|
||||
=head2 The Modules
|
||||
|
||||
=pod
|
||||
|
||||
There are more modules than there is documentation. The reason for this
|
||||
is that the only module you have full and complete access to is
|
||||
C<Net::Z3950::AsyncZ>. The other modules are either internal to C<Net::AsyncZ>
|
||||
or accessed indirectly or in part indirectly.
|
||||
|
||||
=cut
|
||||
|
||||
=for html
|
||||
There are more modules than there is documentation. The reason for this
|
||||
is that the only module you have full and complete access to is
|
||||
<code>Net::Z3950::AsyncZ</code>. The other modules are either internal to <code>Net::AsyncZ</code>
|
||||
or accessed indirectly or in part indirectly.
|
||||
|
||||
=head3 Here are the modules:
|
||||
|
||||
=over 4
|
||||
|
||||
=item Net::Z3950::AsyncZ
|
||||
|
||||
The main module: direct access --documented in
|
||||
C<AsyncZ> and C<Options> documentation
|
||||
|
||||
=item Net::Z3950::AsyncZ::ErrMsg
|
||||
|
||||
User error message handling: indirect access -- documented in
|
||||
C<AsyncZ> documentation
|
||||
|
||||
=item Net::Z3950::AsyncZ::Errors
|
||||
|
||||
Error handling for debugging: limited access -- documented in
|
||||
C<AsyncZ> documentation
|
||||
|
||||
=item Net::Z3950::AsyncZ::Report
|
||||
|
||||
Module reponsible for fetching and formatting records: limited access -- documented
|
||||
|
||||
=item Net::Z3950::AsyncZ::ZLoop
|
||||
|
||||
Event loop for child processes: no access -- not documented
|
||||
|
||||
=item Net::Z3950::AsyncZ::ZSend
|
||||
|
||||
Connection details for child processes: no access -- not documented
|
||||
|
||||
=item Net::Z3950::AsyncZ::Options::_params
|
||||
|
||||
Options for child processes: direct and indirect access -- documented
|
||||
in C<Options> and C<AsyncZ> documentation
|
||||
|
||||
=back
|
||||
|
||||
=head1 INDEX
|
||||
|
||||
|
||||
7
tests/golden-files/input/hello.c
Normal file
7
tests/golden-files/input/hello.c
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
#include <stdio.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
printf("Hello World\n");
|
||||
return 0;
|
||||
}
|
||||
8
tests/golden-files/input/hello.cpp
Normal file
8
tests/golden-files/input/hello.cpp
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main()
|
||||
{
|
||||
cout << "Hello World" << endl;
|
||||
}
|
||||
6
tests/golden-files/input/hello.h
Normal file
6
tests/golden-files/input/hello.h
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
#ifndef HELLO_H
|
||||
#define HELLO_H
|
||||
|
||||
void hello();
|
||||
|
||||
#endif
|
||||
4
tests/golden-files/input/hi.html
Normal file
4
tests/golden-files/input/hi.html
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
<html>
|
||||
<head></head>
|
||||
<body>hello</body>
|
||||
</html>
|
||||
4
tests/golden-files/input/hi.py
Normal file
4
tests/golden-files/input/hi.py
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
|
||||
|
||||
def hi():
|
||||
print "hi"
|
||||
BIN
tests/golden-files/input/hi.tar.bz2
Normal file
BIN
tests/golden-files/input/hi.tar.bz2
Normal file
Binary file not shown.
BIN
tests/golden-files/input/hi.tar.gz
Normal file
BIN
tests/golden-files/input/hi.tar.gz
Normal file
Binary file not shown.
BIN
tests/golden-files/input/hi.tgz
Normal file
BIN
tests/golden-files/input/hi.tgz
Normal file
Binary file not shown.
BIN
tests/golden-files/input/hi.zip
Normal file
BIN
tests/golden-files/input/hi.zip
Normal file
Binary file not shown.
BIN
tests/golden-files/input/hi3.cpython-34.pyc
Normal file
BIN
tests/golden-files/input/hi3.cpython-34.pyc
Normal file
Binary file not shown.
4
tests/golden-files/input/hi3.py
Normal file
4
tests/golden-files/input/hi3.py
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
|
||||
|
||||
def hi():
|
||||
print("hi")
|
||||
15
tests/golden-files/input/hi3_test.py
Executable file
15
tests/golden-files/input/hi3_test.py
Executable file
|
|
@ -0,0 +1,15 @@
|
|||
|
||||
|
||||
import unittest
|
||||
|
||||
import hi3
|
||||
|
||||
|
||||
class HiTestCase(unittest.TestCase):
|
||||
|
||||
def test_hi(self):
|
||||
hi3.hi()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
15
tests/golden-files/input/hi_test.py
Normal file
15
tests/golden-files/input/hi_test.py
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
|
||||
|
||||
import unittest
|
||||
|
||||
import hi
|
||||
|
||||
|
||||
class HiTestCase(unittest.TestCase):
|
||||
|
||||
def test_hi(self):
|
||||
hi.hi()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
BIN
tests/golden-files/input/libieee.a
Normal file
BIN
tests/golden-files/input/libieee.a
Normal file
Binary file not shown.
BIN
tests/golden-files/input/libpcprofile.so
Normal file
BIN
tests/golden-files/input/libpcprofile.so
Normal file
Binary file not shown.
2
tests/golden-files/input/perl.pl
Normal file
2
tests/golden-files/input/perl.pl
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
#!/usr/bin/perl
|
||||
print "Hello, world!\n";
|
||||
232
tests/golden-files/input/perl6.p6
Normal file
232
tests/golden-files/input/perl6.p6
Normal file
|
|
@ -0,0 +1,232 @@
|
|||
#!/usr/bin/env perl6
|
||||
|
||||
use v6;
|
||||
|
||||
my $string = 'I look like a # comment!';
|
||||
|
||||
if $string eq 'foo' {
|
||||
say 'hello';
|
||||
}
|
||||
|
||||
regex http-verb {
|
||||
'GET'
|
||||
| 'POST'
|
||||
| 'PUT'
|
||||
| 'DELETE'
|
||||
| 'TRACE'
|
||||
| 'OPTIONS'
|
||||
| 'HEAD'
|
||||
}
|
||||
|
||||
# a sample comment
|
||||
|
||||
say 'Hello from Perl 6!'
|
||||
|
||||
|
||||
#`{ | ||||