Skip to content

Commit 0ef0e9e

Browse files
authored
Run doctests in all tests (#95)
* Run doctests in all tests * Fix broken doctests * Load `Breeze` in `Main` to make doctests pass
1 parent df066f8 commit 0ef0e9e

File tree

6 files changed

+21
-5
lines changed

6 files changed

+21
-5
lines changed

docs/src/contributing.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,13 @@ import Pkg
4444
Pkg.test("Breeze"; test_args=`--verbose --jobs 2 moist_air atmosphere`)
4545
```
4646

47+
Similarly, to run only the doctests, you can use the command
48+
49+
```julia
50+
import Pkg
51+
Pkg.test("Breeze"; test_args=`doctests`)
52+
```
53+
4754
!!! note "List of tests"
4855

4956
The names of the test jobs are the file names under the `test` directory, without the `.jl` extension, excluding the `runtests.jl` file.

src/AtmosphereModels/anelastic_formulation.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ end
2929
const AnelasticModel = AtmosphereModel{<:AnelasticFormulation}
3030

3131
function Base.summary(formulation::AnelasticFormulation)
32-
p₀ = formulation.constants.base_pressure
33-
θᵣ = formulation.constants.potential_temperature
32+
p₀ = formulation.reference_state.base_pressure
33+
θᵣ = formulation.reference_state.potential_temperature
3434
return string("AnelasticFormulation(p₀=", prettysummary(p₀),
3535
", θᵣ=", prettysummary(θᵣ), ")")
3636
end

src/AtmosphereModels/atmosphere_model.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ AtmosphereModel{CPU, RectilinearGrid}(time = 0 seconds, iteration = 0)
9090
├── advection scheme: WENO{3, Float64, Float32}(order=5)
9191
├── tracers: ()
9292
├── coriolis: Nothing
93-
└── microphysics: WarmPhaseSaturationAdjustment
93+
└── microphysics: Nothing
9494
```
9595
9696
References
@@ -206,4 +206,4 @@ function Base.show(io::IO, model::AtmosphereModel)
206206
"└── microphysics: ", Mic)
207207
end
208208

209-
cell_advection_timescale(model::AtmosphereModel) = cell_advection_timescale(model.grid, model.velocities)
209+
cell_advection_timescale(model::AtmosphereModel) = cell_advection_timescale(model.grid, model.velocities)

src/Thermodynamics/thermodynamics_constants.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ A struct representing an ideal gas with molar mass and specific heat capacity.
1515
dry_air = IdealGas(molar_mass=0.02897, heat_capacity=1005)
1616
1717
# output
18-
"IdealGas{Float64}(molar_mass=0.02897, heat_capacity=1005)"
18+
IdealGas{Float64}(molar_mass=0.02897, heat_capacity=1005.0)
1919
```
2020
"""
2121
struct IdealGas{FT}

test/Project.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
[deps]
22
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
3+
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
34
ExplicitImports = "7d51a73a-1435-4ff3-83d9-f097790105c7"
45
Oceananigans = "9e8cae18-63c1-5223-a75c-80ca9d6e9a09"
56
ParallelTestRunner = "d3525ed8-44d0-4b2c-a655-542cee43accc"
67
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
78

89
[compat]
910
Aqua = "0.8"
11+
Documenter = "1.15"
1012
ExplicitImports = "1.13"
1113
Oceananigans = "0.100"
1214
ParallelTestRunner = "2.0.1"

test/doctests.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Loading `Breeze` into `Main` is necessary to work around
2+
# <https://github.com/JuliaTesting/ParallelTestRunner.jl/issues/68>.
3+
@eval Main using Breeze
4+
using Documenter: DocMeta, doctest
5+
DocMeta.setdocmeta!(Main.Breeze, :DocTestSetup, :(using Breeze); recursive = true)
6+
7+
doctest(Main.Breeze; manual = false)

0 commit comments

Comments
 (0)