1 // This program is used to split tailcall-interface-conservestack.il into separate tests.
3 // Algorithm is just to split on special inserted markers.
5 // mkdir tailcall/interface-conservestack
6 // rm tailcall-interface-conservestack-*
7 // git rm tailcall-interface-conservestack-*
8 // g++ split-tailcall-interface-conservestack.cpp && ./a.out < tailcall-interface-conservestack.il
9 // git add tailcall/interface-conservestack/*.il
11 // Note This is valid C++98 for use with older compilers, where C++11 would be desirable.
24 typedef vector
<string
> strings_t
;
29 typedef vector
<test_t
> tests_t
;
32 CreateDir (const char *a
)
47 test_t
*test
= &test_dummy
;
50 while (getline(cin
, line
) && line
!= "// test-split-prefix do not remove or edit this line")
51 prefix
.push_back(line
);
53 while (getline (cin
, line
))
55 if (!line
.length()) // tests are delimited by empty lines
57 tests
.resize(tests
.size() + 1);
59 assert(getline(cin
, line
));
60 if (line
== "// test-split-suffix do not remove or edit this line")
63 test
->content
.push_back(line
);
65 while (getline (cin
, line
))
66 suffix
.push_back(line
);
70 CreateDir ("tailcall");
71 CreateDir ("tailcall/interface-conservestack");
73 for (tests_t::iterator test
= tests
.begin(); test
!= tests
.end(); ++test
)
76 sprintf(buffer
, "%d", ++i
);
77 //printf("%s\n", buffer);
78 FILE* output
= fopen((string("tailcall/interface-conservestack/") + buffer
+ ".il").c_str(), "w");
79 for (strings_t::const_iterator s
= prefix
.begin(); s
!= prefix
.end(); ++s
)
80 fprintf(output
, "%s\n", s
->c_str());
82 for (strings_t::const_iterator s
= test
->content
.begin(); s
!= test
->content
.end(); ++s
)
83 fprintf(output
, "%s\n", s
->c_str());
85 for (strings_t::const_iterator s
= suffix
.begin(); s
!= suffix
.end(); ++s
)
86 fprintf(output
, "%s\n", s
->c_str());