Skip to content

big revamp#109

Open
randrescastaneda wants to merge 21 commits intomainfrom
revamp
Open

big revamp#109
randrescastaneda wants to merge 21 commits intomainfrom
revamp

Conversation

@randrescastaneda
Copy link
Copy Markdown
Collaborator

No description provided.

- Remove install, uninstall, update subcommands from pip.ado; replaced
  with deprecation messages directing users to github install / net install
- Rewrite pip_gh.ado as a pure once-per-session version-check utility:
  queries GitHub releases API, compares versions, returns r(update_available)
  and r(install_cmd) with github/net install fallback
- Rewrite pip_new_session.ado: remove all pip_update/pip_find_src/SSC logic;
  call pip_gh once per session gated by \ global;
  silent on network failure
- Add standardized *!version 0.11.0 as first line of pip.ado
- Remove version history block from bottom of pip.ado
- pip_ssc.ado: SSC-specific update/install logic, no longer needed
- pip_install.ado: dual-source install logic, replaced by direct github/net install
- pip_update.ado: update dispatcher (SSC vs GitHub), replaced by pip_gh check
- pip_find_src.ado: source detection (SSC vs GitHub), no longer needed
- pip_install.sthlp: help file for removed install/uninstall/update subcommands
- pip.sthlp: remove [un]install subcommand from table; update troubleshooting
  to use github uninstall / ado uninstall and add net install fallback
- README.md: remove SSC section; add net install fallback option;
  update troubleshooting; bump version badge to 0.11.0
- .gitignore: add compound-gpid local config and .cg-docs entries
P1: version comparison now uses weighted arithmetic (Major*1e6 + Minor*1e3 + Patch)
    to correctly handle multi-digit version components (e.g. 0.9.10 vs 0.10.0)
P1: add else-exit guard for non-semver GitHub tags
P1: rewrite pip_githubquery using /releases/latest endpoint (single JSON object,
    no Mata/getmata/preserve pipeline); rename from _pip_githubquery
P2: capture scalar drop instead of scalar drop (avoids user-visible error offline)
P2: remove dead path/subcommand/pause params from pip_new_session; drop rclass
P2: remove stale boilerplate footer from pip_new_session
P2: cap -> capture in pip.ado deprecation block
P2: remove unused pause/path args from pip_new_session call in pip.ado
P2: gitignore pip.pkg and stata.toc (generated artifacts); untrack from index
P2: remove hardcoded absolute cd path from make.do
P3: standardize all comments to * style in pip_gh.ado
P3: document string contract for r(update_available)
P3: document pip_version_checked global in pip_new_session
…orconfig

BOM bytes (0xEF 0xBB 0xBF) were silently added by VS Code to pip.ado and
pip_gh.ado. PowerShell Get-Content automatically strips BOMs when reading,
hiding them from earlier checks. Stata does not strip BOMs and tried to
execute the 3-byte sequence as a command name, producing:

  ï is not a valid command name
  (error occurred while loading pip.ado)

Fix: stripped BOM from both files using Python codecs (utf-8-sig read, utf-8
write). Added .editorconfig with charset = utf-8 (no BOM) for all Stata
file types to prevent recurrence.
…_source call

Bug 1: pip_gh.ado used * for inline comments after code (e.g. exit * text).
In Stata, * is only a comment at line start; mid-line it is parsed as
multiplication, causing r(198). Replaced 4 inline * with //.

Bug 2: pip_utils_final_msg called pip_$pip_source' msg, but pip_update.ado
(which set pip_source) was deleted and pip_gh no longer has a msg subcommand.
Removed the dead block.

Tests: tests/test_bug_inline_star_comment.do, tests/test_bug_pip_source_stale.do
P1: fix GitHub API regex (space after colon in tag_name field);
    use exit 1 for all skip-exits in pip_gh so pip_new_session
    correctly distinguishes skip from success; add emptiness guard
    on r() macros before display in pip_new_session

P2: anchor semver regex with ^ and $; remove zombie pip_source from
    pip_setup_create; move deprecated subcmd check before pip_new_session
    to avoid unnecessary API call; remove duplicate install_cmd block in
    pip.ado; fix numlist overflow in frame2locals (forvalues);
    fix double count-if in dropvars (ds + qui sum); use tempname for
    scalar in pip_githubquery; add *.log and *.smcl to .gitignore;
    fix pip_uitls typo -> pip_utils in disp_query definition and call

P3: pre-clear scalar before capture block; semver overflow comment;
    remove redundant noi from capture pip_gh; guard set checksum off
    with session global; use substr for _pip_ prefix check; add
    *!version header to pip_utils.ado; version 16.1 in make.do;
    add deprecated subcommands section to pip.sthlp

Tests: add run_all_tests.do runner; test_pip_gh_returns.do (9 tests);
       test_pip_gh_silent_failures.do (2 tests); all 4/4 passing
P1: split capture block in pip_gh for file handle - open/read/close
    as separate capture steps so handle is always closed and rc_fh
    is preserved before cleanup resets _rc

P2: pip_utils - add parentheses to ustrregexm condition; extract
    pip_setup_ensure helper to eliminate duplicated findfile+create
    pattern in pip_setup (run, display, and replace call sites);
    add Test 3 (three-part guard component tests) to silent_failures;
    add test_pip_utils_dropvars.do (6 tests); add test_pip_deprecated_
    subcommands.do (4 tests)

P3: flatten pip_utils_keep_frame nesting with early continue;
    add state cleanup between tests in run_all_tests.do;
    add test_pip_utils_keep_frame.do (4 tests)

Tests: 7/7 passing
- Add tests/test_helpers.do with 13 shared assertion programs
- Add tests/run_unit_tests.do for offline-only test execution
- Update tests/run_all_tests.do to discover unit/, integration/, and root
  suites; fix batch-mode cwd issue by cd-ing into each suite dir before
  running tests
- Add 16 unit tests covering: parseopts, cache, fun.mata, cleanup, drop,
  gh returns/silent failures, split_options, timer, utils (dropvars,
  frame2locals, frameexists, keep_frame), deprecated subcommands, and
  two regression bugs (inline star comment, stale pip source)
- Add 13 integration tests covering: cl, wb, agg, cp, gd, tables,
  versions, set_server, auxframes, cache_live, cite, info, dispatcher
- Update README.md with Running Tests section
…ip calls

The revamp branch replaced three inline findfile/pip_setup_create
blocks in pip_setup.ado with calls to pip_setup_ensure, but that
program was never defined.  Every pip invocation failed immediately
with r(199): command pip_setup_ensure is unrecognized.

Add program define pip_setup_ensure, rclass which:
- calls findfile pip_setup.do
- if not found, calls pip_setup_create to write a blank one
- guards against no-writable-directory with error 198 + diagnostic
- returns r(fn) with the absolute path to the file
P1 fixes:
- rename tests/test_stubs.do -> tests/stubs.do (removes glob match
  from root test runner, prevents stubs leaking into integration suite)
- add stub program drop to runner cleanup blocks (unconditional, runs
  even when a test fails mid-run)
- add welfare_type to cl_min_vars in offline and live smoke tests
- improve Test 5 comment in test_pip_setup_ensure.do (restore-before-
  assert rationale now explicit)
- add welfare_type labels + heterogeneous values (1=Consumption,
  2=Income) to pip_cl stub

P2 fixes:
- hoist adopath ++ to runners (prevents duplicate entries; individual
  tests keep their own call for standalone robustness)
- add type checks for poverty_gap, poverty_severity, welfare_type in
  offline smoke tests
- add negative test (Test 8: pip xyzzy errors on unknown subcommand)
- extract Test 6 from test_pip_smoke.do to new file
  tests/unit/test_pip_setup_stub_compat.do
- remove unreachable stub cleanup from test_pip_smoke.do (moved to runner)
- stage pip.sthlp (auto-updated by pip_setup date logic during test run)

P3 fixes:
- add Layer field to stubs.do header
- add magic number comments in pip_cl stub (mean, headcount, etc.)
- vary is_interpolated in fillgaps path (obs1=0, obs2=1)
- add Test 0 precondition check in test_pip_setup_ensure.do
- improve Test 5 why-comment in test_pip_setup_ensure.do

Tests: 19/19 unit tests pass
P1 fixes:
- pip_gh.ado: bare exit replaced with exit 1 in skip path
- tests/run_all_tests.do: root suite restricted to _diag_*.do only
- pip_utils.ado: restore now unconditional (no dataset leak on list error)

P2 fixes:
- pip_setup.ado: session gate guards expensive I/O on every pip call
- pip_setup.ado: pip_setup_replace uses pip_setup_ensure (cache-aware)
- pip_setup.ado: %12.0g -> %15.0f format for hash display
- pip.ado: named local for default subcommand; return add for cl/wb/cp
- pip.ado: ssc deprecation redirect added to regex
- pip_utils.ado: sepvars -> sepvar typo fixed
- pip_utils.ado: frame2locals row-count guard (max 50 rows)
- pip_utils.ado: all 8 sub-programs documented with Purpose/Syntax/Returns
- pip_utils.ado: syntax keyword restored to pip_utils_clicktable
- pip_parseopts.ado: pip_split_options moved here from pip.ado
- pip_gh.ado: formal header comments added to both programs
- pip_new_session.ado: header added; redundant pip_setup run removed
- tests/run_all_tests.do: cd restoration before summary block

P3 fixes:
- pip_gh.ado: *!version -> *! version spacing
- pip_gh.ado: dead capture scalar drop before tempname removed
- pip_utils.ado: note added about misstable alternative in dropvars
- tests/stubs.do: pip_versions stub uses regex extraction
- tests/stubs.do: staleness comment added
- tests/unit/test_pip_gh_returns.do: Test 9 comment improved
- tests/run_unit_tests.do: path validation for unit_dir before cd
- make.do: comment corrected (manual, not auto-generated)
- 7 duplicate root test files deleted (now live only under unit/)

Tests: 20/20 unit tests pass
Stata's ado auto-loader only retains the first program defined in a
.ado file (the one matching the filename). pip_split_options was a
sub-program inside pip_parseopts.ado, so it was silently discarded
on auto-load, causing r(199) on every pip call.

Move pip_split_options to pip_split_options.ado so Stata can
auto-discover it independently.
P1 fixes:
- Add dollar end-anchor to regex in pip_split_options to prevent
  prefix false-matches (e.g. 'verbosity' no longer matches 'version')
- Add abblength() range guard (1-5); abblength=0 now errors rc=125
- Add mata pre-flight assertion to test file

P2 fixes:
- Explicit empty r(gen_opts)/r(est_opts) on early exit (no stale r())
- Add version 16.1 directive inside pip_split_options program body
- Add optname validity guard in pip_parseopts (rc=198 on bad name)
- Add duplicate option warning in pip_parseopts
- Add *! version banner to pip_parseopts.ado
- Expand comment explaining the extraction reason
- Add edge-case tests: 2-char abbreviations rejected (Test 4)
- Standardise Test 4/5 to inline style; renumber to Tests 5/6

P3 fixes:
- Rename cryptic sgo/oo locals to gen_opt_tokens/est_opt_tokens
- Add INTERNAL HELPER notice to pip_split_options header
- Document abblength() parameter range in header block
- Remove template scaffolding below exit in pip_parseopts.ado
- Add teardown (capture program drop) at end of test file
- Add canonical list cross-reference comment in test file
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.

1 participant