@@ -1926,6 +1926,95 @@ var parseFixtures = []parseFixture{
1926
1926
},
1927
1927
},
1928
1928
}},
1929
+ {"lua-block-tricky" , "" , ParseOptions {
1930
+ SingleFile : true ,
1931
+ ErrorOnUnknownDirectives : true ,
1932
+ ParseComments : true ,
1933
+ MatchFuncs : []MatchFunc {MatchLua },
1934
+ LexOptions : LexOptions {
1935
+ ExternalLexers : []ExtLexer {
1936
+ & LuaLexer {},
1937
+ },
1938
+ },
1939
+ }, Payload {
1940
+ Status : "ok" ,
1941
+ Errors : []PayloadError {},
1942
+ Config : []Config {
1943
+ {
1944
+ File : getTestConfigPath ("lua-block-tricky" , "nginx.conf" ),
1945
+ Status : "ok" ,
1946
+ Parsed : Directives {
1947
+ {
1948
+ Directive : "http" ,
1949
+ Line : 1 ,
1950
+ Args : []string {},
1951
+ Block : Directives {
1952
+ {
1953
+ Directive : "server" ,
1954
+ Line : 2 ,
1955
+ Args : []string {},
1956
+ Block : Directives {
1957
+ {
1958
+ Directive : "listen" ,
1959
+ Line : 3 ,
1960
+ Args : []string {"127.0.0.1:8080" },
1961
+ Block : Directives {},
1962
+ },
1963
+ {
1964
+ Directive : "server_name" ,
1965
+ Line : 4 ,
1966
+ Args : []string {"content_by_lua_block" },
1967
+ Block : Directives {},
1968
+ },
1969
+ {
1970
+ Directive : "#" ,
1971
+ Args : []string {},
1972
+ Line : 4 ,
1973
+ Comment : pStr (" make sure this doesn't trip up lexers" ),
1974
+ },
1975
+ {
1976
+ Directive : "set_by_lua_block" ,
1977
+ Line : 5 ,
1978
+ Args : []string {"$res" , " -- irregular lua block directive" +
1979
+ "\n local a = 32" +
1980
+ "\n local b = 56" +
1981
+ "\n " +
1982
+ "\n ngx.var.diff = a - b; -- write to $diff directly" +
1983
+ "\n return a + b; -- return the $sum value normally" +
1984
+ "\n " },
1985
+ Block : Directives {},
1986
+ },
1987
+ {
1988
+ Directive : "rewrite_by_lua_block" ,
1989
+ Line : 12 ,
1990
+ Args : []string {" -- have valid braces in Lua code and quotes around directive" +
1991
+ "\n do_something(\" hello, world!\\ nhiya\\ n\" )" +
1992
+ "\n a = { 1, 2, 3 }" +
1993
+ "\n btn = iup.button({title=\" ok\" })" +
1994
+ "\n " },
1995
+ Block : Directives {},
1996
+ },
1997
+ },
1998
+ },
1999
+ {
2000
+ Directive : "upstream" ,
2001
+ Line : 18 ,
2002
+ Args : []string {"content_by_lua_block" },
2003
+ Block : Directives {
2004
+ {
2005
+ Directive : "#" ,
2006
+ Args : []string {},
2007
+ Line : 19 ,
2008
+ Comment : pStr (" stuff" ),
2009
+ },
2010
+ },
2011
+ },
2012
+ },
2013
+ },
2014
+ },
2015
+ },
2016
+ },
2017
+ }},
1929
2018
}
1930
2019
1931
2020
func TestParse (t * testing.T ) {
0 commit comments