Skip to content

Skip MSVS tests when license is expired - #4906

Open
bdbaddog wants to merge 5 commits into
SCons:masterfrom
bdbaddog:handle_msvs_no_license
Open

bdbaddog wants to merge 5 commits into
SCons:masterfrom
bdbaddog:handle_msvs_no_license

Conversation

@bdbaddog

Copy link
Copy Markdown
Contributor

Summary

Add detection for expired/invalid Visual Studio licenses in MSVS end-to-end tests, allowing tests to be skipped cleanly instead of failing with confusing build errors.

The 17 test/MSVS/*-exec.py tests build real Visual Studio projects using devenv/msdev. When the VS license/trial has expired, these invocations fail even though the toolchain is otherwise detected as present. This change probes for usable license validity before running these tests, skipping them with a clear message if the license is unavailable.

Key features:

  • Isolated license probe: Builds a minimal dummy project via devenv/msdev to test actual usability (not just filesystem presence)
  • Version-correct project format: Probe uses correct file format (.dsp for legacy msdev, .vcproj/.vcxproj for devenv) based on MSVS version
  • Cached per version: Probe result cached across test run to avoid redundant builds
  • Opt-in control: SCONS_MSVS_CHECK_LICENSE environment variable (default: disabled) allows enabling only where needed
  • Zero overhead by default: Other environments (local dev, non-AppVeyor CI) pay no cost unless explicitly enabled
  • Enabled on AppVeyor: .appveyor.yml sets SCONS_MSVS_CHECK_LICENSE=1 for Windows builders where license expiry is known to occur

Implementation:

  1. TestSConsMSVS.msvs_build_usable(version): Probes whether devenv/msdev can build; caches result per version
  2. TestSConsMSVS.skip_if_msvs_license_invalid(version): Calls probe and skips test if it fails
  3. All 17 test/MSVS/*-exec.py tests: Added one-line call to license check after version presence check
  4. .appveyor.yml: Added SCONS_MSVS_CHECK_LICENSE: "1" to enable check on AppVeyor
  5. testing/framework/test-framework.rst: Added Environment Variables reference section documenting all test framework env vars
  6. CHANGES.txt and RELEASE.txt: Documented the feature for the next release

Contributor Checklist:

  • I have created a new test or updated the unit tests to cover the new/changed functionality. (Tests updated: added license check to all 17 MSVS exec tests)
  • I have updated `CHANGES.txt` and `RELEASE.txt` (and read the `README.rst`). (Documentation added)
  • I have updated the appropriate documentation (Added Environment Variables reference section to test-framework.rst)

🤖 Generated with Claude Code

bdbaddog and others added 4 commits September 15, 2026 14:33
When Visual Studio's license or trial has expired, devenv.exe /build exits
non-zero even though the toolchain is otherwise present (filesystem/registry
checks pass, but the IDE itself is unusable). This causes the 17 test/MSVS/*-exec.py
tests to fail with a confusing build error instead of being skipped.

Implement a license probe in TestSConsMSVS:
- New msvs_build_usable(version) method: builds an isolated minimal dummy
  project via devenv/msdev to test if the toolchain is actually usable
  (not just present on the filesystem).
- Result is cached per version at tempfile.gettempdir()/scons/msvs_license_probe_cache.json
  so the expensive probe build runs at most once per version per test run.
- New skip_if_msvs_license_invalid(version) method: calls the probe and skips
  the test if it fails, with a clear message.
- Each of the 17 *-exec.py test files adds one line call to this method right
  after the msvs_versions() presence check, before any test-specific setup.

The probe generates the correct project file format (.dsp for legacy msdev,
.vcproj/.vcxproj for devenv) based on version, reusing SCons's own MSVSProject
builder so the probe is as realistic as possible while being isolated from the
test's own real project.

Fixes: tests on machines with expired Visual Studio licenses now report
'NO RESULT' (skip) instead of 'FAILED', allowing CI runs to continue even when
the license is the only blocker.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
The MSVS license/expired-trial detection feature probes whether devenv/msdev
can actually build, adding overhead (extra project generation + devenv
invocation per test) in every environment. This overhead is only necessary on
AppVeyor's Windows builders where the license expiry problem is known to occur.

Add opt-in control via SCONS_MSVS_CHECK_LICENSE environment variable:
- Default: disabled (check is skipped, no overhead anywhere except AppVeyor)
- Set to "1": enables the check (runs probe, caches result per version)
- Set to anything else ("0", empty, etc.): disabled

The check is short-circuited at the top of msvs_build_usable() —
when disabled, returns True immediately and skips the entire probe
(no cache read/write, no temporary project, no extra devenv build).

Enable the check in .appveyor.yml's environment block alongside the
existing SCONS_CACHE_MSVC_CONFIG flag, so AppVeyor CI runs benefit from
the license detection while all other environments (local dev, GitHub
Actions, other CI providers) pay zero overhead by default.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Document all environment variables recognized by the test framework:
- FIXTURE_DIRS: directory search path for test fixtures
- PRESERVE: preserve test working directory after run
- PRESERVE_PASS/PRESERVE_FAIL/PRESERVE_NORESULT: preserve on specific outcomes
- SCONS_MSVS_CHECK_LICENSE: control whether VS license validity is probed

This centralizes environment variable documentation in one reference section
at the end of test-framework.rst, making it easy for developers to discover
available options. Includes the newly-added SCONS_MSVS_CHECK_LICENSE flag.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Document the new MSVS license/expired-trial detection feature:
- Added to CHANGES.txt under William Deegan's contributions for the current release
- Added to RELEASE.txt under the DEVELOPMENT section
- Explains the problem (expired VS license causes test failures)
- Describes the solution (opt-in probing via SCONS_MSVS_CHECK_LICENSE env var)
- Notes the default-off behavior to avoid overhead on unaffected environments

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
@bdbaddog
bdbaddog requested a review from mwichmann September 15, 2026 18:52
@bdbaddog bdbaddog added MSVC Microsoft Visual C++ Support testsuite Things that only affect the SCons testing. Do not use just because a PR has tests. labels Sep 15, 2026
The probe SConstruct was missing the 'msvc' tool needed to compile foo.c
and the 'msvs' tool needed to generate the project file. This caused the
probe to crash on AppVeyor when the C++ build tools weren't available in
the environment, even though VS was detected as installed.

Changes:
- Add 'msvc' and 'msvs' tools to the probe Environment
- Wrap the SCons project generation step with status=None to capture
  exit code without asserting, so missing tools are treated as
  "not usable" rather than test failures

This allows the probe to gracefully handle environments where VS is
installed but the build tools aren't set up, falling back to skipping
the test rather than crashing.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

MSVC Microsoft Visual C++ Support testsuite Things that only affect the SCons testing. Do not use just because a PR has tests.

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

1 participant