ludic.update: update_notes answers only for the language update_notes_for kept (none for another), and the tests follow the contract 3ac1179 set - the notes are kept by update_notes_for and whether this copy is installed is worked out when the updater is configured; they read the old per-call answers and failed 2 of 12
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
359de7bfe5
commit
313f95cd1f
3 changed files with 19 additions and 4 deletions
|
|
@ -37,8 +37,12 @@ export function update_latest(update_st: UpdateState) -> string { return update_
|
||||||
export function update_shown(update_st: UpdateState) -> bool { return update_st.update__ask == UPDATE_NEWER or update_st.update__ask == UPDATE_CURRENT }
|
export function update_shown(update_st: UpdateState) -> bool { return update_st.update__ask == UPDATE_NEWER or update_st.update__ask == UPDATE_CURRENT }
|
||||||
export function update_fresh(update_st: UpdateState) -> bool { return update_st.update__ask == UPDATE_NEWER }
|
export function update_fresh(update_st: UpdateState) -> bool { return update_st.update__ask == UPDATE_NEWER }
|
||||||
|
|
||||||
# the notes in the language the game asked for (update_notes_for), else English, else none
|
# the notes update_notes_for last kept, for that language (else English); none for a language it was
|
||||||
export function update_notes(update_st: UpdateState, lang: string) -> []string { return update_st.update__notes_list }
|
# not asked for - a question makes nothing, so it cannot fill them itself
|
||||||
|
export function update_notes(update_st: UpdateState, lang: string) -> []string {
|
||||||
|
if lang != update_st.update__notes_lang { return update_st.update__notes_none }
|
||||||
|
return update_st.update__notes_list
|
||||||
|
}
|
||||||
|
|
||||||
# the notes kept for this language: filled when the version or the language changes, so the panel
|
# the notes kept for this language: filled when the version or the language changes, so the panel
|
||||||
# reading them every frame makes nothing
|
# reading them every frame makes nothing
|
||||||
|
|
|
||||||
|
|
@ -59,6 +59,7 @@ export state UpdateState {
|
||||||
update__installed: bool = false # worked out when configured: the panel asks every frame
|
update__installed: bool = false # worked out when configured: the panel asks every frame
|
||||||
@max(256) update__notes_list: []string = new []string # the notes in the language last asked, kept
|
@max(256) update__notes_list: []string = new []string # the notes in the language last asked, kept
|
||||||
update__notes_lang: string = ""
|
update__notes_lang: string = ""
|
||||||
|
update__notes_none: []string = new []string # update_notes for a language not kept: always empty, never pushed to
|
||||||
update__notes_of: string = "" # ... for this version
|
update__notes_of: string = "" # ... for this version
|
||||||
update__cfg: UpdateConfig = new UpdateConfig
|
update__cfg: UpdateConfig = new UpdateConfig
|
||||||
update__state: int = 0
|
update__state: int = 0
|
||||||
|
|
|
||||||
|
|
@ -63,6 +63,12 @@ program UpdateTest {
|
||||||
System.run("rm -rf '" + dir() + "'")
|
System.run("rm -rf '" + dir() + "'")
|
||||||
Fs.mkdir(dir())
|
Fs.mkdir(dir())
|
||||||
Fs.mkdir(pkgs())
|
Fs.mkdir(pkgs())
|
||||||
|
configure(update_st, root)
|
||||||
|
update_reset(update_st)
|
||||||
|
}
|
||||||
|
# whether this copy was installed is worked out when the updater is configured, so a test that
|
||||||
|
# changes the disk or the executable's place configures again
|
||||||
|
function configure(update_st: mut UpdateState, root: bool) -> void {
|
||||||
let c = new UpdateConfig
|
let c = new UpdateConfig
|
||||||
c.feed = "http://feed"
|
c.feed = "http://feed"
|
||||||
c.app_id = "Game"
|
c.app_id = "Game"
|
||||||
|
|
@ -71,7 +77,6 @@ program UpdateTest {
|
||||||
c.packages = pkgs()
|
c.packages = pkgs()
|
||||||
c.scratch = hashf()
|
c.scratch = hashf()
|
||||||
update_config(update_st, c)
|
update_config(update_st, c)
|
||||||
update_reset(update_st)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function asset(ty: string, ver: string, size: int) -> string {
|
function asset(ty: string, ver: string, size: int) -> string {
|
||||||
|
|
@ -116,8 +121,11 @@ program UpdateTest {
|
||||||
update_check_tick(update_st, false)
|
update_check_tick(update_st, false)
|
||||||
expect(update_fresh(update_st))
|
expect(update_fresh(update_st))
|
||||||
expect(update_latest(update_st) == "1.2.0")
|
expect(update_latest(update_st) == "1.2.0")
|
||||||
|
update_notes_for(update_st, "tr") # the game's tick keeps them for its language
|
||||||
expect_eq(len(update_notes(update_st, "tr")), 1)
|
expect_eq(len(update_notes(update_st, "tr")), 1)
|
||||||
expect_eq(len(update_notes(update_st, "de")), 2)
|
expect_eq(len(update_notes(update_st, "de")), 0) # not kept for German yet
|
||||||
|
update_notes_for(update_st, "de")
|
||||||
|
expect_eq(len(update_notes(update_st, "de")), 2) # no German: English
|
||||||
}
|
}
|
||||||
|
|
||||||
test "the version being played is shown only when asked" (update_st: mut UpdateState, update_test_st: mut UpdateTestState) {
|
test "the version being played is shown only when asked" (update_st: mut UpdateState, update_test_st: mut UpdateTestState) {
|
||||||
|
|
@ -175,8 +183,10 @@ program UpdateTest {
|
||||||
Fs.mkdir(dir() + "/Game.app/Contents")
|
Fs.mkdir(dir() + "/Game.app/Contents")
|
||||||
Fs.mkdir(dir() + "/Game.app/Contents/MacOS")
|
Fs.mkdir(dir() + "/Game.app/Contents/MacOS")
|
||||||
Fs.write_text(dir() + "/Game.app/Contents/MacOS/UpdateMac", "x")
|
Fs.write_text(dir() + "/Game.app/Contents/MacOS/UpdateMac", "x")
|
||||||
|
configure(update_st, false)
|
||||||
expect(update_installed(update_st))
|
expect(update_installed(update_st))
|
||||||
update_test_st.exe = "/private/var/folders/x/AppTranslocation/y/Game.app/Contents/MacOS/Game"
|
update_test_st.exe = "/private/var/folders/x/AppTranslocation/y/Game.app/Contents/MacOS/Game"
|
||||||
|
configure(update_st, false)
|
||||||
expect(not update_installed(update_st))
|
expect(not update_installed(update_st))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue