Modify

Opened 6 weeks ago

Closed 3 minutes ago

#17932 closed defect (fixed)

Update OpeningHourTest.java to enable propper logging

Reported by: SlowMo24 Owned by: Don-vip
Priority: normal Milestone: 19.08
Component: Core validator Version:
Keywords: opening_hours nashorn javascript Cc: ypid

Description (last modified by Don-vip)

What steps will reproduce the problem?

  1. set tag of an entity to 'opening_hours=SH off'
  2. click validate

What is the expected result?

Throw a proper error message to track down the problem like

javax.script.ScriptException: An error occurred during evaluation of the value "SH off". Please submit a pull request: https://github.com/ypid/opening_hours.js. no SH definition in <eval> at line number 46 at column number 4733. Cause: [...]

What happens instead?

the following error-message is shown:

javax.script.ScriptException: ReferenceError: "console" is not defined in <eval> at line number 44. Ursache: [...]

Solution

Add

                ENGINE.eval(
                    "var global=this;var window=this;var process={env:{}};" +
                    "var console={};console.debug=print;console.log=print;console.warn=print;console.error=print;");

to the initialize() method of OpeningHourTestPatch.java as done in https://github.com/opening-hours/opening_hours.java/issues/1

Please provide any additional information below. Attach a screenshot if possible.

Relative:URL: ^/trunk
Repository:UUID: 0c6e7542-c601-0410-84e7-c038aed88b3b
Last:Changed Date: 2019-07-10 00:52:47 +0200 (Wed, 10 Jul 2019)
Revision:15238
Build-Date:2019-07-10 01:30:51
URL:https://josm.openstreetmap.de/svn/trunk

Identification: JOSM/1.5 (15238 de) Linux Ubuntu 18.04.2 LTS
Memory Usage: 449 MB / 4006 MB (329 MB allocated, but free)
Java version: 11.0.3+7-Ubuntu-1ubuntu218.04.1, Oracle Corporation, OpenJDK 64-Bit Server VM
Screen: :0.0 1920x1080, :0.1 1280x1024
Maximum Screen Size: 1920x1080
Java package: openjdk-11-jre:amd64-11.0.3+7-1ubuntu2~18.04.1
Java ATK Wrapper package: libatk-wrapper-java:all-0.33.3-20ubuntu0.1
libcommons-logging-java: libcommons-logging-java:all-1.2-2
fonts-noto: fonts-noto:-
Dataset consistency test: No problems found

Plugins:
+ FastDraw (34977)
+ OpeningHoursEditor (34977)
+ buildings_tools (34982)
+ pt_assistant (705)
+ wikipedia (v1.1.1)

Map paint styles:
+ https://josm.openstreetmap.de/josmfile?page=Styles/PublicTransport&zip=1

Last errors/warnings:
- W: No configuration settings found.  Using hardcoded default values for all pools.
- W: javax.script.ScriptException: ReferenceError: "console" is not defined in <eval> at line number 44. Ursache: jdk.nashorn.internal.runtime.ECMAException: ReferenceError: "console" is not defined
- E: javax.script.ScriptException: ReferenceError: "console" is not defined in <eval> at line number 44. Ursache: jdk.nashorn.internal.runtime.ECMAException: ReferenceError: "console" is not defined

Attachments (0)

Change History (11)

comment:1 Changed 6 weeks ago by Don-vip

Keywords: opening_hours javascript added; openinghour removed
Milestone: 19.08
Version: tested

comment:2 Changed 6 weeks ago by Don-vip

Type: enhancementdefect

comment:3 Changed 6 weeks ago by Don-vip

Description: modified (diff)

comment:4 Changed 3 weeks ago by Don-vip

Description: modified (diff)
Owner: changed from team to Don-vip
Status: newassigned

comment:5 Changed 3 weeks ago by Don-vip

Description: modified (diff)

comment:6 Changed 3 weeks ago by Don-vip

Resolution: fixed
Status: assignedclosed

In 15277/josm:

fix #17932 - Update OpeningHourTest to enable propper logging

See https://github.com/opening-hours/opening_hours.java/issues/1

comment:7 Changed 3 weeks ago by Don-vip

Cc: ypid added
Resolution: fixed
Status: closedreopened

The fix breaks error message localization. This test now fails:

    @Test
    public void testI18n() {
        System.out.println(openingHourTest.checkOpeningHourSyntax("opening_hours", ".", null, false, "de")
                .get(0).toString());
        assertTrue(openingHourTest.checkOpeningHourSyntax("opening_hours", ".", null, false, "de")
                .get(0).toString().contains("Unerwartetes Zeichen"));
        assertFalse(openingHourTest.checkOpeningHourSyntax("opening_hours", ".", null, false, "en")
                .get(0).toString().contains("Unerwartetes Zeichen"));
    }

@ypid do you see why?

comment:8 Changed 3 weeks ago by skyper

I get exceptions now:

URL:https://josm.openstreetmap.de/svn/trunk
Repository:UUID: 0c6e7542-c601-0410-84e7-c038aed88b3b
Last:Changed Date: 2019-08-05 20:49:54 +0200 (Mon, 05 Aug 2019)
Build-Date:2019-08-06 01:30:53
Revision:15283
Relative:URL: ^/trunk

Validator rules:
+ https://josm.openstreetmap.de/josmfile?page=Rules/GermanySpecific&zip=1

Last errors/warnings:
- W: No configuration settings found.  Using hardcoded default values for all pools.
- W: java.net.SocketTimeoutException: Read timed out
- W: javax.script.ScriptException: An error occurred during evaluation of the value "Mo-Fr 15:30-16:05; Sa,Su,SH,PH off". Please submit a pull request: https://github.com/ypid/opening_hours.js. no SH definition in <eval> at line number 46 at column number 4733. Cause: jdk.nashorn.internal.runtime.ECMAException: An error occurred during evaluation of the value "Mo-Fr 15:30-16:05; Sa,Su,SH,PH off". Please submit a pull request: https://github.com/ypid/opening_hours.js. no SH definition
- E: javax.script.ScriptException: An error occurred during evaluation of the value "Mo-Fr 15:30-16:05; Sa,Su,SH,PH off". Please submit a pull request: https://github.com/ypid/opening_hours.js. no SH definition in <eval> at line number 46 at column number 4733. Cause: jdk.nashorn.internal.runtime.ECMAException: An error occurred during evaluation of the value "Mo-Fr 15:30-16:05; Sa,Su,SH,PH off". Please submit a pull request: https://github.com/ypid/opening_hours.js. no SH definition

terminal output:

An error occurred during evaluation of the value "Mo-Fr 15:30-16:05; Sa,Su,SH,PH off". Please submit a pull request: https://github.com/ypid/opening_hours.js. no SH definition
2019-08-06 22:49:04.331 WARNING: javax.script.ScriptException: An error occurred during evaluation of the value "Mo-Fr 15:30-16:05; Sa,Su,SH,PH off". Please submit a pull request: https://github.com/ypid/opening_hours.js. no SH definition in <eval> at line number 46 at column number 4733. Cause: jdk.nashorn.internal.runtime.ECMAException: An error occurred during evaluation of the value "Mo-Fr 15:30-16:05; Sa,Su,SH,PH off". Please submit a pull request: https://github.com/ypid/opening_hours.js. no SH definition
javax.script.ScriptException: An error occurred during evaluation of the value "Mo-Fr 15:30-16:05; Sa,Su,SH,PH off". Please submit a pull request: https://github.com/ypid/opening_hours.js. no SH definition in <eval> at line number 46 at column number 4733
	at jdk.nashorn.api.scripting.NashornScriptEngine.throwAsScriptException(NashornScriptEngine.java:470)
	at jdk.nashorn.api.scripting.NashornScriptEngine.invokeImpl(NashornScriptEngine.java:392)
	at jdk.nashorn.api.scripting.NashornScriptEngine.invokeMethod(NashornScriptEngine.java:199)
	at org.openstreetmap.josm.data.validation.tests.OpeningHourTest.getOpeningHoursPrettifiedValues(OpeningHourTest.java:268)
	at org.openstreetmap.josm.data.validation.tests.OpeningHourTest.checkOpeningHourSyntax(OpeningHourTest.java:239)
	at org.openstreetmap.josm.data.validation.tests.OpeningHourTest.checkOpeningHourSyntax(OpeningHourTest.java:215)
	at org.openstreetmap.josm.data.validation.tests.OpeningHourTest.check(OpeningHourTest.java:324)
	at org.openstreetmap.josm.data.validation.tests.OpeningHourTest.check(OpeningHourTest.java:332)
	at org.openstreetmap.josm.data.validation.Test$TagTest.visit(Test.java:138)
	at org.openstreetmap.josm.data.osm.Relation.accept(Relation.java:174)
	at org.openstreetmap.josm.data.validation.Test.visit(Test.java:213)
	at org.openstreetmap.josm.actions.ValidateAction$ValidationTask.realRun(ValidateAction.java:168)
	at org.openstreetmap.josm.gui.PleaseWaitRunnable.doRealRun(PleaseWaitRunnable.java:94)
	at org.openstreetmap.josm.gui.PleaseWaitRunnable.run(PleaseWaitRunnable.java:142)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
Caused by: <eval>:46:4733 An error occurred during evaluation of the value "Mo-Fr 15:30-16:05; Sa,Su,SH,PH off". Please submit a pull request: https://github.com/ypid/opening_hours.js. no SH definition
	at jdk.nashorn.internal.runtime.ECMAException.create(ECMAException.java:113)
	at jdk.nashorn.internal.scripts.Script$Recompilation$148$285644AAA$\^eval\_.opening_hours#L:44#L:44#getSHForYear(<eval>:46)
	at jdk.nashorn.internal.scripts.Script$Recompilation$146$283006A$\^eval\_.opening_hours#L:44#L:44#parseHoliday#selector-1#L:46(<eval>:46)
	at jdk.nashorn.internal.scripts.Script$Recompilation$122$305594A$\^eval\_.opening_hours#L:44#L:44#getStatePair(<eval>:46)
	at jdk.nashorn.internal.scripts.Script$Recompilation$121$314717A$\^eval\_.opening_hours#L:44#L:44#getIterator#L:47(<eval>:47)
	at jdk.nashorn.internal.scripts.Script$Recompilation$120$314693A$\^eval\_.opening_hours#L:44#L:44#getIterator(<eval>:47)
	at jdk.nashorn.internal.scripts.Script$Recompilation$119$311828$\^eval\_.opening_hours#L:44#L:44#getWarnings-1(<eval>:46)
	at jdk.nashorn.internal.scripts.Script$Recompilation$118$311921A$\^eval\_.opening_hours#L:44#L:44#prettifyValue-1(<eval>:46)
	at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:639)
	at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:494)
	at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:393)
	at jdk.nashorn.api.scripting.ScriptObjectMirror.callMember(ScriptObjectMirror.java:199)
	at jdk.nashorn.api.scripting.NashornScriptEngine.invokeImpl(NashornScriptEngine.java:386)
	... 17 more
Last edited 3 weeks ago by skyper (previous) (diff)

comment:9 in reply to:  8 ; Changed 3 weeks ago by Don-vip

Replying to skyper:

I get exceptions now:

Yes, that's the intended behaviour. The exception is raised by the opening_hours library:
An error occurred during evaluation of the value "Mo-Fr 15:30-16:05; Sa,Su,SH,PH off". Please submit a pull request: https://github.com/ypid/opening_hours.js. no SH definition

comment:10 in reply to:  9 Changed 2 weeks ago by SlowMo24

Replying to Don-vip:

Replying to skyper:

I get exceptions now:

Please see https://josm.openstreetmap.de/ticket/17936 and https://github.com/opening-hours/opening_hours.js/issues/86#issuecomment-513255975 for possible solutions of the error that was hidden by the bug reported in this ticket.

comment:11 Changed 3 minutes ago by Don-vip

Resolution: fixed
Status: reopenedclosed

In 15318/josm:

fix #17932 - fix error message localization

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Don-vip.
as The resolution will be set.
The resolution will be deleted.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.