-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
1.5.3 #36
base: master
Are you sure you want to change the base?
1.5.3 #36
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
include BSD_LICENSE | ||
include LICENSE | ||
include README.md | ||
include requirements.txt |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Sample Retool ToolScript file | ||
function MainToolScript() { | ||
const data = useData(); | ||
|
||
return ( | ||
<Container> | ||
<Text value="Hello Retool!" /> | ||
<Table | ||
data={data.users} | ||
onRowSelect={(row) => { | ||
showNotification('Selected: ' + row.name); | ||
}} | ||
/> | ||
<Button | ||
label="Refresh" | ||
onClick={() => { | ||
queries.fetchUsers.run(); | ||
}} | ||
/> | ||
</Container> | ||
); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import os | ||
import json | ||
from modernmetric.__main__ import main as modernmetric_main | ||
from pygments import lex | ||
from pygments_tsx.tsx import TypeScriptXLexer | ||
|
||
|
||
def test_rsx_support(tmp_path): | ||
# Create a temporary output file in the test directory | ||
output_file = tmp_path / "rsx_test_output.json" | ||
|
||
# Get path to the sample RSX file | ||
current_dir = os.path.dirname(__file__) | ||
test_file = os.path.join(current_dir, "fixtures", "Sample.rsx") | ||
|
||
# Run modernmetric on the .rsx file | ||
modernmetric_main(custom_args=[ | ||
test_file, | ||
"--output_file", str(output_file) | ||
]) | ||
|
||
# Verify output exists and contains expected data | ||
assert output_file.exists() | ||
with open(output_file) as f: | ||
result = json.load(f) | ||
assert "files" in result | ||
assert any(f.endswith("Sample.rsx") for f in result["files"]) | ||
|
||
|
||
def test_rsx_lexer(): | ||
# Get path to the sample RSX file | ||
current_dir = os.path.dirname(__file__) | ||
test_file = os.path.join(current_dir, "fixtures", "Sample.rsx") | ||
|
||
# Read the RSX file | ||
with open(test_file, 'r') as f: | ||
code = f.read() | ||
|
||
# Create lexer and get tokens | ||
lexer = TypeScriptXLexer() | ||
tokens = list(lex(code, lexer)) | ||
|
||
# Test for RSX-specific components | ||
rsx_components = ['Container', 'Text', 'Table', 'Button'] | ||
found_components = [] | ||
|
||
for token_type, value in tokens: | ||
if value in rsx_components: | ||
found_components.append(value) | ||
print(f"Token: {token_type} -> {value}") | ||
Comment on lines
+47
to
+50
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. issue (code-quality): Avoid loops in tests. ( ExplanationAvoid complex code, like loops, in test functions.Google's software engineering guidelines says:
Some ways to fix this:
Software Engineering at Google / Don't Put Logic in Tests
Comment on lines
+48
to
+50
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. issue (code-quality): Avoid conditionals in tests. ( ExplanationAvoid complex code, like conditionals, in test functions.Google's software engineering guidelines says:
Some ways to fix this:
Software Engineering at Google / Don't Put Logic in Tests |
||
|
||
# Verify all expected components were found | ||
assert set(found_components) == set(rsx_components), ( | ||
f"Not all RSX components were found. Expected {rsx_components}, " | ||
f"got {found_components}") | ||
|
||
# Test basic syntax elements | ||
code_elements = { | ||
'function': False, | ||
'const': False, | ||
'return': False, | ||
'MainToolScript': False | ||
} | ||
|
||
for _, value in tokens: | ||
if value in code_elements: | ||
code_elements[value] = True | ||
Comment on lines
+65
to
+67
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. issue (code-quality): Avoid loops in tests. ( ExplanationAvoid complex code, like loops, in test functions.Google's software engineering guidelines says:
Some ways to fix this:
Software Engineering at Google / Don't Put Logic in Tests
Comment on lines
+66
to
+67
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. issue (code-quality): Avoid conditionals in tests. ( ExplanationAvoid complex code, like conditionals, in test functions.Google's software engineering guidelines says:
Some ways to fix this:
Software Engineering at Google / Don't Put Logic in Tests |
||
|
||
# Verify basic syntax elements were found | ||
assert all(code_elements.values()), \ | ||
f"Missing required code elements. Status: {code_elements}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This probably shouldn't be here. And pygments-tsx should be >= 1.0.3