Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testcase #4630

Draft
wants to merge 88 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
595a94c
register the test CLI command correctly
Gouvernathor Feb 11, 2022
eba7bf4
use better exception types (probably very little relevance)
Gouvernathor Feb 11, 2022
148cd16
Add launcher button to launch tests on the current game
Gouvernathor Feb 11, 2022
2b2f4a5
add doc stub
Gouvernathor Feb 11, 2022
3621028
slotting ast nodes (like in normal-renpy ast)
Gouvernathor Feb 11, 2022
98eba57
clean stuff
Gouvernathor Feb 12, 2022
b1b613a
update doc page
Gouvernathor Feb 12, 2022
83d48b2
update doc page
Gouvernathor Feb 13, 2022
1efa5b6
oh
Gouvernathor Feb 13, 2022
ac9c91e
fix bugs in class attributes
Gouvernathor Feb 14, 2022
e40561a
check for both
Gouvernathor Feb 14, 2022
b627cf6
makes label raise an exception instead of creating a silly loop
Gouvernathor Feb 14, 2022
fadf4b0
raise more accurate exception types
Gouvernathor Feb 18, 2022
eb048b5
add exit statement
Gouvernathor Feb 19, 2022
2a54a20
doc updates
Gouvernathor Feb 19, 2022
3f23fb1
add pass
Gouvernathor Feb 19, 2022
64e35b7
document the clause concept differently
Gouvernathor Feb 19, 2022
44d3155
more proper reorder
Gouvernathor Feb 19, 2022
75383c0
fix pass
Gouvernathor Feb 19, 2022
1c26110
add eval clause
Gouvernathor Feb 19, 2022
92556b3
change doc structure
Gouvernathor Feb 19, 2022
e2f2bac
document if eval
Gouvernathor Feb 19, 2022
671685e
add advance (except for the readiness condition)
Gouvernathor Feb 19, 2022
a9f5024
big advancement on the doc
Gouvernathor Feb 19, 2022
15744d1
fix rst
Gouvernathor Feb 19, 2022
479d19b
fix wrong offset
Gouvernathor Feb 19, 2022
70cb354
add has_default_focus
Gouvernathor Feb 19, 2022
98ee238
remove advance clause
Gouvernathor Feb 20, 2022
1398dc0
parameterize the number of trials in find_position
Gouvernathor Feb 20, 2022
84b73d7
document the focusing algorithm, and use faster min instead of sort
Gouvernathor Feb 20, 2022
b671e01
make Patterns raise exceptions when the target is not found
Gouvernathor Feb 26, 2022
e888893
reorder and better document the click/string clause
Gouvernathor Feb 26, 2022
4a3b272
document the testcase statement
Gouvernathor Feb 26, 2022
9d8155b
rephrase documentation
Gouvernathor Feb 26, 2022
d49c392
rst fixes
Gouvernathor Feb 26, 2022
7333957
fix exit example
Gouvernathor Feb 26, 2022
42b38f3
disable the (useless) always property for patternless click clauses
Gouvernathor Feb 26, 2022
1e24279
raise better exception
Gouvernathor Feb 26, 2022
3344def
raise betterer exception
Gouvernathor Feb 26, 2022
a85c53c
make label inexecutive, and assert clause-taking like if
Gouvernathor Feb 26, 2022
4517f76
better document click and patterns
Gouvernathor Feb 26, 2022
4adadda
update
Gouvernathor Feb 26, 2022
5c80ffa
add config.testcase_finally_callbacks
Gouvernathor Feb 26, 2022
13e8445
document config.testcase_finally_callbacks
Gouvernathor Feb 26, 2022
12cc2d4
add to the config list
Gouvernathor Feb 26, 2022
322d247
rename
Gouvernathor Feb 26, 2022
6b585d2
document that the run clause takes lists
Gouvernathor Mar 14, 2022
144001b
add renpy.is_in_test
Gouvernathor Mar 14, 2022
a6f2e6b
update doc
Gouvernathor Mar 14, 2022
f9995e8
updates following assert's change of meaning
Gouvernathor Mar 14, 2022
12b070c
create Clause subclass for more readability
Gouvernathor Apr 3, 2022
6c08d61
update doc and add things to add later
Gouvernathor Apr 3, 2022
57abd5b
fix super calls
Gouvernathor Apr 3, 2022
777ff16
let me sleep before writing code
Gouvernathor Apr 3, 2022
29979fd
improve the repr
Gouvernathor Apr 3, 2022
14e19cd
further documentation
Gouvernathor Apr 3, 2022
ca77d6f
add the hide property to python blocks
Gouvernathor Apr 4, 2022
0f8b1ad
update doc
Gouvernathor Apr 4, 2022
56ee681
add the Not, And and Or test clauses
Gouvernathor Apr 4, 2022
70ce1aa
simplify these repetititive start methods
Gouvernathor Apr 4, 2022
3543238
fix execute methods
Gouvernathor Apr 4, 2022
29f4c1c
add boolean operations between clauses
Gouvernathor Apr 4, 2022
3dec7f6
first pass at and/or state management
Gouvernathor Apr 4, 2022
451c3a7
make code more compact to find the problem
Gouvernathor Apr 5, 2022
692bf4c
remove short-circuit in readiness check causing inaccurate sub-readiness
Gouvernathor Apr 5, 2022
3eba038
update the readiness at each execution instead of in start
Gouvernathor Apr 5, 2022
e5d16a9
fix example
Gouvernathor Apr 5, 2022
ef98d82
add not/and/or documentation (and fix line endings)
Gouvernathor Apr 5, 2022
11cc6ae
add The Question example testcase
Gouvernathor Apr 5, 2022
c6cd0fe
add caveat about renpy.is_in_test
Gouvernathor Apr 5, 2022
aa9f15a
Cleanup a bit
Gouvernathor Mar 16, 2023
7aa9d66
Commit small launcher test
Gouvernathor Mar 16, 2023
8342a66
have a pass at the doc page
Gouvernathor Mar 16, 2023
19fa815
Simplify focus finder code
Gouvernathor Mar 17, 2023
eb3f6a2
doc: better explanation
Gouvernathor Mar 17, 2023
641f569
Simplify test
Gouvernathor Mar 17, 2023
459295f
Optimize int castings
Gouvernathor Mar 17, 2023
a223253
Set attribute at the correct time
Gouvernathor Mar 17, 2023
51070c6
Make pass a clause instead of a statement
Gouvernathor Mar 17, 2023
2c431f7
Fix 19fa815
Gouvernathor Mar 17, 2023
266c69e
doc updates
Gouvernathor Mar 17, 2023
5e494d1
Fix tutorial testcase
Gouvernathor Mar 17, 2023
fd55d9f
Also check if the save was correctly loaded
Gouvernathor Mar 17, 2023
acfc577
Not sure
Gouvernathor Mar 17, 2023
6fb6425
Merge branch 'master' into testcase-ex
Gouvernathor May 13, 2023
bbd8d7c
Deactivate execution of not
Gouvernathor May 13, 2023
abb7557
doc tweaks
Gouvernathor May 13, 2023
4402611
various fixes
Gouvernathor May 13, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions launcher/game/front_page.rpy
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ screen front_page_project:

textbutton _("Navigate Script") action Jump("navigation")
textbutton _("Check Script (Lint)") action Jump("lint")
textbutton _("Launch tests") action Jump("launch_tests")

if project.current.exists("game/gui.rpy"):
textbutton _("Change/Update GUI") action Jump("change_gui")
Expand Down Expand Up @@ -283,3 +284,11 @@ label force_recompile:
project.current.launch([ 'compile' ], wait=True)

jump front_page

label launch_tests:

python hide:
interface.processing(_("Launching tests..."))
project.current.launch([ 'test' ], wait=True)

jump front_page
26 changes: 24 additions & 2 deletions launcher/game/testcases.rpy
Original file line number Diff line number Diff line change
@@ -1,9 +1,31 @@
init python:
TEST_PROJECTS = u"/tmp/renpy-moé"
import shutil
def finally_callback():
print("finally "*100)
whether = renpy.is_in_test()

define config.end_testcase_callbacks += [finally_callback]

testcase default:
python hide:
renpy.watch("renpy.is_in_test()")
renpy.watch("waitch")
renpy.watch("whether")
waitch = 5
"preferences"
"theme"
"dEfAuLt theme"
"theme"
"dark the"
"return"
# exit
"quit"


init python:
TEST_PROJECTS = "/tmp/renpy-moé"
import shutil

testcase old_default:

call new_project
call translate_project
Expand Down
4 changes: 2 additions & 2 deletions renpy/ast.py
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,7 @@ def execute(self):
be executed after this one.
"""

raise Exception("Node subclass forgot to define execute.")
raise NotImplementedError("Node subclass forgot to define execute.")

# def early_execute(self):
# """
Expand Down Expand Up @@ -719,7 +719,7 @@ def get_code(self, dialogue_filter=None):
text in the statement.
"""

raise Exception("Not Implemented")
raise NotImplementedError

def analyze(self):
"""
Expand Down
4 changes: 4 additions & 0 deletions renpy/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,10 @@ def bootstrap(renpy_base):

finally:

if renpy.test.testexecution.node is not None:
for clbk in renpy.config.end_testcase_callbacks:
clbk()

if "RENPY_SHUTDOWN_TRACE" in os.environ:
enable_trace(int(os.environ["RENPY_SHUTDOWN_TRACE"]))

Expand Down
3 changes: 3 additions & 0 deletions renpy/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -1377,6 +1377,9 @@ def say_attribute_transition_callback(*args):
# A function that returns the autosave prefix.
autosave_prefix_callback = None

# Functions called when a test ends - one way or another
end_testcase_callbacks = [ ]

# Compatibility for c492f2f8e6de57b2740fa5d00566f445124caaba.
at_transform_compare_full_context = False

Expand Down
24 changes: 24 additions & 0 deletions renpy/exports.py
Original file line number Diff line number Diff line change
Expand Up @@ -4302,6 +4302,17 @@ def add_to_all_stores(name, value):
ns[name] = value


def is_in_test():
"""
:doc: other

Returns True if Ren'py is currently executing a testcase.
This always returns False at init time.
"""

return (renpy.test.testexecution.node is not None)


def get_zorder_list(layer):
"""
:doc: image_func
Expand Down Expand Up @@ -4436,6 +4447,19 @@ def set_focus(screen, id, layer="screens"): # @ReservedAssignment
restart_interaction()


def has_default_focus():
"""
:doc: other

Returns true if the game can be advanced by clicking or pressing the
spacebar.

For example, it is True in a dialogue or a pause, and False in places
like the Game Menu.
"""
return any(f.x is None for f in renpy.display.focus.focus_list)


def check_permission(permission):
"""
:doc: android_permission
Expand Down