File tree 3 files changed +37
-1
lines changed
3 files changed +37
-1
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ enum CodegenFileType: int {
24
24
HACK_DECL = 1 ;
25
25
HACK_PARTIAL = 2 ;
26
26
HACK_STRICT = 3 ;
27
+ DOT_HACK = 4 ;
27
28
}
28
29
29
30
/**
@@ -223,6 +224,8 @@ final class CodegenFile {
223
224
return ' <?hh // partial' ;
224
225
case CodegenFileType :: HACK_STRICT :
225
226
return ' <?hh // strict' ;
227
+ case CodegenFileType :: DOT_HACK :
228
+ return ' ' ;
226
229
}
227
230
}
228
231
@@ -298,7 +301,10 @@ final class CodegenFile {
298
301
$builder -> addLine($shebang );
299
302
}
300
303
301
- $builder -> addLine($this -> getFileTypeDeclaration());
304
+ $decl = $this -> getFileTypeDeclaration();
305
+ if ($decl !== ' ' ) {
306
+ $builder -> addLine($decl );
307
+ }
302
308
$header = $this -> config -> getFileHeader();
303
309
if ($header ) {
304
310
foreach ($header as $line ) {
Original file line number Diff line number Diff line change @@ -35,6 +35,20 @@ const string FOO = 'bar';
35
35
*/
36
36
const string HERP = 'derp';
37
37
38
+ !@#$%codegentest:testDotHackExecutable
39
+ #!/usr/bin/env hhvm
40
+ // Codegen Tests
41
+ /**
42
+ * This file is generated. Do not modify it manually!
43
+ *
44
+ * @-generated SignedSource<<2e680a68425d6302b789a6588a8218e4>>
45
+ */
46
+
47
+ <<__EntryPoint>>
48
+ function main(): noreturn {
49
+ exit(0);
50
+ }
51
+
38
52
!@#$%codegentest:testExecutable
39
53
#!/usr/bin/env hhvm
40
54
<?hh // partial
Original file line number Diff line number Diff line change @@ -316,6 +316,22 @@ final class CodegenFileTest extends CodegenBaseTest {
316
316
);
317
317
}
318
318
319
+ public function testDotHackExecutable (): void {
320
+ $cgf = $this -> getCodegenFactory();
321
+ $code = $cgf
322
+ -> codegenFile(' no_file' )
323
+ -> setFileType(CodegenFileType :: DOT_HACK )
324
+ -> setShebangLine(' #!/usr/bin/env hhvm' )
325
+ -> addFunction(
326
+ $cgf -> codegenFunction(' main' )
327
+ -> setReturnType(' noreturn' )
328
+ -> addEmptyUserAttribute(' __EntryPoint' )
329
+ -> setBody(' exit(0);' )
330
+ )
331
+ -> render();
332
+ expect_with_context (static :: class , $code )-> toBeUnchanged();
333
+ }
334
+
319
335
public function testNoPseudoMainHeaderInStrict (): void {
320
336
expect (() ==> {
321
337
$cgf = $this -> getCodegenFactory();
You can’t perform that action at this time.
0 commit comments