Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/autofonce_core/parser.ml
Original file line number Diff line number Diff line change
Expand Up @@ -293,11 +293,17 @@ let load_file ~dirs ~keep_files ~path c filename =
let content = M4Parser.to_string content in
AT_DATA { file ; content }

| Macro ( ( "AF_DATA_FILE" ) , [ file ; content_file]) ->
| Macro ( ( "AF_DATA_COPY" ) , [ file ; content_file]) ->
let file = M4Parser.to_string file in
let content_file = M4Parser.to_string content_file in
let dir = Filename.dirname macro.loc.file in
AF_DATA_FILE { file ; dir ; content_file }
AF_DATA_COPY { file ; dir ; content_file }

| Macro ( ( "AF_DATA_LINK" ) , [ file ; content_file]) ->
let file = M4Parser.to_string file in
let content_file = M4Parser.to_string content_file in
let dir = Filename.dirname macro.loc.file in
AF_DATA_LINK { file ; dir ; content_file }

| Macro ( ( "AF_CAPTURE_FILE" | "AT_CAPTURE_FILE" ) , [ file ] ) ->
let file = M4Parser.to_string file in
Expand Down
12 changes: 8 additions & 4 deletions src/autofonce_core/types.ml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ type check = { (* variable name is `check` *)

and action =
| AT_DATA of { file:string ; content: string }
| AF_DATA_FILE of { file:string ; dir : string ; content_file: string }
| AT_CAPTURE_FILE of string
| AT_XFAIL
| AT_XFAIL_IF of { step : step ; loc : location ; command : string }
Expand All @@ -58,6 +57,8 @@ and action =
promote : bool ; (* explicit or implicit ? *)
}
| AF_COMMENT of string
| AF_DATA_LINK of { file:string ; dir : string ; content_file: string }
| AF_DATA_COPY of { file:string ; dir : string ; content_file: string }

and test = { (* variable name is `t` *)
test_suite : suite ;
Expand Down Expand Up @@ -91,9 +92,6 @@ let string_of_location = Autofonce_m4.M4Printer.string_of_location
let rec string_of_action = function
| AT_DATA { file ; content } ->
Printf.sprintf "AT_DATA ( file=%S, content=%s )" file content
| AF_DATA_FILE { file ; dir ; content_file } ->
Printf.sprintf "AF_DATA_FILE ( file=%S, dir=%s, content_file=%s )"
file dir content_file
| AT_CAPTURE_FILE string ->
Printf.sprintf "AT_CAPTURE_FILE %s" string
| AT_XFAIL -> "AT_XFAIL_IF([true])"
Expand All @@ -118,6 +116,12 @@ let rec string_of_action = function
Printf.sprintf "AF_ENV %S" env
| AF_COMMENT comment ->
Printf.sprintf "AF_COMMENT %S" comment
| AF_DATA_COPY { file ; dir ; content_file } ->
Printf.sprintf "AF_DATA_COPY ( file=%S, dir=%s, content_file=%s )"
file dir content_file
| AF_DATA_LINK { file ; dir ; content_file } ->
Printf.sprintf "AF_DATA_LINK ( file=%S, dir=%s, content_file=%s )"
file dir content_file

and string_of_check_output = function
| Ignore -> "IGNORE"
Expand Down
3 changes: 2 additions & 1 deletion src/autofonce_lib/logging.ml
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ let log_checks ?failed_check state ter =
| AF_COMMENT _
| AF_COPY _
| AT_DATA _
| AF_DATA_FILE _
| AF_DATA_COPY _
| AF_DATA_LINK _
| AF_ENV _
| AT_CAPTURE_FILE _
| AT_XFAIL
Expand Down
8 changes: 6 additions & 2 deletions src/autofonce_lib/promote.ml
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,12 @@ let print_actions t ~ignore_exitcode ~keep_old b actions =
Printf.bprintf b "AT_DATA(%s, %s)\n"
( PARSER.m4_escape file )
( PARSER.m4_escape content )
| AF_DATA_FILE { file ; dir=_; content_file } ->
Printf.bprintf b "AF_DATA_FILE(%s, %s)\n"
| AF_DATA_COPY { file ; dir=_; content_file } ->
Printf.bprintf b "AF_DATA_COPY(%s, %s)\n"
( PARSER.m4_escape file )
( PARSER.m4_escape content_file )
| AF_DATA_LINK { file ; dir=_; content_file } ->
Printf.bprintf b "AF_DATA_LINK(%s, %s)\n"
( PARSER.m4_escape file )
( PARSER.m4_escape content_file )
| AF_ENV string ->
Expand Down
7 changes: 6 additions & 1 deletion src/autofonce_lib/runner_common.ml
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,12 @@ let exec_action_no_check ter action =
match action with
| AT_DATA { file ; content } ->
EzFile.write_text_file ( tester_dir ter // file ) content
| AF_DATA_FILE { file ; dir ; content_file } ->
| AF_DATA_COPY { file ; dir ; content_file } ->
let dst_file = tester_dir ter // file in
if Sys.file_exists dst_file then Unix.unlink dst_file;
let content = EzFile.read_file ( dir // content_file ) in
EzFile.write_file dst_file content
| AF_DATA_LINK { file ; dir ; content_file } ->
let dst_file = tester_dir ter // file in
if Sys.file_exists dst_file then Unix.unlink dst_file;
Unix.link ( dir // content_file ) dst_file
Expand Down
3 changes: 2 additions & 1 deletion src/autofonce_lib/runner_par.ml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ and schedule_action r action =
| AF_COMMENT _
| AT_XFAIL
| AT_DATA _
| AF_DATA_FILE _
| AF_DATA_COPY _
| AF_DATA_LINK _
| AT_CAPTURE_FILE _
| AT_CLEANUP _
| AF_ENV _
Expand Down
3 changes: 2 additions & 1 deletion src/autofonce_lib/runner_seq.ml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ let rec exec_action_or_check ter action =
| AF_COMMENT _
| AT_XFAIL
| AT_DATA _
| AF_DATA_FILE _
| AF_DATA_COPY _
| AF_DATA_LINK _
| AT_CAPTURE_FILE _
| AT_CLEANUP _
| AF_ENV _
Expand Down
8 changes: 8 additions & 0 deletions src/autofonce_m4/m4Lexer.mll
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,14 @@ and unescape = parse
| "@:>@" { quadrigraph lexbuf "]"; unescape lexbuf }
| "@S|@" { quadrigraph lexbuf "$"; unescape lexbuf }
| "@%:@" { quadrigraph lexbuf "#"; unescape lexbuf }
| "@&t@" ['0'-'9' ]+ "@&t@" {
let s = Lexing.lexeme lexbuf in
let len = String.length s in
let code = String.sub s 4 (len-8) in
let code = int_of_string code in
let c = char_of_int code in
let s = String.make 1 c in
quadrigraph lexbuf s; unescape lexbuf }
| "@&t@" { quadrigraph lexbuf ""; unescape lexbuf }
| "@{:@" { quadrigraph lexbuf "("; unescape lexbuf }
| "@:}@" { quadrigraph lexbuf ")"; unescape lexbuf }
Expand Down
Loading