nitc :: CmdTesting
mentity
nitc :: CmdTesting :: _command
nitc :: CmdTesting :: command
nitc :: CmdTesting :: command=
nitc :: CmdTesting :: defaultinit
nitc $ CmdTesting :: SELF
Type of this instance, automatically specialized in every classnitc :: html_commands $ CmdTesting :: to_html
Render results as a HTML stringnitc :: json_commands $ CmdTesting :: to_json
Return a JSON Serializable representation ofself
results
nitc :: md_commands $ CmdTesting :: to_md
Render results as a Markdown stringnitc :: CmdTesting :: _command
nitc :: CmdEntity :: _mentity_name
Name of the mentity this command is aboutnitc :: CmdEntities :: _sorter
core :: Object :: class_factory
Implementation used byget_class
to create the specific class.
nitc :: DocCommand :: cmd_filter
Return a new filter for that command execution.nitc :: CmdTesting :: command
nitc :: CmdTesting :: command=
nitc :: CmdEntityList :: defaultinit
core :: Object :: defaultinit
nitc :: CmdEntity :: defaultinit
nitc :: DocCommand :: defaultinit
nitc :: CmdEntities :: defaultinit
nitc :: CmdList :: defaultinit
nitc :: CmdTesting :: defaultinit
nitc :: DocCommand :: execute
nitc :: DocCommand :: filter=
ModelFilter to apply if anynitc :: DocCommand :: http_init
Init the command from an HTTPRequestcore :: Object :: is_same_instance
Return true ifself
and other
are the same instance (i.e. same identity).
core :: Object :: is_same_serialized
Isself
the same as other
in a serialization context?
core :: Object :: is_same_type
Return true ifself
and other
have the same dynamic type.
nitc :: CmdEntity :: mentity_name
Name of the mentity this command is aboutnitc :: CmdEntity :: mentity_name=
Name of the mentity this command is aboutcore :: Object :: native_class_name
The class name of the object in CString format.core :: Object :: output_class_name
Display class name on stdout (debug only).nitc :: DocCommand :: parser_init
Initialize the command from the CommandParser datanitc :: CmdList :: print_list
nitc :: DocCommand :: to_json
Return a JSON Serializable representation ofself
results
# Cmd that finds the nitunit command related to an `mentity`
class CmdTesting
super CmdEntityList
var command: nullable String is lazy do
var results = self.results
if results == null then return null
var tpl = new Template
tpl.add "nitunit"
for result in results do
var path = test_path(result)
if path == null then continue
tpl.add " {path}"
end
return tpl.write_to_string
end
redef fun init_results do
if results != null then return new CmdSuccess
var res = super
if not res isa CmdSuccess then return res
var mentity = self.mentity.as(not null)
var mentities = new Array[MEntity]
if not mentity isa MPackage then return new WarningNoTest(mentity)
for mgroup in mentity.collect_all_mgroups(filter) do
if mgroup.is_test then
mentities.add mgroup
continue
end
for mmodule in mgroup.collect_mmodules(filter) do
if mmodule.is_test then mentities.add mmodule
end
end
if mentities.is_empty then return new WarningNoTest(mentity)
self.results = mentities
return res
end
# Return the mentity path
#
# This method exists for the only purpose to be redefined by nitunit tests
# to avoid path diffs.
private fun test_path(mentity: MEntity): nullable String do
var file = mentity.location.file
if file == null then return null
var base_path = self.mentity.as(not null).location.file.as(not null).filename
return file.filename.replace(base_path, "")
end
end
src/doc/commands/commands_main.nit:131,1--185,3
redef class CmdTesting
redef fun to_json do
var obj = new JsonObject
obj["command"] = command
return obj
end
end
src/doc/templates/json_commands.nit:272,1--278,3
redef class CmdTesting
redef fun execute(no_color) do
var mentity = self.mentity.as(not null).full_name
if no_color == null or not no_color then mentity = mentity.blue.bold
var title = "Testing `{mentity}`:"
if no_color == null or not no_color then
print title.bold
else
print title
end
print ""
var command = self.command
if command != null then print command
end
end
src/doc/term/term.nit:484,1--500,3