CN111797009A - Method and device for detecting code compatibility and electronic equipment - Google Patents

Method and device for detecting code compatibility and electronic equipment Download PDF

Info

Publication number
CN111797009A
CN111797009A CN202010577194.7A CN202010577194A CN111797009A CN 111797009 A CN111797009 A CN 111797009A CN 202010577194 A CN202010577194 A CN 202010577194A CN 111797009 A CN111797009 A CN 111797009A
Authority
CN
China
Prior art keywords
function
application object
code
detected
determining
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202010577194.7A
Other languages
Chinese (zh)
Inventor
韩希鹏
刘秉楠
王聪
肖禅
杨远航
樊华
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing ByteDance Network Technology Co Ltd
Original Assignee
Beijing ByteDance Network Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing ByteDance Network Technology Co Ltd filed Critical Beijing ByteDance Network Technology Co Ltd
Priority to CN202010577194.7A priority Critical patent/CN111797009A/en
Publication of CN111797009A publication Critical patent/CN111797009A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3604Software analysis for verifying properties of programs
    • G06F11/3608Software analysis for verifying properties of programs using formal methods, e.g. model checking, abstract interpretation

Abstract

The embodiment of the disclosure discloses a method and a device for detecting code compatibility and electronic equipment. One embodiment of the method comprises: acquiring a code to be detected; determining an objective function included in the code to be detected; matching the target function with a first function indicated by pre-acquired information of the first function, wherein the first function is a function supported by a preset application object, and the information of the first function comprises an identifier of the first function and an identifier of the application object supporting the first function; and determining a target application object supporting the code to be detected based on the matching result. The efficiency of the compatibility test of the codes to be detected can be improved.

Description

Method and device for detecting code compatibility and electronic equipment
Technical Field
The present disclosure relates to the field of computer technologies, and in particular, to a method and an apparatus for detecting code compatibility, and an electronic device.
Background
In the process of code development, due to the diversity of the running environment of the code, the compatibility condition of the code on each application object needs to be judged to ensure that the code can be normally executed on each application object. For such detection, it is a common situation that a real machine/simulator is used to actually run the code on a low-version platform, and whether an error occurs is checked in the simulator, so as to determine the compatibility of the front-end code in each application object.
Disclosure of Invention
This disclosure is provided to introduce concepts in a simplified form that are further described below in the detailed description. This disclosure is not intended to identify key features or essential features of the claimed subject matter, nor is it intended to be used to limit the scope of the claimed subject matter.
The embodiment of the disclosure provides a method and a device for detecting code compatibility and electronic equipment.
In a first aspect, an embodiment of the present disclosure provides a method for detecting code compatibility, including: acquiring a code to be detected; determining an objective function included in the code to be detected; matching the target function with a first function indicated by pre-acquired information of the first function, wherein the first function is a function supported by a preset application object, and the information of the first function comprises an identifier of the first function and an identifier of the application object supporting the first function; and determining a target application object supporting the code to be detected based on the matching result.
In a second aspect, an embodiment of the present disclosure provides an apparatus for detecting code compatibility, including: the acquisition unit is used for acquiring a code to be detected; the first determining unit is used for determining an objective function included in the code to be detected; the matching unit is used for matching the target function with a first function indicated by pre-acquired information of the first function, wherein the first function is a function supported by a preset application object, and the information of the first function comprises an identifier of the first function and an identifier of the application object supporting the first function; and the second determining unit is used for determining the target application object supporting the code to be detected based on the matching result.
In a third aspect, an embodiment of the present disclosure provides an electronic device, including: one or more processors; storage means for storing one or more programs which, when executed by the one or more processors, cause the one or more processors to implement the method for detecting code compatibility as described in the first aspect.
In a fourth aspect, the disclosed embodiments provide a computer-readable medium, on which a computer program is stored, which when executed by a processor, implements the steps of the method for detecting code compatibility as described in the first aspect.
According to the method, the device and the electronic equipment for detecting the code compatibility, the code to be detected is obtained; determining an objective function included in the code to be detected; matching the target function with a first function indicated by pre-acquired information of the first function, wherein the first function is a function supported by a preset application object, and the information of the first function comprises an identifier of the first function and an identifier of the application object supporting the first function; and determining a target application object supporting the code to be detected based on the matching result. Matching a target function included in the code to be detected with a first function supported by a preset application object, and determining the compatibility of the code to be detected in the application object according to a matching result. Compared with the prior art, the code to be detected needs to be tested on the simulator of the real machine or the application object, the scheme provided by the embodiment does not need to be tested on the simulator of the real machine or the application object, the test speed of the compatibility test of the code can be improved, and the efficiency of the compatibility test of the code to be detected in each application object is higher.
Drawings
The above and other features, advantages and aspects of various embodiments of the present disclosure will become more apparent by referring to the following detailed description when taken in conjunction with the accompanying drawings. Throughout the drawings, the same or similar reference numbers refer to the same or similar elements. It should be understood that the drawings are schematic and that elements and features are not necessarily drawn to scale.
FIG. 1 is a flow diagram of one embodiment of a method for detecting code compatibility according to the present disclosure;
FIG. 2 is a diagram of an exemplary syntax tree structure;
FIG. 3 is a flow diagram of another embodiment of a method for detecting code compatibility according to the present disclosure;
FIG. 4 is a schematic block diagram illustrating one embodiment of an apparatus for detecting code compatibility according to the present disclosure;
FIG. 5 is an exemplary system architecture to which the method for detecting code compatibility of one embodiment of the present disclosure may be applied;
fig. 6 is a schematic diagram of a basic structure of an electronic device provided according to an embodiment of the present disclosure.
Detailed Description
Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While certain embodiments of the present disclosure are shown in the drawings, it is to be understood that the present disclosure may be embodied in various forms and should not be construed as limited to the embodiments set forth herein, but rather are provided for a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the disclosure are for illustration purposes only and are not intended to limit the scope of the disclosure.
It should be understood that the various steps recited in the method embodiments of the present disclosure may be performed in a different order, and/or performed in parallel. Moreover, method embodiments may include additional steps and/or omit performing the illustrated steps. The scope of the present disclosure is not limited in this respect.
The term "include" and variations thereof as used herein are open-ended, i.e., "including but not limited to". The term "based on" is "based, at least in part, on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". Relevant definitions for other terms will be given in the following description.
It should be noted that the terms "first", "second", and the like in the present disclosure are only used for distinguishing different devices, modules or units, and are not used for limiting the order or interdependence relationship of the functions performed by the devices, modules or units.
It is noted that references to "a", "an", and "the" modifications in this disclosure are intended to be illustrative rather than limiting, and that those skilled in the art will recognize that "one or more" may be used unless the context clearly dictates otherwise.
The names of messages or information exchanged between devices in the embodiments of the present disclosure are for illustrative purposes only, and are not intended to limit the scope of the messages or information.
Referring to FIG. 1, a flow diagram of one embodiment of a method for detecting code compatibility is shown, according to the present disclosure. The method for detecting code compatibility as shown in fig. 1 includes the following steps:
step 101, acquiring a code to be detected.
In this embodiment, the code to be detected may be a code to be run in a preset application object. The application object can be various application software and application programs.
In some application scenarios, the application object may be a browser.
When the application object is a browser, the code to be detected may be a code to be run on a browser page. Such as the code of a Web application embedded in a browser.
The acquiring of the code to be detected includes acquiring the code to be detected input by a developer, or acquiring the code to be detected from a designated address, which is input by a user and used for storing the code to be detected.
The code to be detected can be code written by using JavaScript. But also code written in other languages.
The JavaScript is a client scripting language, runs in client browsers, and each browser has a JavaScript analysis engine. The browser is a script language, does not need compiling, and can be directly analyzed and executed by the browser.
The JavaScript can enhance the interaction between the user and the html page, can control html elements, enables the page to have some dynamic effects, and enhances the experience of the user.
Step 102, determining an objective function included in the code to be detected.
After the code to be detected is acquired in step 101, the code to be detected may be analyzed by using various methods, so as to determine a target function included in the code to be detected.
The objective function may be a plurality of functions included in the code to be detected. When the application object is a browser, the target function may be a call function triggered by an event. An event-triggered calling function refers to a function that can be called in a synchronous or asynchronous manner when some event occurs. By way of example, the target function may be a function that calls a window object, a method call function, a regular matching function, or the like.
In some optional implementations of this embodiment, the step 102 may include the following steps:
firstly, carrying out syntactic analysis on a code to be detected, and determining a syntactic tree corresponding to the code to be detected;
secondly, determining an objective function included in the code to be detected based on the node corresponding to the syntax tree.
The code to be detected may be parsed using existing parsing tools. Such as parsing tools like esprima, acorn, traceur-builder, etc.
In these optional implementation manners, syntax analysis may be performed on the code to be detected to obtain an abstract syntax tree of the code to be detected. An Abstract Syntax Tree (AST) is a Tree structure corresponding to a source code Syntax. That is, the source code of a programming language maps statements in the source code to each node in the tree by building a syntax tree.
Please refer to fig. 2, which shows a schematic abstract syntax Tree structure of the sentence var AST ═ is Tree.
As shown in FIG. 2, the abstract syntax tree has a top level type attribute "Program" 201. The second level attribute is "body [ ]" 202. The second level attributes correspond to an array. Each item stored in the Body array is an object, and all description information of the statement is contained in the object. "type": VariableDeclaration "203 describes the type of the statement, and is a variable declaration statement. The key of the variable declaration of "kid" 204. The contents array declared by "definitions [ ]" 205. Each item in the content array is an object. "type": VariableDeclaration "203," kind "204, and" declarations [ ] "205 belong to the third-level attribute. "type" 206 describes the type of the statement. Belonging to the next level of attributes comprised by "definitions [ ]" 205. I.e., the fourth level attribute of the abstract syntax tree, "id" 207 describes the object of the variable name. "init" 208 initializes the object of variable values. "id" 207 and "init" 208 are next-level attributes belonging to "type" 206.
From the above analysis, it can be seen that the program code itself can be mapped into a syntax tree. And whether each node in the program code corresponds to a statement or not can be accurately obtained by analyzing each node of the syntax tree. Such as declaration statements, assignment statements, and the like. Whether each node corresponds to the objective function can also be determined through the syntax tree.
Specifically, the determining an objective function included in the code to be detected based on the node corresponding to the syntax tree may include:
and traversing each node of the syntax tree, and determining whether each node comprises a target function or not based on a preset rule in the traversing process.
The preset rule may be a coding specification to which the code to be detected conforms.
Taking the code written by JavaScript as an example, the preset rule may be the ECMAScript specification. The ECMAScript specification is a scripting programming language standardized by Ecma international (formerly the european computer Manufacturers Association, european computer Manufacturers Association) via Ecma-262.
Here, the preset specification may include different versions. Different application objects may support different versions.
For each node, the content of the node may be matched with a function supported by a preset specification, and if the matching is successful, the node includes an objective function.
Step 103, matching the target function with a first function indicated by the pre-acquired information of the first function, where the first function is a function supported by a preset application object, and the information of the first function includes an identifier of the first function and an identifier of the application object supporting the first function.
The preset application object may include, but is not limited to, office application software, an instant messaging application program, a browser, and the like.
The browser may include, but is not limited to, an IE browser, google browser, firefox browser, dog browser, 360 security browser.
The preset specification supported by the preset application object may be obtained in advance. Further, a plurality of first functions supported by the application object are determined according to the preset specification.
The information of the first function may include an identification of the first function, an identification of an application object supporting the first function.
In practice, the identity of the objective function obtained in step 102 may be matched with the identity of the first function in the information of the first function.
And 104, determining a target application object supporting the code to be detected based on the matching result.
In this embodiment, the target application object may be determined according to the identifier of the application object that supports the first function successfully matched with the target function.
In some application scenarios, if the implementation code corresponding to the objective function is the same as or implements the same function as the implementation code corresponding to the first function, the objective function and the first function are considered to be successfully matched.
In other application scenarios, if the identifier of the objective function obtained in step 102 is successfully matched with the identifier of the first function in the information of the first function, it is considered that the objective function is successfully matched with the first function.
In some optional implementation manners of this embodiment, the number of objective functions included in the code to be detected may include more than two.
In these alternative implementations, step 103 may include: and matching the target function included in each code to be detected with the first function indicated by each piece of first function information. Further, the step 104 may include:
and determining a preset application object corresponding to the first function successfully matched with all the target functions as a target application object.
The first function may here be a plurality of first functions.
As an illustrative illustration, the preset application object may include an application object a and an application object B. The application object A supports a first function A1, A2; the application object B supports the first functions A1, B1, B2. The set of functions supported by the application objects A and B is { A1, A2, B1, B2 }. The objective function may be matched to each first function. The identification of the application object that supports the first function a1 may include an identification of application object a, an identification of application object B. The identification of the application object that supports the first function a2 may include an identification of the application object a. The identification of the application object that supports the first function B1 may include an identification of the application object B. The identification of the application object that supports the first function B2 may include an identification of the application object B.
If the target function included in the code to be detected is a1 ', the target function a 1' may be matched with each first function supported by the preset application object. Taking the example that the target function a 1' is successfully matched with the first function a1, the application objects supporting the first function a1 can be viewed as the application object a and the application object B, so that the target application objects can be determined as the application object a and the application object B.
If the target functions included in the code to be detected are a1 'and B1', the target functions a1 'and B1' may be respectively matched with the first functions supported by the application object a and the application object B. Taking the example that the target functions a1 'and B1' are successfully matched with the first functions a1 and B1, respectively, the application object supporting the first function a1 can be viewed as the application object A, B. The application object supporting the first function B1 is the application object B, so that the target application object can be determined to be the application object B.
The method for detecting code compatibility provided by the embodiment includes acquiring a code to be detected; determining an objective function included in the code to be detected; matching the target function with a first function indicated by pre-acquired information of the first function, wherein the first function is a function supported by a preset application object, and the information of the first function comprises an identifier of the first function and an identifier of the application object supporting the first function; and determining a target application object supporting the code to be detected based on the matching result. Matching a target function included in the code to be detected with a first function supported by a preset application object, and determining the compatibility of the code to be detected in the application object according to a matching result. Compared with the prior art, the code to be detected needs to be tested on the simulator of the real machine or the application object, the scheme provided by the embodiment does not need to detect on the simulator of the real machine or the application object, the test speed of the compatibility test of the code can be improved, and the efficiency of the compatibility test of the code to be detected in each application object is higher.
Referring to FIG. 3, a flow diagram of another embodiment of a method for detecting code compatibility according to the present disclosure is shown. The method for detecting code compatibility as shown in fig. 3 includes the following steps:
step 301, acquiring a code to be detected.
Step 302, determining an objective function included in the code to be detected.
In this embodiment, steps 301 and 302 may be performed in a manner similar to steps 101 and 102 of the embodiment shown in fig. 1, and are not described herein again.
Step 303, matching the target function with a first function indicated by the pre-acquired information of the first function, where the first function is a function supported by a preset application object, the information of the first function includes an identifier of the first function and an identifier of an application object supporting the first function, and the preset application object includes the first application object.
The process of matching the target function with the first function in step 303 may refer to the description of step 103 in the embodiment shown in fig. 1, which is not repeated herein.
Step 304, if each target function included in the code to be detected is successfully matched with the first function supported by the first application object, determining that the first application object and the second application object corresponding to the first application object are target application objects.
The second application object is an application object of an updated version of the first application object. Typically, the second application object may be a higher version of the application object of the first application object.
Taking a browser as an example, the browser may include multiple versions, for example, an IE browser may include: versions of Internet Explorer8, Internet Explorer9, Internet Explorer10, Internet Explorer11, and the like. Internet Explorer8 may be the first application object, and Internet Explorer9, Internet Explorer10, Internet Explorer11 may be the second application object. For example, Internet Explorer9 may be used as the first application object, and Internet Explorer10 and Internet Explorer11 may be used as the second application object.
When the code to be detected is detected, a browser with a lower version can be selected to test the code to be detected.
The first application object here may be a lower version application object. Typically, the high version of the application object may be compatible with the functionality of the low version of the application object. If the code to be detected can be run on the first application object of the low version, theoretically also on the application object of the high version.
By way of example, browser A, browser C, and browser D are browsers of the same kernel. Browser C is an updated version of browser a, and browser D is an updated version of browser C. That is, the version of browser C is greater than the version of browser A; browser D is larger than the version of browser C. When the compatibility test is performed on the code to be detected, the browser A can be selected as a browser for test. That is, browser a is taken as the first application object.
In this embodiment, the step 304 may include: and matching the target function included by the code to be detected with each first function supported by the first application object.
A plurality of first functions supported by the first application object may be predetermined. And then matching each target function of the codes to be detected with each first function. If each target function of the code to be detected is successfully matched with the first function supported by the first application object, it can be determined that the first application object can support the code to be detected. Otherwise, the first application object does not support the code to be detected.
If the first application object is determined to support the code to be detected, the first application object and a second application object corresponding to the first application object can be determined to be target application objects.
The description is given by taking the browser a, the browser C, and the browser D as examples. And when the compatibility of the code to be detected is tested, using the browser A as a first browser. And if the browser A is determined to support the codes to be detected. Browser a, browser C, and browser D may be determined to be target browsers.
In some application scenarios, the preset application objects may simultaneously include application objects of different versions, and the first function may include a first function commonly included in the application objects of different versions, and a first function included in each of the application objects of different versions. Each objective function included in the code to be detected may be matched with each of the first functions. And determining the supported first function and the target function included in the code to be detected as the successfully matched application object with the lowest version and the application object larger than the lowest version as the target application object.
The description is given by taking the browser a, the browser C, and the browser D as examples.
The browsers supporting the first functions L1 and L2 can be a browser A, a browser C and a browser D; the browsers supporting the first function L3 may be browser C, browser D; the browser supporting the first function L4 may be browser D.
If the target functions included in the code to be tested are successfully matched with the first functions L1, L2, and L3, respectively, the browser C and the browser D may be used as target browsers. Meanwhile, the browser which does not support the operation of the codes to be detected can be determined.
In the application scenes, the browser which can run the code to be detected and the browser which does not support the code to be detected can be determined simultaneously through one-time detection. The efficiency of the compatibility test of the codes to be detected can be further improved.
Compared with the implementation shown in fig. 1, in this embodiment, a scheme that a code to be detected is detected by using a lower version of an application object to determine a plurality of application objects supporting the code to be detected may obtain higher efficiency of performing compatibility detection on the code to be detected.
With further reference to fig. 4, as an implementation of the methods shown in the above-mentioned figures, the present disclosure provides an embodiment of an apparatus for detecting code compatibility, where the embodiment of the apparatus corresponds to the embodiment of the method shown in fig. 1, and the apparatus may be specifically applied to various electronic devices.
As shown in fig. 4, the apparatus for detecting code compatibility of the present embodiment includes: an acquisition unit 401, a first determination unit 402, a matching unit 403, and a second unit 404. The acquiring unit 401 is configured to acquire a code to be detected; a first determining unit 402, configured to determine an objective function included in a code to be detected; a matching unit 403, configured to match the target function with a first function indicated by information of a first function acquired in advance, where the first function is a function supported by a preset application object, and the information of the first function includes an identifier of the first function and an identifier of an application object supporting the first function; a second determining unit 404, configured to determine, based on the matching result, a target application object that supports the code to be detected.
In this embodiment, specific processes of the obtaining unit 401, the first determining unit 402, the matching unit 403, and the second unit 404 of the device for detecting code compatibility and technical effects brought by the specific processes may refer to related descriptions of step 101, step 102, step 103, and step 104 in the corresponding embodiment of fig. 1, which are not described herein again.
In some optional implementations of the present embodiment, the first determining unit 401 is further configured to: performing syntax analysis on the code to be detected, and determining a syntax tree corresponding to the code to be detected; and determining an objective function included in the code to be detected based on the node corresponding to the syntax tree.
In some optional implementations of this embodiment, the number of objective functions is two or more, and the matching unit 403 is further configured to: matching each first function with each target function; and the second determining unit 404 is further configured to: and determining the application object corresponding to the first function successfully matched with all the target functions as the target application object.
In some optional implementations of this embodiment, the preset application object includes a first application object, and the second determining unit 404 is further configured to: if all target functions included in the code to be detected are successfully matched with the first functions supported by the first application object, determining the first application object and the second application object corresponding to the first application object as target application objects; wherein the second application object is an application object of an updated version of the first application object.
In some optional implementations of the present embodiment, the first determining unit 402 is further configured to: and traversing each node of the syntax tree, and determining whether each node comprises a target function or not based on a preset specification in the traversing process.
In some optional implementations of this embodiment, the application object is a browser.
Referring to fig. 5, fig. 5 illustrates an exemplary system architecture in which a method for detecting code compatibility of an embodiment of the present disclosure may be applied.
As shown in fig. 5, the system architecture may include terminal devices 501, 502, 503, a network 504, and a server 505. The network 504 serves to provide a medium for communication links between the terminal devices 501, 502, 503 and the server 505. Network 504 may include various connection types, such as wired, wireless communication links, or fiber optic cables, to name a few.
The terminal devices 501, 502, 503 may interact with a server 505 over a network 504 to receive or send messages or the like. The terminal devices 501, 502, 503 may have various client applications installed thereon, such as a multimedia conference-type application, a web browser application, a search-type application, and the like. The client application in the terminal device 501, 502, 503 may receive the instruction of the user, and complete the corresponding function according to the instruction of the user, for example, obtain information for presentation from the server according to the instruction of the user.
The terminal devices 501, 502, 503 may be hardware or software. When the terminal devices 501, 502, 503 are hardware, they may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, e-book readers, MP3 players (Moving Picture Experts Group Audio Layer III, mpeg compression standard Audio Layer 3), MP4 players (Moving Picture Experts Group Audio Layer IV, mpeg compression standard Audio Layer 4), laptop portable computers, desktop computers, and the like. When the terminal devices 501, 502, and 503 are software, they can be installed in the electronic devices listed above. It may be implemented as multiple pieces of software or software modules (e.g., software or software modules used to provide distributed services) or as a single piece of software or software module. And is not particularly limited herein.
The server 505 may be a server that provides various services, such as detecting a browser application to be displayed at the terminal device.
It should be noted that the method for detecting code compatibility provided by the embodiment of the present disclosure may be executed by the server 505, and accordingly, a device for detecting code compatibility may be disposed in the server 505. In addition, the method for detecting code compatibility provided by the embodiment of the present disclosure may also be executed by the terminal devices 501, 502, 503, and accordingly, the apparatus for detecting code compatibility may be disposed in the terminal devices 501, 502, 503.
It should be understood that the number of terminal devices, networks, and servers in fig. 5 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
Referring now to fig. 6, a schematic diagram of an electronic device (e.g., the server or terminal device of fig. 5) suitable for implementing embodiments of the present disclosure is shown. The terminal device in the embodiments of the present disclosure may include, but is not limited to, a mobile terminal such as a mobile phone, a notebook computer, a digital broadcast receiver, a PDA (personal digital assistant), a PAD (tablet computer), a PMP (portable multimedia player), a vehicle terminal (e.g., a car navigation terminal), and the like, and a stationary terminal such as a digital TV, a desktop computer, and the like. The electronic device shown in fig. 6 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present disclosure.
As shown in fig. 6, the electronic device may include a processing means (e.g., a central processing unit, a graphics processor, etc.) 601, which may perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM)602 or a program loaded from a storage means 608 into a Random Access Memory (RAM) 603. In the RAM603, various programs and data necessary for the operation of the electronic apparatus 600 are also stored. The processing device 601, the ROM 602, and the RAM603 are connected to each other via a bus 604. An input/output (I/O) interface 605 is also connected to bus 604.
Generally, the following devices may be connected to the I/O interface 605: input devices 606 including, for example, a touch screen, touch pad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, etc.; output devices 607 including, for example, a Liquid Crystal Display (LCD), a speaker, a vibrator, and the like; storage 608 including, for example, tape, hard disk, etc.; and a communication device 609. The communication means 609 may allow the electronic device to communicate with other devices wirelessly or by wire to exchange data. While fig. 6 illustrates an electronic device having various means, it is to be understood that not all illustrated means are required to be implemented or provided. More or fewer devices may alternatively be implemented or provided.
In particular, according to an embodiment of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program carried on a non-transitory computer readable medium, the computer program containing program code for performing the method illustrated by the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network via the communication means 609, or may be installed from the storage means 608, or may be installed from the ROM 602. The computer program, when executed by the processing device 601, performs the above-described functions defined in the methods of the embodiments of the present disclosure.
It should be noted that the computer readable medium in the present disclosure can be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present disclosure, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In contrast, in the present disclosure, a computer readable signal medium may comprise a propagated data signal with computer readable program code embodied therein, either in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: electrical wires, optical cables, RF (radio frequency), etc., or any suitable combination of the foregoing.
In some embodiments, the clients, servers may communicate using any currently known or future developed network protocol, such as HTTP (HyperText transfer protocol), and may be interconnected with any form or medium of digital data communication (e.g., a communications network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), the Internet (e.g., the Internet), and peer-to-peer networks (e.g., ad hoc peer-to-peer networks), as well as any currently known or future developed network.
The computer readable medium may be embodied in the electronic device; or may exist separately without being assembled into the electronic device.
The computer readable medium carries one or more programs which, when executed by the electronic device, cause the electronic device to: acquiring a code to be detected; determining an objective function included in the code to be detected; matching the target function with a first function indicated by pre-acquired information of the first function, wherein the first function is a function supported by a preset application object, and the information of the first function comprises an identifier of the first function and an identifier of the application object supporting the first function; and determining a target application object supporting the code to be detected based on the matching result.
Computer program code for carrying out operations for the present disclosure may be written in any combination of one or more programming languages, including but not limited to an object oriented programming language such as Java, Smalltalk, C + +, and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The units described in the embodiments of the present disclosure may be implemented by software or hardware. Where the name of a unit does not in some cases constitute a limitation of the unit itself, for example, the acquiring unit may also be described as a "unit acquiring the code to be detected".
The functions described herein above may be performed, at least in part, by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field Programmable Gate Arrays (FPGAs), Application Specific Integrated Circuits (ASICs), Application Specific Standard Products (ASSPs), systems on a chip (SOCs), Complex Programmable Logic Devices (CPLDs), and the like.
In the context of this disclosure, a machine-readable medium may be a tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
The foregoing description is only exemplary of the preferred embodiments of the disclosure and is illustrative of the principles of the technology employed. It will be appreciated by those skilled in the art that the scope of the disclosure herein is not limited to the particular combination of features described above, but also encompasses other embodiments in which any combination of the features described above or their equivalents does not depart from the spirit of the disclosure. For example, the above features and (but not limited to) the features disclosed in this disclosure having similar functions are replaced with each other to form the technical solution.
Further, while operations are depicted in a particular order, this should not be understood as requiring that such operations be performed in the particular order shown or in sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Likewise, while several specific implementation details are included in the above discussion, these should not be construed as limitations on the scope of the disclosure. Certain features that are described in the context of separate embodiments can also be implemented in combination in a single embodiment. Conversely, various features that are described in the context of a single embodiment can also be implemented in multiple embodiments separately or in any suitable subcombination.
Although the subject matter has been described in language specific to structural features and/or methodological acts, it is to be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described above. Rather, the specific features and acts described above are disclosed as example forms of implementing the claims.

Claims (14)

1. A method for detecting code compatibility, comprising:
acquiring a code to be detected;
determining an objective function included in the code to be detected;
matching the target function with a first function indicated by pre-acquired information of the first function, wherein the first function is a function supported by a preset application object, and the information of the first function comprises an identifier of the first function and an identifier of the application object supporting the first function;
and determining a target application object supporting the code to be detected based on the matching result.
2. The method according to claim 1, wherein the determining an objective function included in the code to be detected comprises:
performing syntax analysis on the code to be detected, and determining a syntax tree corresponding to the code to be detected;
and determining an objective function included in the code to be detected based on the node corresponding to the syntax tree.
3. The method of claim 1, wherein the number of objective functions is two or more, and
the matching the target function with a first function indicated by pre-acquired information of the first function includes:
matching each target function with each first function; and
the determining, based on the matching result, the target application object that supports the code to be detected includes:
and determining the application object corresponding to the first function successfully matched with all the target functions as the target application object.
4. The method of claim 1, wherein the default application object comprises a first application object, and wherein
The determining, based on the matching result, the target application object that supports the code to be detected includes:
if all target functions included in the code to be detected are successfully matched with the first function supported by the first application object, determining that the first application object and the second application object corresponding to the first application object are target application objects, wherein the target application objects are the first application objects and the second application objects are the second application objects corresponding to the first application objects
The second application object is an updated version of the first application object.
5. The method according to claim 2, wherein the determining the objective function included in the code to be detected based on the node corresponding to the syntax tree comprises:
and traversing each node of the syntax tree, and determining whether each node comprises a target function or not based on a preset rule in the traversing process.
6. The method according to one of claims 1 to 5, wherein the application object is a browser.
7. An apparatus for detecting code compatibility, comprising:
the acquisition unit is used for acquiring a code to be detected;
the first determining unit is used for determining an objective function included in the code to be detected;
the matching unit is used for matching the target function with a first function indicated by pre-acquired information of the first function, wherein the first function is a function supported by a preset application object, and the information of the first function comprises an identifier of the first function and an identifier of the application object supporting the first function;
and the second determining unit is used for determining the target application object supporting the code to be detected based on the matching result.
8. The apparatus of claim 7, wherein the first determining unit is further configured to:
performing syntax analysis on the code to be detected, and determining a syntax tree corresponding to the code to be detected;
and determining an objective function included in the code to be detected based on the node corresponding to the syntax tree.
9. The apparatus of claim 7, wherein the number of objective functions is two or more, and
the matching unit is further configured to:
matching each target function with each first function; and
the second determination unit is further configured to:
and determining the application object corresponding to the first function successfully matched with all the target functions as the target application object.
10. The apparatus of claim 7, wherein the default application object comprises a first application object, and wherein
The second determination unit is further configured to:
if all target functions included in the code to be detected are successfully matched with the first functions supported by the first application object, determining the first application object and the second application object corresponding to the first application object as target application objects; wherein
The second application object is an updated version of the first application object.
11. The apparatus of claim 8, wherein the first determining unit is further configured to:
and traversing each node of the syntax tree, and determining whether each node comprises a target function or not based on a preset specification in the traversing process.
12. The apparatus according to any of claims 7-11, wherein the application object is a browser.
13. An electronic device, comprising:
one or more processors;
a storage device for storing one or more programs,
when executed by the one or more processors, cause the one or more processors to implement the method of any one of claims 1-6.
14. A computer-readable medium, on which a computer program is stored which, when being executed by a processor, carries out the method according to any one of claims 1-6.
CN202010577194.7A 2020-06-22 2020-06-22 Method and device for detecting code compatibility and electronic equipment Pending CN111797009A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010577194.7A CN111797009A (en) 2020-06-22 2020-06-22 Method and device for detecting code compatibility and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010577194.7A CN111797009A (en) 2020-06-22 2020-06-22 Method and device for detecting code compatibility and electronic equipment

Publications (1)

Publication Number Publication Date
CN111797009A true CN111797009A (en) 2020-10-20

Family

ID=72803034

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010577194.7A Pending CN111797009A (en) 2020-06-22 2020-06-22 Method and device for detecting code compatibility and electronic equipment

Country Status (1)

Country Link
CN (1) CN111797009A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112764797A (en) * 2021-01-06 2021-05-07 浙江大华技术股份有限公司 Software compatibility detection method and device, electronic device and storage medium

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103942137A (en) * 2013-01-23 2014-07-23 腾讯科技(深圳)有限公司 Browser compatibility testing method and device
CN106201850A (en) * 2015-04-29 2016-12-07 阿里巴巴集团控股有限公司 A kind of compatibility test method and device
CN106326091A (en) * 2015-06-24 2017-01-11 深圳市腾讯计算机系统有限公司 Browser webpage compatibility detection method and system
CN107133165A (en) * 2017-03-22 2017-09-05 腾讯科技(深圳)有限公司 Browser compatibility detection method and device
CN108073508A (en) * 2016-11-18 2018-05-25 腾讯科技(深圳)有限公司 A kind of compatibility detection method and device
CN109684220A (en) * 2018-12-26 2019-04-26 苏州博纳讯动软件有限公司 A kind of browser compatibility analysis method based on event replay
CN111240987A (en) * 2020-01-16 2020-06-05 北京奇艺世纪科技有限公司 Migration program detection method and device, electronic equipment and computer readable storage medium

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103942137A (en) * 2013-01-23 2014-07-23 腾讯科技(深圳)有限公司 Browser compatibility testing method and device
CN106201850A (en) * 2015-04-29 2016-12-07 阿里巴巴集团控股有限公司 A kind of compatibility test method and device
CN106326091A (en) * 2015-06-24 2017-01-11 深圳市腾讯计算机系统有限公司 Browser webpage compatibility detection method and system
CN108073508A (en) * 2016-11-18 2018-05-25 腾讯科技(深圳)有限公司 A kind of compatibility detection method and device
CN107133165A (en) * 2017-03-22 2017-09-05 腾讯科技(深圳)有限公司 Browser compatibility detection method and device
CN109684220A (en) * 2018-12-26 2019-04-26 苏州博纳讯动软件有限公司 A kind of browser compatibility analysis method based on event replay
CN111240987A (en) * 2020-01-16 2020-06-05 北京奇艺世纪科技有限公司 Migration program detection method and device, electronic equipment and computer readable storage medium

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112764797A (en) * 2021-01-06 2021-05-07 浙江大华技术股份有限公司 Software compatibility detection method and device, electronic device and storage medium
CN112764797B (en) * 2021-01-06 2023-03-21 浙江大华技术股份有限公司 Software compatibility detection method and device, electronic device and storage medium

Similar Documents

Publication Publication Date Title
CN111338623B (en) Method, device, medium and electronic equipment for developing user interface
CN109873735B (en) Performance test method and device for H5 page and computer equipment
CN112631590B (en) Component library generation method, device, electronic equipment and computer readable medium
CN111309304B (en) Method, device, medium and electronic equipment for generating IDL file
CN110851211A (en) Method, apparatus, electronic device, and medium for displaying application information
CN112596738B (en) Method and device for determining front-end page to be tested, storage medium and electronic equipment
CN111506904B (en) Method and device for online bug repair
CN110489326B (en) IDS-based HTTPAPI debugging method device, medium and equipment
CN111797009A (en) Method and device for detecting code compatibility and electronic equipment
CN111752644A (en) Interface simulation method, device, equipment and storage medium
CN111783010A (en) Webpage blank page monitoring method, device, terminal and storage medium
CN111414154A (en) Method and device for front-end development, electronic equipment and storage medium
CN112379967B (en) Simulator detection method, device, equipment and medium
CN111539200B (en) Method, device, medium and electronic equipment for generating rich text
CN113391860B (en) Service request processing method and device, electronic equipment and computer storage medium
CN111309323A (en) Parameter initialization method and device and electronic equipment
CN109669679B (en) Service detection and processing method and device and electronic equipment
CN112306858A (en) Test method and device and electronic equipment
CN111782549A (en) Test method and device and electronic equipment
CN112306469A (en) Barrier-free component construction method, device, equipment and storage medium
CN112068814A (en) Method, device, system and medium for generating executable file
CN110099122B (en) Method and apparatus for sending network request
CN111104626B (en) Information storage method and device
CN110489341B (en) Test method and device, storage medium and electronic equipment
CN116263824A (en) Resource access method and device, storage medium and electronic equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination