Skip to content

Commit 0469de1

Browse files
committed
Add run-fast-tests.ps1 and document test environment variables
- Add PowerShell version of run-fast-tests for Windows - Add --keep-outputs/-k flag to run-tests.ps1 (matches bash version from ed683a3) - Document run-fast-tests.sh environment variables with detailed comments - Add comprehensive test environment variables section to README.md Environment variables documented: - QUARTO_TESTS_NO_CONFIG - Skip configure-test-env - QUARTO_TESTS_FORCE_NO_VENV - Skip .venv activation - QUARTO_TEST_KEEP_OUTPUTS - Keep test artifacts (new flag support in PS1) - QUARTO_TEST_VERBOSE - Verbose output - QUARTO_TESTS_NO_CHECK - Legacy/unused variable Changes bring feature parity between bash and PowerShell test runners.
1 parent 48ccd98 commit 0469de1

4 files changed

Lines changed: 106 additions & 5 deletions

File tree

‎tests/README.md‎

Lines changed: 64 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,20 +140,80 @@ Tests are run using `run-tests.sh` on UNIX, and `run-tests.ps1` on Windows.
140140
./run-tests.ps1 smoke/extensions/extension-render-doc.test.ts
141141
```
142142

143-
#### Prevent configuration for dependencies (R, Julia, Python, ...)
143+
#### Test environment variables
144144

145-
Those files will run `configure-test-env` scripts to check for requirements and set up dependencies (except on Github Action as this is done in the workflow file directly).
146-
You can prevent test configuration locally by setting `QUARTO_TESTS_NO_CONFIG` environment variable to a non-empty value.
145+
The test scripts support several environment variables to control their behavior:
146+
147+
**QUARTO_TESTS_NO_CONFIG**
148+
- Skip running `configure-test-env` scripts
149+
- Useful for faster test runs when environment is already configured
150+
- Tests will still activate `.venv` if present
147151

148152
```bash
149153
QUARTO_TESTS_NO_CONFIG="true" ./run-tests.sh
150154
```
151155

152156
```powershell
153-
$env:QUARTO_TESTS_NO_CONFIG=$true
157+
$env:QUARTO_TESTS_NO_CONFIG="true"
158+
./run-tests.ps1
159+
```
160+
161+
**QUARTO_TESTS_FORCE_NO_VENV** (replaces deprecated `QUARTO_TESTS_FORCE_NO_PIPENV`)
162+
- Skip activating the `.venv` virtual environment
163+
- Tests will use system Python packages instead of UV-managed dependencies
164+
- Use with caution: Python tests may fail if dependencies aren't in system Python
165+
166+
```bash
167+
QUARTO_TESTS_FORCE_NO_VENV="true" ./run-tests.sh
168+
```
169+
170+
```powershell
171+
$env:QUARTO_TESTS_FORCE_NO_VENV="true"
154172
./run-tests.ps1
155173
```
156174

175+
**Quick test runs with run-fast-tests scripts**
176+
177+
For convenience, `run-fast-tests.sh` and `run-fast-tests.ps1` are provided to skip environment configuration:
178+
179+
```bash
180+
# Linux/macOS
181+
./run-fast-tests.sh
182+
183+
# Windows
184+
./run-fast-tests.ps1
185+
```
186+
187+
These scripts set `QUARTO_TESTS_NO_CONFIG` automatically. Use after running `configure-test-env` at least once.
188+
189+
**QUARTO_TEST_KEEP_OUTPUTS** (or use `--keep-outputs`/`-k` flag)
190+
- Keep test output artifacts instead of cleaning them up
191+
- Useful for debugging test failures or inspecting generated files
192+
- Can be set via environment variable or command-line flag
193+
194+
```bash
195+
# Using flag
196+
./run-tests.sh --keep-outputs
197+
./run-tests.sh -k
198+
199+
# Using environment variable
200+
QUARTO_TEST_KEEP_OUTPUTS="true" ./run-tests.sh
201+
```
202+
203+
```powershell
204+
# Using flag
205+
./run-tests.ps1 --keep-outputs
206+
./run-tests.ps1 -k
207+
208+
# Using environment variable
209+
$env:QUARTO_TEST_KEEP_OUTPUTS="true"
210+
./run-tests.ps1
211+
```
212+
213+
**Other environment variables**
214+
- `QUARTO_TEST_VERBOSE` - Enable verbose test output
215+
- `QUARTO_TESTS_NO_CHECK` - Not currently used (legacy variable)
216+
157217
#### About smoke-all tests
158218

159219
`docs/smoke-all/` is a specific folder to run some tests written directly within `.qmd`, `.md` or `.ipynb` files (but files starting with `_` will be ignored). They are run through the `smoke/smoke-all.tests.ts` script. To ease running smoke-all tests, `run-tests.sh` has a special behavior where it will run `./smoke/smoke-all.tests.ts` when passed a `.qmd`, `.md` or `.ipynb` file, not starting with `_`.

‎tests/run-fast-tests.ps1‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Run tests without reconfiguring the environment (faster for repeated test runs)
2+
#
3+
# Environment variables set:
4+
# QUARTO_TESTS_NO_CONFIG - Skip running configure-test-env.ps1
5+
# (don't reinstall/update R, Python, Julia dependencies)
6+
#
7+
# Note: This still activates .venv if present, so Python tests use correct dependencies.
8+
# Only use after running configure-test-env.ps1 at least once to set up environment.
9+
10+
$env:QUARTO_TESTS_NO_CONFIG="true"
11+
& .\run-tests.ps1 @args

‎tests/run-fast-tests.sh‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
11
#!/usr/bin/env bash
22

3-
QUARTO_TESTS_FORCE_NO_PIPENV=true QUARTO_TESTS_NO_CONFIG=true QUARTO_TESTS_NO_CHECK=true ./run-tests.sh $*
3+
# Run tests without reconfiguring the environment (faster for repeated test runs)
4+
#
5+
# Environment variables set:
6+
# QUARTO_TESTS_FORCE_NO_VENV - Skip activating .venv virtual environment
7+
# (tests use system Python packages instead)
8+
# QUARTO_TESTS_NO_CONFIG - Skip running configure-test-env.sh
9+
# (don't reinstall/update R, Python, Julia dependencies)
10+
# QUARTO_TESTS_NO_CHECK - Not currently used by run-tests.sh
11+
# (kept for backward compatibility in case checked elsewhere)
12+
#
13+
# Note: Only use after running configure-test-env.sh at least once to set up environment.
14+
# Consider removing QUARTO_TESTS_FORCE_NO_VENV if Python tests require .venv packages.
15+
16+
QUARTO_TESTS_FORCE_NO_VENV=true QUARTO_TESTS_NO_CONFIG=true QUARTO_TESTS_NO_CHECK=true ./run-tests.sh $*

‎tests/run-tests.ps1‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,23 @@ $SOURCE = $MyInvocation.MyCommand.Path
66
# Check if verbose mode is enabled (GitHub Actions debug mode or explicit flag)
77
$VERBOSE_MODE = $env:RUNNER_DEBUG -eq "1" -or $env:QUARTO_TEST_VERBOSE -eq "true"
88

9+
# Check if keep-outputs mode is enabled
10+
$KEEP_OUTPUTS = $false
11+
$FILTERED_ARGS = @()
12+
foreach ($arg in $args) {
13+
if ($arg -eq "--keep-outputs" -or $arg -eq "-k") {
14+
$KEEP_OUTPUTS = $true
15+
} else {
16+
$FILTERED_ARGS += $arg
17+
}
18+
}
19+
$args = $FILTERED_ARGS
20+
21+
if ($KEEP_OUTPUTS) {
22+
$env:QUARTO_TEST_KEEP_OUTPUTS = "true"
23+
Write-Host "> Keep outputs mode enabled - test artifacts will not be deleted"
24+
}
25+
926
# ------ Setting all the paths required
1027

1128
if ($VERBOSE_MODE) {

0 commit comments

Comments
 (0)