Browse Source

test at-__NAME__ replacement

pull/5/head
Fredrik Ekre 8 years ago
parent
commit
880cf32485
  1. 43
      test/runtests.jl

43
test/runtests.jl

@ -154,9 +154,11 @@ content = """
print(i) print(i)
#' some markdown in a code block #' some markdown in a code block
end end
#' name: @__NAME__
#' Link to repo root: @__REPO_ROOT_URL__ #' Link to repo root: @__REPO_ROOT_URL__
# Link to repo root: @__REPO_ROOT_URL__
#' Link to nbviewer: @__NBVIEWER_ROOT_URL__ #' Link to nbviewer: @__NBVIEWER_ROOT_URL__
# name: @__NAME__
# Link to repo root: @__REPO_ROOT_URL__
# Link to nbviewer: @__NBVIEWER_ROOT_URL__ # Link to nbviewer: @__NBVIEWER_ROOT_URL__
#' PLACEHOLDER1 #' PLACEHOLDER1
@ -198,8 +200,8 @@ content = """
end end
# name: inputfile
# Link to repo root: https://github.com/fredrikekre/Literate.jl/blob/master/ # Link to repo root: https://github.com/fredrikekre/Literate.jl/blob/master/
# Link to nbviewer: https://nbviewer.jupyter.org/github/fredrikekre/Literate.jl/blob/gh-pages/v1.2.0/ # Link to nbviewer: https://nbviewer.jupyter.org/github/fredrikekre/Literate.jl/blob/gh-pages/v1.2.0/
# PLACEHOLDER3 # PLACEHOLDER3
@ -232,7 +234,10 @@ content = """
# name # name
Literate.script(inputfile, outdir, name = "foobar") Literate.script(inputfile, outdir, name = "foobar")
@test isfile(joinpath(outdir, "foobar.jl")) script = read(joinpath(outdir, "foobar.jl"), String)
@test contains(script, "name: foobar")
@test !contains(script, "name: inputfile")
@test !contains(script, "name: @__NAME__")
end end
end end
end end
@ -282,15 +287,13 @@ end
end end
``` ```
name: inputfile
Link to repo root: https://github.com/fredrikekre/Literate.jl/blob/master/ Link to repo root: https://github.com/fredrikekre/Literate.jl/blob/master/
```@example inputfile
# Link to repo root: https://github.com/fredrikekre/Literate.jl/blob/master/
```
Link to nbviewer: https://nbviewer.jupyter.org/github/fredrikekre/Literate.jl/blob/gh-pages/v1.2.0/ Link to nbviewer: https://nbviewer.jupyter.org/github/fredrikekre/Literate.jl/blob/gh-pages/v1.2.0/
```@example inputfile ```@example inputfile
# name: inputfile
# Link to repo root: https://github.com/fredrikekre/Literate.jl/blob/master/
# Link to nbviewer: https://nbviewer.jupyter.org/github/fredrikekre/Literate.jl/blob/gh-pages/v1.2.0/ # Link to nbviewer: https://nbviewer.jupyter.org/github/fredrikekre/Literate.jl/blob/gh-pages/v1.2.0/
``` ```
@ -354,6 +357,9 @@ end
markdown = read(joinpath(outdir, "foobar.md"), String) markdown = read(joinpath(outdir, "foobar.md"), String)
@test contains(markdown, "```@example foobar") @test contains(markdown, "```@example foobar")
@test !contains(markdown, "```@example inputfile") @test !contains(markdown, "```@example inputfile")
@test contains(markdown, "name: foobar")
@test !contains(markdown, "name: inputfile")
@test !contains(markdown, "name: @__NAME__")
end end
end end
end end
@ -425,24 +431,16 @@ end
""" """
"source": [ "source": [
"Link to repo root: https://github.com/fredrikekre/Literate.jl/blob/master/" "name: inputfile\\n",
] "Link to repo root: https://github.com/fredrikekre/Literate.jl/blob/master/\\n",
""",
"""
"source": [
"# Link to repo root: https://github.com/fredrikekre/Literate.jl/blob/master/"
]
""",
"""
"source": [
"Link to nbviewer: https://nbviewer.jupyter.org/github/fredrikekre/Literate.jl/blob/gh-pages/v1.2.0/" "Link to nbviewer: https://nbviewer.jupyter.org/github/fredrikekre/Literate.jl/blob/gh-pages/v1.2.0/"
] ]
""", """,
""" """
"source": [ "source": [
"# name: inputfile\\n",
"# Link to repo root: https://github.com/fredrikekre/Literate.jl/blob/master/\\n",
"# Link to nbviewer: https://nbviewer.jupyter.org/github/fredrikekre/Literate.jl/blob/gh-pages/v1.2.0/" "# Link to nbviewer: https://nbviewer.jupyter.org/github/fredrikekre/Literate.jl/blob/gh-pages/v1.2.0/"
] ]
""", """,
@ -526,7 +524,10 @@ end
# name # name
Literate.notebook(inputfile, outdir, name = "foobar", execute = false) Literate.notebook(inputfile, outdir, name = "foobar", execute = false)
@test isfile(joinpath(outdir, "foobar.ipynb")) notebook = read(joinpath(outdir, "foobar.ipynb"), String)
@test contains(notebook, "name: foobar")
@test !contains(notebook, "name: inputfile")
@test !contains(notebook, "name: @__NAME__")
end end
end end
end end

Loading…
Cancel
Save