Testing LibreOffice Calc formulas from the command line: why my first test passed without recalculating
We maintain two small Calc templates: a YouTube Partner Program eligibility tracker template and a Facebook Page monetization tracker for Calc. You enter your current numbers and what you gained over the past 28 days. The sheet shows how far you are from the numeric targets and uses that pace to estimate when you might reach the subscriber, watch hours, Shorts views or follower targets. The YouTube sheet also shows how many more valid public uploads you need. Both are formulas only, no macros.
The sheets have nested IFs, a rolling window, a streak counter and a "Not sure" answer that must never turn into Yes. I wanted to check them without opening Calc after every edit, so the checks run from a terminal. My first test passed on results Calc had already saved in the .ods files.
The setup: sample files, a CSV export, and numbers worked out by hand
The build script (a Python macro run inside headless LibreOffice) writes the template and then a few sample files. Each sample is the template with different inputs and a fixed date, saved as .ods. The YouTube sheet has three samples and the Facebook sheet has four.
For each sample, the expected values are written by hand in a Python dict, keyed by cell. Nothing in the dict is copied from Calc's output. Here's part of the Facebook one:
TODAY = datetime.date(2026, 11, 2) def on(days): return (TODAY + datetime.timedelta(days=days)).strftime("%-d %b %Y") EXPECTED = { # 1,800 followers, +300 in 28 days (10.714/day), at 500+ since 12 days ago "A-example": { "C26": "12", "D26": "18", "F26": on(18), "D34": "3,200", "E34": str(math.ceil(3200 / (300 / 28))), "F34": on(299), ... }, } The values are strings because the comparison runs on the CSV, which holds formatted text: 3,200, 2 Dec 2026, Not at this pace. That's what a user sees, so number formats get tested along with the formulas.
The export is one command per folder. $PWD/profile is a LibreOffice profile with one setting added, shown in the next section; without it, this command exports stale results:
soffice -env:UserInstallation=file://$PWD/profile --headless \ --convert-to 'csv:Text - txt - csv (StarCalc):44,34,76' \ --outdir out/ypp run/ypp/*.ods python3 compare.py out/ypp 44,34,76 means comma separator, double-quote text delimiter, UTF-8. Run on LibreOffice 26.8.1.1 today, the two compare scripts print:
A-example: 34/34 match B-shorts: 31/31 match C-edge: 28/28 match A-example: 20/20 match, 0 error cells B-big-page: 12/12 match, 0 error cells C-shrinking: 16/16 match, 0 error cells D-policy: 15/15 match, 0 error cells The Facebook script also fails on any cell starting with Err: or #, so a broken reference shows up even in a cell nobody wrote an expectation for.
Why --convert-to exported cached results
An .ods file stores each formula's last result next to the formula. With a fresh profile, LibreOffice 26.8 opened my samples, kept those stored results, and wrote them to the CSV. So the test was comparing my expectations with whatever Calc had calculated when the file was saved.
To see it, I took the YouTube example sample, changed the subscriber input in content.xml from 820 to 990, left the stored results alone, and exported it with two profiles. Fresh profile:
Subscribers,990,,YouTube Studio > Analytics,,, Subscribers,"1,000",,820,180,68,January 2027 The input says 990, and the row below still uses 820. With the setting below:
Subscribers,990,,YouTube Studio > Analytics,,, Subscribers,"1,000",,990,10,4,October 2026 The fix is one entry in the export profile's user/registrymodifications.xcu. Setting ODFRecalcMode to 0 makes Calc recalculate OpenDocument spreadsheets when it opens them:
<item oor:path="/org.openoffice.Office.Calc/Formula/Load"> <prop oor:name="ODFRecalcMode" oor:op="fuse"><value>0</value></prop> </item> The build macro sets the same key in the profile it runs in. If you export with any other profile, a fresh one included, add the entry to that profile's user/registrymodifications.xcu first.
The shipped templates made this easy to miss. Their TODAY() cell and the dates that depend on it updated with both profiles. The fixed-date sample I edited still exported the old result with the fresh profile.
To check your own setup, edit an input in content.xml that feeds a formula your test checks. Leave the cached result and the expected value alone, then export again with your test profile. The check for that cell should fail.
How I picked the sample inputs
Most of the interesting formulas are "days to go" cells. Here's the Shorts views row for the YouTube lower tier, from the shipped file's content.xml with line breaks added:
=IF(E29=0; 0; IF($C$13<=0; ""; IF(ROUNDUP(E29/$C$13; 0) < C29; ROUNDUP(E29/$C$13; 0); IF($C$13*C29 >= B29; C29; "")))) E29 is the gap, C13 the daily pace (28-day gain divided by 28), C29 the window in days (90 for Shorts views, 365 for watch hours) and B29 the target. There are five ways out: already there, no growth, done inside the window, new views alone fill the window, and not at this pace. The same pattern is used on the watch hours rows, and the three YouTube samples hit all five outcomes across the watch hours and Shorts rows:
- A-example (820 subscribers, steady growth) lands inside the window on the watch hours row: 700 hours short at about 10.7 a day, 66 days.
- B-shorts is a Shorts-heavy channel with few watch hours, so the watch hours rows come out empty and the Shorts rows give the dates.
- C-edge is dated 15 February 2027, after the new ad revenue bar starts. It has a negative subscriber pace, zero watch hours, two uploads where three are needed, and a Shorts pace picked to land on the window boundary.
That last one is the case I most wanted pinned down. The sample gains 933,352 Shorts views in 28 days, 33,334 a day, and is 2,990,000 views short of 3 million. ROUNDUP(2990000/33334) is 90, which is not less than the 90-day window, so the formula falls through to the last check: 33,334 × 90 is 3,000,060, just over the target. The cell says 90. I changed the input to 933,324 (33,333 a day) and exported again:
Or Shorts views,"3,000,000",90,"10,000","2,990,000",90,May 2027 Or Shorts views,"3,000,000",90,"10,000","2,990,000",,Not at this pace At 33,333 a day, 90 days adds 2,999,970 views, 30 short of the target. The test expects 90 and May 2027 at 33,334 a day. It doesn't catch a change from >= to >: that needs a pace that lands exactly on 3 million in 90 days, which would take a 28-day gain of 933,333.33 views, and gains are whole numbers.
The Facebook sheet has two different kinds of formula to cover. Stars needs 500 followers held for 30 days in a row, so it counts a streak from the date you reached 500 (B10):
C26 =IF(C25<B25; 0; IF(ISNUMBER(B10); MAX(0; B7-B10); 0)) E26 =IF(D25>0; IF(ISNUMBER(E25); E25+B26; ""); D26) Then there are the yes/no answers (professional mode, age, country list, policy issues), each a dropdown with Yes, No and Not sure. A blank answer has to read as unknown, not as No:
C27 =IF(B11=""; ""; B11) D27 =IF(C27="Yes"; "OK"; IF(C27="No"; "Not met"; "Check")) B31 =IF(COUNTIF(C27:C30; "No")>0; "No"; IF(D25+D26>0; "Not yet"; IF(COUNTIF(C27:C30; "Yes")=ROWS(C27:C30); "Yes"; "Numbers met"))) The plain =B11 would have shown a blank answer as 0. Here are three cases I tested. None of the four Facebook samples reaches "Numbers met" yet. That needs a page that meets the follower requirements and has a blank or "Not sure" answer, with no "No":
- C-shrinking: 300 followers, losing 10 in 28 days, every answer left blank. All four Stars checks say "Check", and the result is "Not yet", not "No". The day estimates in E25 and E26 are blank, and the date column next to them, F25 and F26, shows "Not at this pace".
- D-policy: 520 followers with B10 left empty, so the streak counts from today: 30 days to go, 2 December 2026. The policy answer is No, so the result is "No" even though the follower count is fine.
- B-big-page: 6,400 followers, 45 days at 500 or more, but a No on the Subscriptions country list. Stars says Yes and Subscriptions says No.
In total that's 93 hand-worked cells for the YouTube sheet and 63 for the Facebook one. The same samples were exported from LibreOffice 7.4.7 when the templates were built, and those CSVs still match today.
The thresholds, and what can't be tested this way
The formulas read numeric targets from the Needed column. The lower-tier Shorts target, for example, is in B29. As of 29 November 2026, YouTube's help center lists 1,000 subscribers plus either 4,000 qualified watch hours in 12 months or 10 million qualified Shorts views in 90 days for the ad revenue tier. From 1 February 2027, new applicants need 8,000 hours or 20 million Shorts views, still with 1,000 subscribers. The lower tier still requires 500 subscribers, three valid public uploads in the last 90 days, and either 3,000 qualified watch hours in 12 months or 3 million qualified Shorts views in 90 days. On Facebook, Stars needs 500 followers for 30 days in a row and Subscriptions needs 5,000. In-stream ads ended on 31 August 2025, and Content Monetization is invite-only with no published follower minimum.
The tests check that the formulas match my reading of those rules. They can't check the inputs. YouTube counts qualified watch hours and Shorts views. A browser extension can check public pages for the subscriber count, a Join button, a Store tab or ads on watch pages, but none of those pages shows the qualified totals. For a date estimate in Calc, you enter them from YouTube Studio. A passing CSV check tells me how Calc applied the thresholds in the sheet to the sample inputs I gave it, nothing more.