Skip to content

Commit 8eaa51f

Browse files
committed
chore(e2e): inline python assertions
1 parent d34fbf9 commit 8eaa51f

File tree

13 files changed

+162
-67
lines changed

13 files changed

+162
-67
lines changed

.github/workflows/nightly.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,6 @@ jobs:
110110
sudo apt-get update
111111
sudo apt-get install -y gcc-multilib
112112
113-
- name: Run unit tests
114-
if: matrix.target == 'x86_64-unknown-linux-gnu'
115-
run: cargo test
116-
117113
- name: Build
118114
run: cargo build --release --target ${{ matrix.target }}
119115

.github/workflows/test.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,10 @@ jobs:
3838
- name: Run tests
3939
working-directory: testing
4040
run: |
41-
pip install uv
41+
pip install -U uv
4242
uv venv
4343
. ${{ matrix.runs-on == 'windows-latest' && '.venv/Scripts/activate' || '.venv/bin/activate'}}
44+
uv pip compile requirements.in -o requirements.txt
4445
uv pip sync requirements.txt
4546
pytest -vv --junitxml=.results.xml --color=yes
4647

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ dist/*
99
syntaxes/*.json
1010
.venv
1111
__pycache__
12-
.*_cache
12+
.*_cache
13+
testing/requirements.txt

src/analyze.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Methods related to type analysis. The two most important methods are
22
//! [`Backend::model_of_range`] and [`Backend::type_of`].
33
4-
use std::{borrow::Borrow, collections::HashMap, iter::FusedIterator, ops::ControlFlow};
4+
use std::{borrow::Borrow, collections::HashMap, fmt::Debug, iter::FusedIterator, ops::ControlFlow};
55

66
use tracing::trace;
77
use tree_sitter::{Node, QueryCursor};
@@ -63,6 +63,12 @@ pub struct Scope {
6363
pub super_: Option<ImStr>,
6464
}
6565

66+
impl Debug for Scope {
67+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
68+
f.debug_tuple("Scope").field(&"..").finish()
69+
}
70+
}
71+
6672
pub fn normalize<'r, 'n>(node: &'r mut Node<'n>) -> &'r mut Node<'n> {
6773
let mut cursor = node.walk();
6874
while matches!(

src/python.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,6 +1017,11 @@ impl Backend {
10171017
return ControlFlow::Continue(entered);
10181018
}
10191019

1020+
// HACK: fix this issue where the model name is just empty
1021+
if interner().resolve(&model_name).is_empty() {
1022+
return ControlFlow::Continue(entered);
1023+
}
1024+
10201025
diagnostics.push(Diagnostic {
10211026
range: ts_range_to_lsp_range(attribute.range()),
10221027
severity: Some(DiagnosticSeverity::ERROR),

src/xml.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use odoo_lsp::model::{Field, FieldKind};
1515
use odoo_lsp::template::gather_templates;
1616
use ropey::{Rope, RopeSlice};
1717
use tower_lsp::lsp_types::*;
18-
use tracing::{debug, warn};
18+
use tracing::{debug, instrument, warn};
1919
use tree_sitter::Parser;
2020
use xmlparser::{ElementEnd, Error, StrSpan, StreamError, Token, Tokenizer};
2121

@@ -610,6 +610,7 @@ impl Backend {
610610
}
611611
/// The main function that determines all the information needed
612612
/// to resolve the symbol at the cursor.
613+
#[instrument(level = "trace", skip_all, ret)]
613614
fn gather_refs<'read>(
614615
&self,
615616
offset_at_cursor: ByteOffset,
@@ -998,6 +999,7 @@ impl Backend {
998999
}
9991000
}
10001001

1002+
#[derive(Debug)]
10011003
struct XmlRefs<'a> {
10021004
ref_at_cursor: Option<(&'a str, core::ops::Range<usize>)>,
10031005
ref_kind: Option<RefKind<'a>>,

testing/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,9 @@
11
End-to-end testing for odoo-lsp.
2+
3+
```shell
4+
pip install -U setuptools uv
5+
uv venv
6+
source .venv/bin/activate
7+
uv pip compile requirements.in > requirements.txt
8+
uv pip sync requirements.txt
9+
```

testing/fixtures/basic/bar/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ class DerivedBar(models.Model):
77
_inherit = "bar"
88

99
def test(self):
10-
self.env["bar"]
10+
pass
Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,32 @@
11
class Foo(Model):
22
_name = "foo"
33

4-
def test(self):
4+
bar = fields.Char()
5+
6+
def completions(self):
57
self.env["bar"]
8+
# ^complete bar derived.bar foo foob
69

710
def diagnostics(self):
811
self.foo
12+
# ^diag Model `foo` has no field `foo`
913
self.env["foo"].foo
14+
# ^diag Model `foo` has no field `foo`
1015
self.mapped("foo")
16+
# ^diag Model `foo` has no field `foo`
1117
self.env["fo"]
18+
# ^diag `fo` is not a valid model name
1219

1320

1421
class Foob(Model):
1522
_name = "foob"
23+
24+
foo_id = fields.Many2one("foo")
25+
barb = fields.Char(related='foo_id.bar')
26+
# ^complete bar
27+
28+
class NonModel:
29+
__slots__ = ("foo", "bar")
30+
31+
def __init__(self):
32+
...
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<odoo>
2+
<record id="foo.1" model="foo">
3+
<field name="bar"/>
4+
<!-- ^complete bar -->
5+
</record>
6+
</odoo>

0 commit comments

Comments
 (0)