Skip to content

More tests, workflows PR comment for feature test - #405

Open
varunghat wants to merge 19 commits into
phoible:masterfrom
varunghat:feat/more-tests
Open

More tests, workflows PR comment for feature test#405
varunghat wants to merge 19 commits into
phoible:masterfrom
varunghat:feat/more-tests

Conversation

@varunghat

Copy link
Copy Markdown
Contributor

Added the following regression tests:

  • Clicks and modifiers get typed as "M", which caused some issues previously with clicks and diacritics getting swapped where they shouldn't. Added a test to make sure the behaviour is as intended.
  • c-cedilla is a special case handled in denorm(), as well as 20 special-cases for features. Added a test to ensure these are not changed

Added the following new test

  • test-cross-inventory-integrity.R checks if
    • any (Source, Glottocode, LanguageName, SpecificDialect, BibtexKey) repeats with the same InventoryID , which implies there's two languages with the same InventoryID
    • Checks if all BibtexKey map to a valid Bibtex entry in phoible-references.bib
    • Checks if each InventoryID in bibtex mapping file is present in the final phoible.csv and vice-versa

Added the following extra test to test-inventory-metadata.R

  • Check if the ISOcodes present in glottolog match the ISOcodes present in phoible (With certain exceptions where glottolog keeps the older ISOcodes)

Excluded test-phonemes.R from github workflows test suite, but added it as a separate job which writes the output as a comment in the PR

Added tasks to pixi.toml (exactly the same as #398)

@varunghat
varunghat marked this pull request as draft August 20, 2026 23:27
@varunghat

Copy link
Copy Markdown
Contributor Author

Split into two workflows now (Since PR from forked repo does not have write permissions)

First workflow runs the Feature test (test-phonemes.R) first and stores data. Then runs the tests suite.
Second workflow runs on completion of the first, and writes the PR comment.

Verified the workflow on my forked branch, PR comment works with PR from a forked repo. Will work once the new workflow file gets added to master.

Current test fails are the 5 ISOcodes that do not match with glottolog (More info in this PR that fixes them: #403)

@varunghat
varunghat marked this pull request as ready for review August 21, 2026 12:43
Comment thread .github/workflows/main.yml Outdated
Comment thread .github/workflows/main.yml Outdated
runs-on: ubuntu-latest
permissions:
contents: read
actions: write

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why does this job need actions: write?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Job does not need actions: write. I wrongly assumed writing file needed it. Removed in 520b592. Tested on separate fork.

Comment thread .github/workflows/main.yml Outdated
run: |
Rscript -e "testthat::test_dir('.', stop_on_failure=TRUE)"
Rscript -e "testthat::test_dir('.', filter = 'phonemes', invert = TRUE, stop_on_failure = TRUE)"

No newline at end of file

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

stray whitespace

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed in 520b592

Comment thread tests/test-cross-inventory-integrity.R
Comment thread tests/test-regression-click-modifier.R Outdated
Comment on lines +46 to +57
test_that("multiple clicks in sequence with a modifier are all preserved", {
## two different clicks + one modifier, all typed "M".
result <- order_ipa("ǀǁʰ")
expect(stri_detect_fixed(result, "ǀ"),
paste("First click character was lost from", shQuote(result)))
expect(stri_detect_fixed(result, "ǁ"),
paste("Second click character was lost from", shQuote(result)))
expect(nchar(result) == 3,
paste("Expected a 3-character result, got", shQuote(result),
"(", nchar(result), "characters)"))
})

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
test_that("multiple clicks in sequence with a modifier are all preserved", {
## two different clicks + one modifier, all typed "M".
result <- order_ipa("ǀǁʰ")
expect(stri_detect_fixed(result, "ǀ"),
paste("First click character was lost from", shQuote(result)))
expect(stri_detect_fixed(result, "ǁ"),
paste("Second click character was lost from", shQuote(result)))
expect(nchar(result) == 3,
paste("Expected a 3-character result, got", shQuote(result),
"(", nchar(result), "characters)"))
})

no point to test this as you can't have 2 click glyphs in a row (click glyphs must always be accompanied by a preceding base glyph that denotes the place of back closure; the click glyph denotes front closure). In other words ǀǁʰ would really have to be kǀkǁʰ or qǀkǁʰ or something like that

@varunghat varunghat Aug 23, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed test 9af5531

Comment thread tests/test-regression-click-modifier.R Outdated
Comment on lines +58 to +69
test_that("two separate click+diacritic pairs in one string are both skipped", {
## typestring "MDMD" both with clicks, so both should be skipped
result <- order_ipa("ǀ̥ǁ̥")
expect(stri_detect_fixed(result, "ǀ"),
paste("First click character was lost from", shQuote(result)))
expect(stri_detect_fixed(result, "ǁ"),
paste("Second click character was lost from", shQuote(result)))
expect(nchar(result) == 4,
paste("Expected a 4-character result, got", shQuote(result),
"(", nchar(result), "characters)"))
})

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can skip this one too, for the same reason as above

Suggested change
test_that("two separate click+diacritic pairs in one string are both skipped", {
## typestring "MDMD" both with clicks, so both should be skipped
result <- order_ipa("ǀ̥ǁ̥")
expect(stri_detect_fixed(result, "ǀ"),
paste("First click character was lost from", shQuote(result)))
expect(stri_detect_fixed(result, "ǁ"),
paste("Second click character was lost from", shQuote(result)))
expect(nchar(result) == 4,
paste("Expected a 4-character result, got", shQuote(result),
"(", nchar(result), "characters)"))
})

@varunghat varunghat Aug 23, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed test 9af5531

Comment thread tests/test-regression-special-casess.R Outdated
Comment on lines +22 to +33
## every add-features.R `special_cases` pair has a matching row in special-feature-table.csv
special_cases <- c("pɸ", "pf", "tθ", "ts", "tʃ", "ʈʂ", "cç", "kx",
"qχ", "bβ", "bv", "dð", "dz", "dʒ", "ɖʐ", "ɟʝ", "ɡɣ",
"ɢʁ", "kp", "ɡb")
special_feats <- read.csv(file.path("..", "raw-data", "FEATURES",
"special-feature-table.csv"),
fileEncoding="UTF-8")
missing <- setdiff(special_cases, special_feats$segment)
expect(length(missing) == 0,
paste("special_cases pair(s) missing from special-feature-table.csv:",
paste(missing, collapse=", ")))
})

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is OK, but it seems like we could achieve the same thing by calling stopifnot(nrow(base_vec) == 1) right after the lookup, to make sure we got back exactly one row:

dev/scripts/add-features.R

Lines 145 to 146 in 6da1f9e

## look up the combined base glyphs in the special_feats table
base_vec <- special_feats[special_feats$segment == base_pair, ]

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, that is better. Avoids issue of hardcoded special_cases list in test.

Removed the test in f1c78ca
And renamed file to test-regression-c-cedilla.R since it only tests for c-cedilla now 792ea5a

Added the stopifnow assert in 9f8864d

Reran pipeline, phoible.csv has no diff with committed version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants