Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 18 additions & 14 deletions components.dylan
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,15 @@ define class <suite> (<component>)
init-keyword: cleanup-function:;
end class <suite>;

define method make (class == <suite>, #rest args, #key) => (suite :: <suite>)
define method make
(class == <suite>, #rest args, #key register? = #t) => (suite :: <suite>)
let suite = next-method();
for (comp in suite.suite-components)
comp.component-parent := suite;
end;
when (register?)
register-component(suite);
end;
check-for-tests-included-multiple-times(suite);
suite
end;
Expand Down Expand Up @@ -98,15 +105,19 @@ define abstract class <runnable> (<component>)
end class <runnable>;

define method make
(class :: subclass(<runnable>), #rest args, #key name, tags)
(class :: subclass(<runnable>), #rest args, #key name, tags, register? = #t)
=> (runnable :: <runnable>)
let tags = map(make-tag, tags | #[]);
let negative = choose(tag-negated?, tags);
if (~empty?(negative))
error("tags associated with tests or benchmarks may not be negated."
" test = %s, tags = %s", name, negative);
end;
apply(next-method, class, tags: tags, args)
let runnable = apply(next-method, class, tags: tags, args);
when (register?)
register-component(runnable);
end;
runnable
end method;

define method expected-to-fail? (runnable :: <runnable>)
Expand Down Expand Up @@ -182,18 +193,11 @@ end;

/// Suites

// DEPRECATED: use make(<suite>) directly
define method make-suite
(name :: <string>, components, #rest keyword-args)
=> (suite :: <suite>)
let suite = apply(make, <suite>,
name: name,
components: components,
keyword-args);
for (comp in components)
comp.component-parent := suite;
end;
register-component(suite);
suite
apply(make, <suite>, name: name, components: components, keyword-args)
end method make-suite;

define macro suite-definer
Expand All @@ -220,7 +224,7 @@ define macro test-definer
name: ?"test-name",
function: "%%" ## ?test-name,
?keyword-args);
register-component(?test-name);
ignorable(?test-name);
}
end macro test-definer;

Expand All @@ -233,7 +237,7 @@ define macro benchmark-definer
name: ?"test-name",
function: "%%" ## ?test-name,
?keyword-args);
register-component(?test-name);
ignorable(?test-name);
}
end macro benchmark-definer;

Expand Down
11 changes: 1 addition & 10 deletions documentation/source/reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -837,8 +837,7 @@ This section describes the APIs necessary for creating a test suite
programmatically. This is sometimes useful if, for example, tests can be generated from
available data or are more easily described in a format like JSON.

Create and :func:`register <register-component>` your test components and then call
:func:`run-test-application` as usual.
Create your test components and then call :func:`run-test-application` as usual.

.. class:: <component>
:sealed:
Expand Down Expand Up @@ -933,11 +932,3 @@ Create and :func:`register <register-component>` your test components and then c
See :macro:`suite-definer` for details.

See :class:`<component>` for additional init keywords.

.. function:: register-component

Register a component (a test, benchmark, or suite) with Testworks so that it will be
found and executed during a test run. All components should be registered.

:signature: register-component ( *component* )
:parameter component: An instance of :class:`<component>`.
2 changes: 1 addition & 1 deletion library.dylan
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ define module testworks
<benchmark>,
<test>,
<suite>,
register-component;
register-component; // DEPRECATED: no longer required
end module testworks;


Expand Down
Loading
Loading