@@ -2,13 +2,8 @@ defmodule Mix.Tasks.Tableau.LogExtension do
2
2
@ moduledoc false
3
3
use Tableau.Extension , key: :log , type: :pre_build , priority: 200
4
4
5
- defmodule Config do
6
- @ moduledoc false
7
- def new ( i ) , do: { :ok , i }
8
- end
9
-
10
5
def run ( token ) do
11
- IO . inspect ( System . monotonic_time ( ) , label: "second ")
6
+ IO . write ( :stderr , "second: #{ System . monotonic_time ( ) } \n ")
12
7
{ :ok , token }
13
8
end
14
9
end
@@ -18,7 +13,7 @@ defmodule Mix.Tasks.Tableau.FailExtension do
18
13
use Tableau.Extension , key: :fail , type: :pre_build , priority: 100
19
14
20
15
def run ( _site ) do
21
- IO . inspect ( System . monotonic_time ( ) , label: "first ")
16
+ IO . write ( :stderr , "first: #{ System . monotonic_time ( ) } \n ")
22
17
:error
23
18
end
24
19
end
@@ -145,8 +140,38 @@ defmodule Mix.Tasks.Tableau.BuildTest do
145
140
146
141
@ tag :tmp_dir
147
142
test "renders all pages" , % { tmp_dir: out } do
143
+ posts = out |> Path . join ( "_posts" ) |> tap ( & File . mkdir_p! / 1 )
144
+ pages = out |> Path . join ( "_pages" ) |> tap ( & File . mkdir_p! / 1 )
145
+ Application . put_env ( :tableau , Tableau.PostExtension , enabled: true , dir: posts )
146
+ Application . put_env ( :tableau , Tableau.PageExtension , enabled: true , dir: pages )
147
+
148
+ File . write ( Path . join ( posts , "my-post.md" ) , """
149
+ ---
150
+ layout: Mix.Tasks.Tableau.BuildTest.RootLayout
151
+ title: A Bing Bong Blog Post
152
+ date: 2017-02-28
153
+ categories: post
154
+ permalink: /:title/
155
+ ---
156
+
157
+ ## Bing
158
+
159
+ Bong!
160
+ """ )
161
+
162
+ page_path = pages |> Path . join ( "some/deeply/nested/page" ) |> tap ( & File . mkdir_p! / 1 ) |> Path . join ( "/my-page.md" )
163
+
164
+ File . write ( page_path , """
165
+ ---
166
+ layout: Mix.Tasks.Tableau.BuildTest.RootLayout
167
+ title: Beginner Tutorial
168
+ ---
169
+
170
+ ## How to get started
171
+ """ )
172
+
148
173
{ log , io } =
149
- with_io ( fn ->
174
+ with_io ( :stderr , fn ->
150
175
{ _ , log } =
151
176
with_log ( fn ->
152
177
_documents = Build . run ( [ "--out" , out ] )
@@ -171,5 +196,7 @@ defmodule Mix.Tasks.Tableau.BuildTest do
171
196
172
197
assert File . exists? ( Path . join ( out , "/index.html" ) )
173
198
assert File . exists? ( Path . join ( out , "/about/index.html" ) )
199
+ assert File . exists? ( Path . join ( out , "/a-bing-bong-blog-post/index.html" ) )
200
+ assert File . exists? ( Path . join ( out , "/some/deeply/nested/page/my-page/index.html" ) )
174
201
end
175
202
end
0 commit comments