Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ui/packages/shared/parser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "JavaScript parser implementation for the continuous profiling language",
"main": "dist/index.js",
"scripts": {
"test": "jest --coverage --config ../../../jest.config.cjs ./src/*",
"test": "vitest run",
"gen": "nearleyc -g -o ./src/selector.js ./src/selector.ne",
"watch": "tsc-watch",
"build": "tsc"
Expand Down
6 changes: 6 additions & 0 deletions ui/packages/shared/parser/src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ test('Query.toString With Comma', () => {
);
});

test('Query.toString With hyphen', () => {
expect(Query.parse('query-memory:inuse_space:bytes:space:bytes{}').toString()).toBe(
'query-memory:inuse_space:bytes:space:bytes{}'
);
});

test('Partial Parsing ProfileName and rest', () => {
[
{
Expand Down
2 changes: 1 addition & 1 deletion ui/packages/shared/parser/src/selector.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export let grammar;
main: {
strstart: {match: '"', push: 'lit'},
space: {match: /\s+/, lineBreaks: true},
ident: /(?:[a-zA-Z_:][a-zA-Z0-9_:.]*)/,
ident: /(?:[a-zA-Z_:][a-zA-Z0-9_:\-.]*)/,
matcherType: ['=', '!=', '=~', '!~'],
'{': '{',
'}': '}',
Expand Down
2 changes: 1 addition & 1 deletion ui/packages/shared/parser/src/selector.ne
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ let lexer = moo.states({
main: {
strstart: {match: '"', push: 'lit'},
space: {match: /\s+/, lineBreaks: true},
ident: /(?:[a-zA-Z_:][a-zA-Z0-9_:.]*)/,
ident: /(?:[a-zA-Z_:][a-zA-Z0-9_:\-.]*)/,
matcherType: ['=', '!=', '=~', '!~'],
'{': '{',
'}': '}',
Expand Down
14 changes: 14 additions & 0 deletions ui/packages/shared/parser/test-setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Copyright 2022 The Parca Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

import '@testing-library/jest-dom';
Loading