1##############################################################################
2# Test that CRLF is handled correctly on Windows.
3##############################################################################
4
5body common control
6{
7  inputs => { "../../default.cf.sub" };
8  bundlesequence => { default("$(this.promise_filename)") };
9  version => "1.0";
10}
11
12#######################################################
13
14bundle agent init
15{
16  meta:
17      "test_skip_unsupported" string => "!windows";
18
19  vars:
20      "datadir" string => "$(this.promise_dirname)/crlf_data";
21      "filelist" slist => { "file-with-lf.txt",
22                            "file-with-crlf.txt",
23                            "file-with-mixed-eol.txt"
24                          };
25
26  files:
27      "$(G.testdir)/."
28        create => "yes";
29      "$(G.testdir)/$(filelist)"
30        copy_from => copy_file("$(filelist)");
31}
32
33body copy_from copy_file(file)
34{
35  source => "$(datadir)/$(file)";
36}
37
38#######################################################
39
40bundle agent test
41{
42  files:
43      "$(G.testdir)/$(init.filelist)"
44        edit_line => insert_line;
45}
46
47bundle edit_line insert_line
48{
49  insert_lines:
50      "Inserted line"
51        select_region => second_line;
52      "Inserted block
53Block line 1
54Block line 2"
55        select_region => third_line;
56}
57
58body select_region second_line
59{
60  select_start => "alpha";
61  select_end   => "beta";
62}
63
64body select_region third_line
65{
66  select_start => "beta";
67  select_end   => "charlie";
68}
69
70#######################################################
71
72bundle agent check
73{
74  vars:
75      "ok_classes" slist => { "diff_ok_file_with_lf_txt",
76                              "diff_ok_file_with_crlf_txt",
77                              "diff_ok_file_with_mixed_eol_txt",
78                              "size_ok_file_with_lf_txt",
79                              "size_ok_file_with_crlf_txt",
80                              "size_ok_file_with_mixed_eol_txt"
81                    };
82      "classes_set" slist => classesmatching("(diff|size)_ok.*");
83  classes:
84      "diff_ok_$(init.filelist)" expression => returnszero(
85          "$(G.diff) $(G.testdir)/$(init.filelist) $(init.datadir)/$(init.filelist).expected >$(G.dev_null) 2>&1",
86          "useshell");
87      "size_ok_$(init.filelist)" expression => strcmp(filestat("$(G.testdir)/$(init.filelist)", "size"),
88                                                      filestat("$(init.datadir)/$(init.filelist).expected", "size"));
89
90      "ok" and => { @(ok_classes) };
91
92  reports:
93    DEBUG.!ok::
94      "Classes expected: $(ok_classes)";
95      "Classes actually set: $(classes_set)";
96    ok::
97      "$(this.promise_filename) Pass";
98    !ok::
99      "$(this.promise_filename) FAIL";
100}
101