Skip to content

Commit 3bb322e

Browse files
authored
Merge pull request #393 from wttech/388-double-slash-comments-are-silently-breaking-script-execution
double slash comments are silently breaking script execution #388
2 parents 410a7cf + 85a1cd2 commit 3bb322e

File tree

20 files changed

+289
-8
lines changed

20 files changed

+289
-8
lines changed

app/aem/core/src/main/antlr/ApmLang.g4

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ grammar ApmLang;
2525
*/
2626

2727
apm
28-
: command+
28+
: command+ EOF
2929
;
3030

3131
name

app/aem/core/src/main/kotlin/com/cognifide/apm/core/grammar/parsedscript/ApmLangParserFactory.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ object ApmLangParserFactory {
4848
throw InvalidSyntaxException(InputMismatchException(recognizer))
4949
}
5050

51+
override fun reportError(recognizer: Parser?, e: RecognitionException?) {
52+
throw InvalidSyntaxException(e!!)
53+
}
54+
5155
override fun sync(recognizer: Parser) {}
5256
}
5357

app/aem/core/src/test/groovy/com/cognifide/apm/core/grammar/ScriptRunnerTest.groovy

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ package com.cognifide.apm.core.grammar
2323
import com.cognifide.apm.api.scripts.Script
2424
import com.cognifide.apm.api.services.ScriptFinder
2525
import com.cognifide.apm.api.status.Status
26-
import com.cognifide.apm.core.grammar.argument.Arguments
2726
import com.cognifide.apm.core.progress.ProgressImpl
2827
import org.apache.commons.io.IOUtils
2928
import org.apache.sling.api.resource.ResourceResolver
@@ -104,7 +103,7 @@ class ScriptRunnerTest extends Specification {
104103
def result = scriptExecutor.execute(script, new ProgressImpl(""))
105104

106105
then:
107-
result.entries.size() == 3
106+
result.entries.size() == 7
108107
result.entries[0].messages ==
109108
["Import from script /import-define.apm. Notice, only DEFINE actions were processed!",
110109
"Imported variable: var=\"imported val\""]
@@ -116,6 +115,11 @@ class ScriptRunnerTest extends Specification {
116115
result.entries[2].messages ==
117116
["Import from script /import-deep-define.apm. Notice, only DEFINE actions were processed!",
118117
"Imported variable: deepNamespace={deeperNamespace: {var: \"imported val\"}, deepVar: \"imported val + imported val\"}"]
118+
119+
result.entries[3].command == "Executing command SHOW \"imported val\""
120+
result.entries[4].command == "Executing command SHOW \"imported val\""
121+
result.entries[5].command == "Executing command SHOW \"imported val\""
122+
result.entries[6].command == "Executing command SHOW \"imported val + imported val\""
119123
}
120124

121125
def "run script filename.apm"() {

app/aem/core/src/test/groovy/com/cognifide/apm/core/grammar/parsedscript/ParsedScriptTest.groovy

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,20 @@ class ParsedScriptTest extends Specification {
4444
error == output
4545

4646
where:
47-
file | output
48-
"/invalid1.apm" | ["Invalid line [20:7]: DEFINE \$ nana", "Invalid sequence: \$"]
49-
"/invalid2.apm" | ["Invalid line [20:7]: DEFINE / nana"]
47+
file | output
48+
"/invalid/invalid1.apm" | ["Invalid line [20:7]: DEFINE \$ nana", "Invalid sequence: \$"]
49+
"/invalid/invalid2.apm" | ["Invalid line [20:7]: DEFINE / nana"]
50+
"/invalid/invalid3.apm" | ["Invalid line [20:0]: // define variable", "Invalid sequence: //"]
51+
"/invalid/invalid4.apm" | ["Invalid line [20:0]: / define variable"]
52+
"/invalid/invalid5.apm" | ["Invalid line [20:0]: /x define variable", "Invalid sequence: /x"]
53+
"/invalid/invalid6.apm" | ["Invalid line [20:0]: /* define variable", "Invalid sequence: /*"]
54+
"/invalid/invalid7.apm" | ["Invalid line [20:0]: <!-- define variable"]
55+
"/invalid/invalid8.apm" | ["Invalid line [21:0]: // define variable", "Invalid sequence: //"]
56+
"/invalid/invalid9.apm" | ["Invalid line [21:0]: / define variable"]
57+
"/invalid/invalid10.apm" | ["Invalid line [21:0]: /x define variable", "Invalid sequence: /x"]
58+
"/invalid/invalid11.apm" | ["Invalid line [21:0]: /* define variable", "Invalid sequence: /*"]
59+
"/invalid/invalid12.apm" | ["Invalid line [21:0]: <!-- define variable"]
60+
"/invalid/invalid13.apm" | ["Invalid line [20:0]: \"define variable\"", "Invalid sequence: \"define variable\""]
61+
"/invalid/invalid14.apm" | ["Invalid line [21:0]: \"define variable\"", "Invalid sequence: \"define variable\""]
5062
}
5163
}

app/aem/core/src/test/resources/import-and-run2.apm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@
1818
# =========================LICENSE_END==================================
1919
RUN '/includes/cycle-a.apm'
2020

21-
RUN '/includes/run-a.apm' AS namespace
21+
RUN '/includes/run-a.apm'

app/aem/core/src/test/resources/import.apm

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,9 @@
1818
# =========================LICENSE_END==================================
1919
IMPORT /import-define.apm
2020
IMPORT '/import-define.apm' AS namespace
21-
IMPORT '/import-deep-define.apm' AS deepNamespace
21+
IMPORT '/import-deep-define.apm' AS deepNamespace
22+
23+
SHOW $var
24+
SHOW $namespace.var
25+
SHOW $deepNamespace.deeperNamespace.var
26+
SHOW $deepNamespace.deepVar
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
2+
# ========================LICENSE_START=================================
3+
# AEM Permission Management
4+
# %%
5+
# Copyright (C) 2013 Wunderman Thompson Technology
6+
# %%
7+
# Licensed under the Apache License, Version 2.0 (the "License");
8+
# you may not use this file except in compliance with the License.
9+
# You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing, software
14+
# distributed under the License is distributed on an "AS IS" BASIS,
15+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
# See the License for the specific language governing permissions and
17+
# limitations under the License.
18+
# =========================LICENSE_END==================================
19+
20+
DEFINE nana "nana"
21+
/x define variable
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
# ========================LICENSE_START=================================
3+
# AEM Permission Management
4+
# %%
5+
# Copyright (C) 2013 Wunderman Thompson Technology
6+
# %%
7+
# Licensed under the Apache License, Version 2.0 (the "License");
8+
# you may not use this file except in compliance with the License.
9+
# You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing, software
14+
# distributed under the License is distributed on an "AS IS" BASIS,
15+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
# See the License for the specific language governing permissions and
17+
# limitations under the License.
18+
# =========================LICENSE_END==================================
19+
20+
DEFINE nana "nana"
21+
/* define variable
22+
*/
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
# ========================LICENSE_START=================================
3+
# AEM Permission Management
4+
# %%
5+
# Copyright (C) 2013 Wunderman Thompson Technology
6+
# %%
7+
# Licensed under the Apache License, Version 2.0 (the "License");
8+
# you may not use this file except in compliance with the License.
9+
# You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing, software
14+
# distributed under the License is distributed on an "AS IS" BASIS,
15+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
# See the License for the specific language governing permissions and
17+
# limitations under the License.
18+
# =========================LICENSE_END==================================
19+
20+
DEFINE nana "nana"
21+
<!-- define variable
22+
-->
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
2+
# ========================LICENSE_START=================================
3+
# AEM Permission Management
4+
# %%
5+
# Copyright (C) 2013 Wunderman Thompson Technology
6+
# %%
7+
# Licensed under the Apache License, Version 2.0 (the "License");
8+
# you may not use this file except in compliance with the License.
9+
# You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing, software
14+
# distributed under the License is distributed on an "AS IS" BASIS,
15+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
# See the License for the specific language governing permissions and
17+
# limitations under the License.
18+
# =========================LICENSE_END==================================
19+
20+
"define variable"
21+
DEFINE nana "nana"
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
2+
# ========================LICENSE_START=================================
3+
# AEM Permission Management
4+
# %%
5+
# Copyright (C) 2013 Wunderman Thompson Technology
6+
# %%
7+
# Licensed under the Apache License, Version 2.0 (the "License");
8+
# you may not use this file except in compliance with the License.
9+
# You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing, software
14+
# distributed under the License is distributed on an "AS IS" BASIS,
15+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
# See the License for the specific language governing permissions and
17+
# limitations under the License.
18+
# =========================LICENSE_END==================================
19+
20+
DEFINE nana "nana"
21+
"define variable"
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
2+
# ========================LICENSE_START=================================
3+
# AEM Permission Management
4+
# %%
5+
# Copyright (C) 2013 Wunderman Thompson Technology
6+
# %%
7+
# Licensed under the Apache License, Version 2.0 (the "License");
8+
# you may not use this file except in compliance with the License.
9+
# You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing, software
14+
# distributed under the License is distributed on an "AS IS" BASIS,
15+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
# See the License for the specific language governing permissions and
17+
# limitations under the License.
18+
# =========================LICENSE_END==================================
19+
20+
// define variable
21+
DEFINE / nana
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
2+
# ========================LICENSE_START=================================
3+
# AEM Permission Management
4+
# %%
5+
# Copyright (C) 2013 Wunderman Thompson Technology
6+
# %%
7+
# Licensed under the Apache License, Version 2.0 (the "License");
8+
# you may not use this file except in compliance with the License.
9+
# You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing, software
14+
# distributed under the License is distributed on an "AS IS" BASIS,
15+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
# See the License for the specific language governing permissions and
17+
# limitations under the License.
18+
# =========================LICENSE_END==================================
19+
20+
/ define variable
21+
DEFINE / nana
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
2+
# ========================LICENSE_START=================================
3+
# AEM Permission Management
4+
# %%
5+
# Copyright (C) 2013 Wunderman Thompson Technology
6+
# %%
7+
# Licensed under the Apache License, Version 2.0 (the "License");
8+
# you may not use this file except in compliance with the License.
9+
# You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing, software
14+
# distributed under the License is distributed on an "AS IS" BASIS,
15+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
# See the License for the specific language governing permissions and
17+
# limitations under the License.
18+
# =========================LICENSE_END==================================
19+
20+
/x define variable
21+
DEFINE / nana
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
# ========================LICENSE_START=================================
3+
# AEM Permission Management
4+
# %%
5+
# Copyright (C) 2013 Wunderman Thompson Technology
6+
# %%
7+
# Licensed under the Apache License, Version 2.0 (the "License");
8+
# you may not use this file except in compliance with the License.
9+
# You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing, software
14+
# distributed under the License is distributed on an "AS IS" BASIS,
15+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
# See the License for the specific language governing permissions and
17+
# limitations under the License.
18+
# =========================LICENSE_END==================================
19+
20+
/* define variable
21+
*/
22+
DEFINE / nana
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
# ========================LICENSE_START=================================
3+
# AEM Permission Management
4+
# %%
5+
# Copyright (C) 2013 Wunderman Thompson Technology
6+
# %%
7+
# Licensed under the Apache License, Version 2.0 (the "License");
8+
# you may not use this file except in compliance with the License.
9+
# You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing, software
14+
# distributed under the License is distributed on an "AS IS" BASIS,
15+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
# See the License for the specific language governing permissions and
17+
# limitations under the License.
18+
# =========================LICENSE_END==================================
19+
20+
<!-- define variable
21+
-->
22+
DEFINE / nana
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
2+
# ========================LICENSE_START=================================
3+
# AEM Permission Management
4+
# %%
5+
# Copyright (C) 2013 Wunderman Thompson Technology
6+
# %%
7+
# Licensed under the Apache License, Version 2.0 (the "License");
8+
# you may not use this file except in compliance with the License.
9+
# You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing, software
14+
# distributed under the License is distributed on an "AS IS" BASIS,
15+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
# See the License for the specific language governing permissions and
17+
# limitations under the License.
18+
# =========================LICENSE_END==================================
19+
20+
DEFINE nana "nana"
21+
// define variable
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
2+
# ========================LICENSE_START=================================
3+
# AEM Permission Management
4+
# %%
5+
# Copyright (C) 2013 Wunderman Thompson Technology
6+
# %%
7+
# Licensed under the Apache License, Version 2.0 (the "License");
8+
# you may not use this file except in compliance with the License.
9+
# You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing, software
14+
# distributed under the License is distributed on an "AS IS" BASIS,
15+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
# See the License for the specific language governing permissions and
17+
# limitations under the License.
18+
# =========================LICENSE_END==================================
19+
20+
DEFINE nana "nana"
21+
/ define variable

0 commit comments

Comments
 (0)