File matching method, device, storage medium and computer equipment
By using Node.js to read the diff file and record the file directory information during the Webpack construction process, the problem of component changes affecting page recognition in Web front-end development is solved, and rapid and accurate testing efficiency is improved.
Patent Information
- Application Number
- CN202110606682.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-05-30
- Publication Date
- 2024-11-05
- Estimated Expiration
- 2041-05-30
AI Technical Summary
In web front-end development, pages affected by changes in components or modules are difficult to accurately identify. The existing methods rely on testers' experience and subjective judgments, lack scientific basis, and lead to uncertainty.
Read the diff file through Node.js, and record the file directory information matching the diff file during the Webpack construction project source code, and write it to the target file to achieve quick identification of the affected pages.
Improves testing efficiency and accuracy, allowing testers to quickly identify pages affected by code modifications, reducing uncertainty.
Smart Images

Figure CN113268221B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer application technology, and in particular to a file matching method, device, storage medium and computer equipment. Background Art
[0002] Currently, Web front-end development projects are mainly developed in a componentized and modular manner. During the development process, components or modules used by multiple pages will be changed more or less according to certain requirements. For each change, in order to ensure the stability of the page, testers need to find the pages that may be affected by the change of a certain component and test these pages. The existing implementation method is generally to find out the affected pages in a guessing way through the tester's own experience or subjective judgment. There is no scientific basis and it is uncertain. Summary of the invention
[0003] The embodiments of the present application provide a file matching method, apparatus, storage medium and computer equipment, which can determine the file directory information of each file affected by a diff file.
[0004] The technical solution is as follows:
[0005] In a first aspect, an embodiment of the present application provides a file matching method, the method comprising:
[0006] Read the modified diff file based on Node.js;
[0007] Record the file directory information of the files matching the diff file during the process of Webpack building the project source code;
[0008] Write the file directory information into the target file.
[0009] In a second aspect, an embodiment of the present application provides a file matching device, the file matching device comprising:
[0010] The diff file acquisition module is used to read the modified diff file based on Node.js;
[0011] A file information recording module is used to record the file directory information of the files matching the diff file in the process of Webpack building the project source code;
[0012] The file information saving module is used to write the file directory information into the target file.
[0013] In a third aspect, an embodiment of the present application provides a storage medium, which stores a plurality of instructions, and the instructions are suitable for being loaded by a processor and executing the above-mentioned method steps.
[0014] In a fourth aspect, an embodiment of the present application provides a computer device, which may include: a processor and a memory; wherein the memory stores a computer program, and the computer program is suitable for being loaded by the processor and executing the above-mentioned method steps.
[0015] The beneficial effects brought about by the technical solutions provided by some embodiments of the present application include at least:
[0016] In the embodiment of the present application, the modified diff file is read based on Node.js, and then the file directory information of the file matching the diff file is recorded in the process of building the project source code with Webpack, and finally the file directory information is written to the target file. With the embodiment of the present application, the file path affected by the diff file can be found in the process of building the project source code with Webpack based on the modified diff file, so that the tester can quickly determine the affected page through the file path. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0018] Figure 1 A flowchart of a file matching method is provided for an embodiment of the present application;
[0019] Figure 2 A flowchart of a file matching method is provided for an embodiment of the present application;
[0020] Figure 3 An example schematic diagram of matching diff files is provided for the embodiment of the present application;
[0021] Figure 4 A structural schematic diagram of a file matching device is provided for an embodiment of the present application;
[0022] Figure 5 A structural schematic diagram of a file information recording module 12 is provided for an embodiment of the present application;
[0023] Figure 6 A schematic diagram of the structure of a computer device is provided for an embodiment of the present application;
[0024] Figure 7 A schematic diagram of the structure of an operating system and a user space is provided for an embodiment of the present application;
[0025] Figure 8 yes Figure 6 The architecture diagram of the Android operating system;
[0026] Fig. 9 yes Figure 6 Architecture diagram of the IOS operating system. DETAILED DESCRIPTION
[0027] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0028] In the description of the present application, it should be understood that the terms "first", "second", etc. are only used for descriptive purposes and cannot be understood as indicating or implying relative importance. In the description of the present application, it should be noted that, unless otherwise clearly specified and limited, "including" and "having" and any of their variations are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but optionally also includes steps or units that are not listed, or optionally also includes other steps or units inherent to these processes, methods, products or devices. For those of ordinary skill in the art, the specific meanings of the above terms in the present application can be understood in specific circumstances. In addition, in the description of the present application, unless otherwise specified, "multiple" refers to two or more. "And / or" describes the association relationship of associated objects, indicating that there can be three relationships, for example, A and / or B, which can represent: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the associated objects before and after are an "or" relationship.
[0029] In order to more clearly describe the technical solution of the embodiment of the present invention, some concepts in the present invention are described in detail before the description to facilitate a better understanding of the solution.
[0030] At present, HTML5 technology in Web front-end development is becoming more and more mature. HTML5 is the mainstream development language for the front end of mobile Internet. HTML5 is actually a collection of technologies. It has three important parts: HTML5, CSS3 and JavaScript (referred to as js). It is a general term for applications running on browsers. Among them, JavaScript is the core of front-end development. Due to the low compatibility of browsers with advanced JavaScript languages, it is necessary to use Webpack to modularly package the compiled front-end resources (including Javascript, images, fonts and CSS, etc.) and place them in the dependency relationship. Resources can be used according to the requirements by referencing dependencies. Webpack is a packaging tool that uses front-end resources to build project source code. It can package resources such as js, image, css, etc. as a module. The module refers to different css files, and different js files can be regarded as different modules. Different modules have their own functions. The packaging refers to writing many css files, js files, images and other files into one js file. Using Webpack, you can reload and compile various front-end resources, compile syntax that the browser does not recognize into syntax that the browser recognizes, and package resources to reduce i / o requests.
[0031] This application proposes a file matching method, which is mainly used in the process of front-end development. When a diff file referenced by multiple pages is changed according to certain requirements, all pages that may be affected by the diff file are found during the process of Webpack building the project source code, so as to facilitate testing by testers.
[0032] See also Figure 1 , which is a flowchart of a file matching method provided in an embodiment of the present application. Figure 1 As shown, the file matching method may include the following steps S101 to S104.
[0033] S101, reading the modified diff file based on Node.js;
[0034] The Node.js is a development platform that allows JavaScript language to run on the server side, and the diff file refers to a file obtained by performing diff operation on the file before modification and the file after modification through the diff command.
[0035] Specifically, a diff command is used on the Node.js platform to perform diff on the file before modification and the file after modification to obtain a diff file, and code data in the diff file is read.
[0036] S102, recording file directory information of files matching the diff file during the process of Webpack building the project source code;
[0037] Specifically, in the process of Webpack building the project source code, the file matching the diff file is found in all front-end resource files, and the file directory information of the file matching the diff file is recorded.
[0038] The step of finding the file matching the diff file in all the front-end resource files may be to perform code matching on all the front-end resource files and the diff file respectively in a code block matching manner.
[0039] The file directory information refers to the file path of the file matching the diff file in the memory, and the tester can quickly determine the Web page pointed to by the file directory information based on the file directory information.
[0040] S103, writing the file directory information into the target file.
[0041] Specifically, the file directory information is sorted and written into a specified target file. The sorted file directory information may be stored separately according to different Web pages pointed to by each file directory information.
[0042] In an embodiment of the present application, the modified diff file is read based on Node.js, and then the file directory information of the file matching the diff file is recorded in the process of building the project source code with Webpack, and finally the file directory information is written to the target file. The file directory information can point to a Web page, so that the tester can quickly determine the Web page that may be affected by the code modification according to the file directory information in the target file, thereby improving the test efficiency and test accuracy.
[0043] See also Figure 2 , which is a flowchart of a file matching method provided in an embodiment of the present application. Figure 2 As shown, the file matching method may include the following steps S201 to S206.
[0044] S201, reading the modified diff file based on Node.js;
[0045] Specifically, for step S201, please refer to the description of step S101 in another embodiment, which will not be described in detail here.
[0046] S202, obtaining a Hook of Webpack, and monitoring event information in the Webpack based on the Hook;
[0047] The Hook, also called the hook function, is a platform for message processing, which can monitor certain messages of a specified window. Whenever a specific message is sent, before it reaches the destination window, the Hook can be used to capture the message, that is, to obtain control before the target window processing function processes the message. The message can be processed, or the message can be continued to be passed without processing, and the message transmission can be forcibly terminated.
[0048] Specifically, obtain the Hook of Webpack and monitor the event information related to the source code of the project built by the Webpack.
[0049] S203, inserting a plug-in when Webpack starts to compile files based on event information in Webpack, and detecting whether the entry file matches the diff file based on the plug-in;
[0050] Specifically, the event information can indicate the process of Webpack building the project source code. According to the process of Webpack building the project source code, a plug-in is inserted when starting to compile the file, and based on the plug-in, it is detected whether the file code of each entry file includes a code block related to the diff file.
[0051] The plug-in is used to detect all front-end resource files and match them with diff files, and record file directory information based on the matching results.
[0052] The entry file refers to a JS file that can be directly referenced by HTML, and other non-entry files are directly or indirectly dependent on the entry file, and are called and executed by the entry files. A web page includes at least one entry file.
[0053] For the import file and non-import file, please refer to the following examples:
[0054] index.html:
[0055]
[0056]
[0057] <script src="main.js">< / script>
[0058]
[0059]
[0060]
[0061]
[0062] main.js
[0063] var a = require('. / a');
[0064] var b = require('. / b');
[0065] in,
[0066] a.doSt();
[0067] b.doSth().
[0068] As can be seen in the above example, main.js is directly referenced by HTML and is where the entire program logic starts, so it is the entry file. The referenced a and b are introduced and called by main.js, so they are not entry files. a and b can be dependent files of main.js.
[0069] S204, if the entry file matches the diff file, then recording the file directory information of the entry file;
[0070] Specifically, if the entry file contains the same code block as the diff file, the file directory information of the entry file is recorded.
[0071] It is not difficult to understand that if the entry file contains the same code block as the diff file, it indicates that the web page corresponding to the entry file may be affected by the modified code. The file directory information of the entry file is recorded, and the file directory information points to the web page corresponding to the entry file.
[0072] S205: If the entry file does not match the diff file, a first dependent file matching the diff file is determined in the dependent files of the entry file, and file directory information of the first dependent file is recorded.
[0073] Specifically, if the entry file does not contain the same code block as the diff file, the dependent files of the entry file are searched in the AST syntax tree created based on Webpack, and the first dependent file that matches the diff file is recursively filtered out from the dependent files, and the file directory information of the first dependent file is recorded.
[0074] The AST syntax tree is used to represent the dependency relationship between files, and it expresses the syntax structure of the programming language in a tree form.
[0075] The dependent file refers to a file that has a reference relationship such as import or require with the entry file.
[0076] Furthermore, the first dependent file that matches the diff file is selected from the dependent files and can be determined as the first dependent file in the dependent files that matches the code of the diff file, that is, detecting whether there are the same code blocks as the diff file in all the dependent files of the entry, and taking the dependent file that has the same code blocks as the diff file as the first dependent file. The recursive method means that the first-level dependent files and the diff file are matched first, and if there is no dependent file that matches the diff file in the first-level dependent file, the dependent files and the diff file of the first-level dependent file are matched, that is, the second-level dependent files and the diff file are matched, and recursive matching is performed in this way until all dependent files are matched.
[0077] Please refer to step S204 and step S205 for details. Figure 3 , provides an example schematic diagram of matching diff files for an embodiment of the present application.
[0078] like Figure 3 As shown, there are five entry files, entry file 1, entry file 2, entry file 3, entry file 4 and entry file 5. First, match the entry file and the diff file. If the entry file contains the same code block as the diff file, the match is successful, otherwise the match fails. After the entry file is matched, it is obtained that entry file 1, entry file 3, and entry file 5 are successfully matched with the diff file, then the file directory information of entry file 1, entry file 3 and entry file 5 is recorded, and the dependent files of entry file 2 and entry file 4 are searched. The first-level dependent files of entry file 2 include dependent file 1 and dependent file 2, and the second-level dependent files include dependent file 11, dependent file 21, and dependent file 22. The first-level dependent files of entry file 4 include dependent file 3, dependent file 4, and the second-level dependent files include dependent file 31, dependent file 32, and dependent file 41. First, the first-level dependent file and the diff file are matched recursively, and the file directory information of the first-level dependent file matching the diff file is recorded. Then, it is determined that the second-level dependent file of the first-level dependent file matching the diff file does not exist in the first-level dependent file. Then, the second-level dependent file and the diff file are matched, and the file directory information of the second-level dependent file matching the diff file is recorded. The first-level dependent file matching the diff file and the second-level dependent file matching the diff file both refer to the first dependent file described in step S205.
[0079] S206, writing the file directory information into the target file.
[0080] Specifically, the file directory information is written into a target file, and the target file may reflect the page pointer of the Web page containing the file directory information.
[0081] In an embodiment of the present application, the modified diff file is read based on Node.js, and then the Hook of Webpack is obtained, the event information in the Webpack is monitored based on the Hook, and a plug-in is inserted when the Webpack starts to compile the file according to the event information in the Webpack, and whether the entry file matches the diff file is detected based on the plug-in. If the entry file matches the diff file, the file directory information of the entry file is recorded; if the entry file does not match the diff file, the first dependent file matching the diff file is determined in the dependent file of the entry file, and the file directory information of the first dependent file is recorded, and the file directory information can point to a Web page. Finally, the file directory information is written to the target file, so that the tester can quickly determine the Web page that may be affected by the code modification according to the file directory information in the target file, thereby improving the test efficiency and test accuracy.
[0082] See also Figure 4 , is a schematic diagram of the structure of a file matching device provided in an embodiment of the present application. Figure 4 As shown, the file matching device 1 can be implemented as all or part of the terminal device through software, hardware or a combination of both. According to some embodiments, the file matching device 1 includes a diff file acquisition module 11, a file information recording module 12, and a file information storage module 13, specifically including:
[0083] A diff file acquisition module 11 is used to read the modified diff file based on Node.js;
[0084] A file information recording module 12 is used to record the file directory information of the files matching the diff file in the process of Webpack building the project source code;
[0085] The file information saving module 13 is used to write the file directory information into the target file.
[0086] Optional, such as Figure 5 As shown, a structural schematic diagram of a diff file acquisition module 11 is provided in an embodiment of the present application.
[0087] The file information recording module 12 includes:
[0088] A Hook acquisition unit 121 is used to acquire a Hook of Webpack, and monitor event information in the Webpack based on the Hook;
[0089] A plug-in detection unit 122, used to insert a plug-in when Webpack starts to compile a file based on event information in Webpack, and detect whether an entry file matches the diff file based on the plug-in;
[0090] A first information recording unit 123, configured to record the file directory information of the entry file if the entry file matches the diff file;
[0091] The second information recording unit 124 is used to determine a first dependent file matching the diff file in the dependent files of the entry file if the entry file does not match the diff file, and record the file directory information of the first dependent file.
[0092] Optionally, the second information recording unit 124 is specifically used to:
[0093] Find the dependent files of the entry file based on the AST syntax tree created by Webpack;
[0094] The first dependent file matching the diff file is screened out from the dependent files in a recursive manner.
[0095] It should be noted that the file matching device provided in the above embodiment only uses the division of the above functional modules as an example when executing the file matching method. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. In addition, the file matching device provided in the above embodiment and the file matching method embodiment belong to the same concept, and the implementation process thereof is detailed in the method embodiment, which will not be repeated here.
[0096] The serial numbers of the above-mentioned embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.
[0097] In an embodiment of the present application, the modified diff file is read based on Node.js, and then the file directory information of the file matching the diff file is recorded in the process of building the project source code with Webpack, and finally the file directory information is written to the target file. The file directory information can point to a Web page, so that the tester can quickly determine the Web page that may be affected by the code modification according to the file directory information in the target file, thereby improving the test efficiency and test accuracy.
[0098] The present application also provides a computer storage medium, which can store multiple instructions, and the instructions are suitable for being loaded and executed by a processor as described above. Figure 1 to Figure 3 The specific implementation process of the file matching method in the embodiment shown can be found in Figure 1 to Figure 3 The specific description of the illustrated embodiment will not be repeated here.
[0099] The present application also provides a computer program product, which stores at least one instruction, and the at least one instruction is loaded and executed by the processor as described above. Figure 1 to Figure 3 The specific implementation process of the file matching method in the embodiment shown can be found in Figure 1 to Figure 3 The specific description of the illustrated embodiment will not be repeated here.
[0100] Please refer to Figure 6 , which shows a block diagram of a computer device provided by an exemplary embodiment of the present application. The computer device in the present application may include one or more of the following components: a processor 110, a memory 120, an input device 130, an output device 140, and a bus 150. The processor 110, the memory 120, the input device 130, and the output device 140 may be connected via a bus 150.
[0101] The processor 110 may include one or more processing cores. The processor 110 uses various interfaces and lines to connect various parts of the entire computer device, and executes various functions and processes data of the computer device 100 by running or executing instructions, programs, code sets or instruction sets stored in the memory 120, and calling data stored in the memory 120. Optionally, the processor 110 can be implemented in at least one hardware form of digital signal processing (DSP), field-programmable gate array (FPGA), and programmable logic array (PLA). The processor 110 can integrate one or a combination of a central processing unit (CPU), a graphics processing unit (GPU), and a modem. Among them, the CPU mainly processes the operating system, user interface, and application programs; the GPU is responsible for rendering and drawing display content; and the modem is used to process wireless communications. It can be understood that the above-mentioned modem may not be integrated into the processor 110, but may be implemented separately through a communication chip.
[0102] The memory 120 may include a random access memory (RAM) or a read-only memory (ROM). Optionally, the memory 120 includes a non-transitory computer-readable storage medium. The memory 120 may be used to store instructions, programs, codes, code sets or instruction sets. The memory 120 may include a storage program area and a storage data area, wherein the storage program area may store instructions for implementing an operating system, instructions for implementing at least one function (such as a touch function, a sound playback function, an image playback function, etc.), instructions for implementing the following various method embodiments, etc. The operating system may be an Android system, including a system deeply developed based on the Android system, an IOS system developed by Apple, including a system deeply developed based on the IOS system or other systems. The storage data area may also store data created by the computer device during use, such as a phone book, audio and video data, chat record data, etc.
[0103] See also Figure 7 As shown, the memory 120 can be divided into an operating system space and a user space. The operating system runs in the operating system space, and native and third-party applications run in the user space. In order to ensure that different third-party applications can achieve good operating results, the operating system allocates corresponding system resources to different third-party applications. However, different application scenarios in the same third-party application also have different requirements for system resources. For example, in the local resource loading scenario, the third-party application has higher requirements for disk reading speed; in the animation rendering scenario, the third-party application has higher requirements for GPU performance. The operating system and third-party applications are independent of each other, and the operating system often cannot perceive the current application scenario of the third-party application in a timely manner, resulting in the operating system being unable to perform targeted system resource adaptation according to the specific application scenario of the third-party application.
[0104] In order for the operating system to distinguish the specific application scenarios of third-party applications, it is necessary to open up data communication between third-party applications and the operating system so that the operating system can obtain the current scenario information of third-party applications at any time, and then perform targeted system resource adaptation based on the current scenario.
[0105] Taking the Android operating system as an example, the programs and data stored in the memory 120 are as follows: Figure 8As shown, the memory 120 may store a Linux kernel layer 320, a system runtime library layer 340, an application framework layer 360 and an application layer 380, wherein the Linux kernel layer 320, the system runtime library layer 340 and the application framework layer 360 belong to the operating system space, and the application layer 380 belongs to the user space. The Linux kernel layer 320 provides underlying drivers for various hardware of computer devices, such as display drivers, audio drivers, camera drivers, Bluetooth drivers, Wi-Fi drivers, power management, etc. The system runtime library layer 340 provides the main feature support for the Android system through some C / C++ libraries. For example, the SQLite library provides database support, the OpenGL / ES library provides 3D drawing support, and the Webkit library provides browser kernel support, etc. The Android runtime library (Android runtime) is also provided in the system runtime library layer 340, which mainly provides some core libraries that allow developers to use the Java language to write Android applications. The application framework layer 360 provides various APIs that may be used when building applications. Developers can also use these APIs to build their own applications, such as activity management, window management, view management, notification management, content provider, package management, call management, resource management, and location management. At least one application runs in the application layer 380. These applications can be native applications that come with the operating system, such as contact applications, text messaging applications, clock applications, camera applications, etc.; they can also be third-party applications developed by third-party developers, such as game applications, instant messaging applications, photo beautification applications, file matching applications, etc.
[0106] Taking the operating system as an IOS system as an example, the programs and data stored in the memory 120 are as follows: Fig. 9As shown, the IOS system includes: a core operating system layer 420 (Core OS layer), a core service layer 440 (Core Services layer), a media layer 460 (Media layer), and a touchable layer 480 (Cocoa Touch Layer). The core operating system layer 420 includes the operating system kernel, drivers, and underlying program frameworks, which provide functions closer to the hardware for use by the program framework located in the core service layer 440. The core service layer 440 provides system services and / or program frameworks required by the application, such as the foundation framework, account framework, advertising framework, data storage framework, network connection framework, geographic location framework, motion framework, etc. The media layer 460 provides audio-visual interfaces for the application, such as graphics and image related interfaces, audio technology related interfaces, video technology related interfaces, and wireless playback (AirPlay) interfaces for audio and video transmission technologies. The touchable layer 480 provides various commonly used interface-related frameworks for application development, and the touchable layer 480 is responsible for the user's touch interaction operations on the computer device. For example, local notification service, remote push service, advertising framework, game tool framework, message user interface (UI) framework, user interface UIKit framework, map framework, etc.
[0107] exist Fig. 9 Among the frameworks shown, the frameworks related to most applications include but are not limited to: the basic framework in the core service layer 440 and the UIKit framework in the touchable layer 480. The basic framework provides many basic object classes and data types, provides the most basic system services for all applications, and has nothing to do with UI. The classes provided by the UIKit framework are basic UI class libraries for creating touch-based user interfaces. iOS applications can provide UIs based on the UIKit framework, so it provides the basic architecture of applications for building user interfaces, drawing, processing and user interaction events, responding to gestures, etc.
[0108] Among them, the method and principle of implementing data communication between third-party applications and the operating system in the IOS system can be referred to the Android system, and this application will not go into details here.
[0109] Among them, the input device 130 is used to receive input instructions or data, and the input device 130 includes but is not limited to a keyboard, a mouse, a camera, a microphone or a touch device. The output device 140 is used to output instructions or data, and the output device 140 includes but is not limited to a display device and a speaker. In one example, the input device 130 and the output device 140 can be combined, and the input device 130 and the output device 140 are touch screens, which are used to receive touch operations on or near them by users using any suitable objects such as fingers and touch pens, and to display the user interfaces of various applications. The touch screen is usually set on the front panel of the computer device. The touch screen can be designed as a full screen, a curved screen or a special-shaped screen. The touch screen can also be designed as a combination of a full screen and a curved screen, or a combination of a special-shaped screen and a curved screen, which is not limited in the embodiments of the present application.
[0110] In addition, those skilled in the art will appreciate that the structure of the computer device shown in the above drawings does not constitute a limitation on the computer device, and the computer device may include more or fewer components than shown, or combine certain components, or arrange the components differently. For example, the computer device also includes a radio frequency circuit, an input unit, a sensor, an audio circuit, a wireless fidelity (WiFi) module, a power supply, a Bluetooth module, and other components, which will not be described in detail here.
[0111] In the embodiment of the present application, the execution subject of each step may be the computer device described above. Optionally, the execution subject of each step is the operating system of the computer device. The operating system may be an Android system, an IOS system, or other operating systems, which is not limited in the embodiment of the present application.
[0112] The computer device of the embodiment of the present application may also be equipped with a display device, which may be any device capable of realizing a display function, such as a cathode ray tube display (CR), a light-emitting diode display (LED), an electronic ink screen, a liquid crystal display (LCD), a plasma display panel (PDP), etc. The user may use the display device on the computer device 101 to view displayed text, images, videos and other information. The computer device may be a smart phone, a tablet computer, a gaming device, an AR (Augmented Reality) device, a car, a data storage device, an audio playback device, a video playback device, a notebook, a desktop computing device, a wearable device such as an electronic watch, an electronic glasses, an electronic helmet, an electronic bracelet, an electronic necklace, electronic clothing and other devices.
[0113] exist Figure 6 In the computer device shown, the processor 110 may be used to call the file matching program stored in the memory 120 and specifically perform the following operations:
[0114] Read the modified diff file based on Node.js;
[0115] Record the file directory information of the files matching the diff file during the process of Webpack building the project source code;
[0116] Write the file directory information into the target file.
[0117] In one embodiment, the processor 110 performs the following operations when recording the file directory information of the file matching the diff file during the process of building the project source code with Webpack:
[0118] Inserting a plug-in when Webpack starts compiling files based on event information in Webpack, and detecting whether the entry file matches the diff file based on the plug-in;
[0119] If the entry file matches the diff file, the file directory information of the entry file is recorded;
[0120] If the entry file does not match the diff file, a first dependent file matching the diff file is determined in the dependent file of the entry file, and the file directory information of the first dependent file is recorded.
[0121] In one embodiment, the processor 110 inserts a plug-in when Webpack starts compiling files based on event information in Webpack, and before detecting whether the entry file matches the diff file based on the plug-in, further performs the following operations:
[0122] Get the Hook of Webpack, and monitor the event information in the Webpack based on the Hook.
[0123] In one embodiment, when the processor 110 determines the first dependent file matching the diff file in the dependent file of the entry file, the processor 110 specifically performs the following operations:
[0124] Find the dependent files of the entry file based on the AST syntax tree created by Webpack;
[0125] The first dependent file matching the diff file is screened out from the dependent files in a recursive manner.
[0126] In one embodiment, when the processor 110 performs the step of filtering out the first dependent file matching the diff file from the dependent file, the processor 110 specifically performs the following operations:
[0127] The dependent file that matches the code of the diff file is determined in the dependent files as the first dependent file.
[0128] In an embodiment of the present application, the modified diff file is read based on Node.js, and then the Hook of Webpack is obtained, the event information in the Webpack is monitored based on the Hook, and a plug-in is inserted when the Webpack starts to compile the file according to the event information in the Webpack, and whether the entry file matches the diff file is detected based on the plug-in. If the entry file matches the diff file, the file directory information of the entry file is recorded; if the entry file does not match the diff file, the first dependent file matching the diff file is determined in the dependent file of the entry file, and the file directory information of the first dependent file is recorded, and the file directory information can point to a Web page. Finally, the file directory information is written to the target file, so that the tester can quickly determine the Web page that may be affected by the code modification according to the file directory information in the target file, thereby improving the test efficiency and test accuracy.
[0129] Those skilled in the art can clearly understand that the technical solution of the present application can be implemented with the help of software and / or hardware. The "unit" and "module" in this specification refer to software and / or hardware that can independently complete or cooperate with other components to complete specific functions, where the hardware can be, for example, a field programmable gate array (FPGA), an integrated circuit (IC), etc.
[0130] It should be noted that, for the aforementioned method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the described order of actions, because according to the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present application.
[0131] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0132] In the several embodiments provided in the present application, it should be understood that the disclosed devices can be implemented in other ways. For example, the device embodiments described above are only schematic, such as the division of the units, which is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some service interfaces, and the indirect coupling or communication connection of devices or units can be electrical or other forms.
[0133] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0134] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0135] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable memory. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a memory, including a number of instructions to enable a computer device (which can be a personal computer, server or network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned memory includes: U disk, read-only memory (ROM), random access memory (RAM), mobile hard disk, disk or optical disk and other media that can store program code.
[0136] A person skilled in the art may understand that all or part of the steps in the various methods of the above embodiments may be completed by entering a program to instruct the relevant hardware. The program may be stored in a computer-readable memory, and the memory may include: a flash drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0137] The above is only an exemplary embodiment of the present disclosure, and the scope of the present disclosure cannot be limited thereto. That is, any equivalent changes and modifications made according to the teachings of the present disclosure are still within the scope of the present disclosure. After considering the specification and practicing the disclosure here, those skilled in the art will easily think of other embodiments of the present disclosure. This application is intended to cover any modification, use or adaptation of the present disclosure, which follows the general principles of the present disclosure and includes common knowledge or customary technical means in the technical field not recorded in the present disclosure. The description and examples are only regarded as exemplary, and the scope and spirit of the present disclosure are defined by the claims.
Claims
1. A file matching method, characterized in that: The method comprises: Read the modified diff file based on Node.js; Record the file directory information of the files matching the diff file during the process of Webpack building the project source code; Writing the file directory information into the target file; The diff file is obtained by performing diff on the file before modification and the file after modification using the diff command on the Node.js platform; The file matching the diff file contains the same code block as the diff file; The method of recording the file directory information of the file matching the diff file in the process of Webpack building the project source code includes: inserting a plug-in when Webpack starts compiling the file based on the event information in Webpack, and detecting whether the entry file matches the diff file based on the plug-in; if the entry file matches the diff file, recording the file directory information of the entry file; if the entry file does not match the diff file, determining the first dependent file matching the diff file in the dependent file of the entry file, and recording the file directory information of the first dependent file; Before inserting the plug-in when Webpack starts to compile files, the method includes: obtaining the Hook of Webpack, and monitoring event information in the Webpack based on the Hook.
2. The method according to claim 1, characterized in that Determining the first dependent file matching the diff file in the dependent file of the entry file includes: Find the dependent files of the entry file based on the AST syntax tree created by Webpack; The first dependent file matching the diff file is screened out from the dependent files in a recursive manner.
3. The method according to claim 2, characterized in that The step of selecting the first dependent file matching the diff file from the dependent files includes: The dependent file that matches the code of the diff file is determined in the dependent files as the first dependent file.
4. A file matching device, characterized in that: include: The diff file acquisition module is used to read the modified diff file based on Node.js; A file information recording module is used to record the file directory information of the files matching the diff file in the process of Webpack building the project source code; A file information saving module, used for writing the file directory information into a target file; The diff file is obtained by performing diff on the file before modification and the file after modification using the diff command on the Node.js platform; The file matching the diff file contains the same code block as the diff file; The file information recording module includes: A plug-in detection unit, used to insert a plug-in when Webpack starts to compile a file, and detect whether the entry file matches the diff file based on the plug-in; A first information recording unit, configured to record file directory information of the entry file if the entry file matches the diff file; A second information recording unit is used to determine a first dependent file matching the diff file in the dependent file of the entry file if the entry file does not match the diff file, and record the file directory information of the first dependent file; The file information recording module also includes: The Hook acquisition unit is used to acquire the Hook of Webpack and monitor the event information in the Webpack based on the Hook.
5. A storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 3 are implemented.
6. A computer device, characterized in that: include: A processor and a memory; wherein the memory stores a computer program, and the computer program is suitable for being loaded by the processor and executing the steps of the method as claimed in any one of claims 1 to 3.
