Skip to content
Merged
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 launchable/commands/inspect/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
import click
from tabulate import tabulate

from ..helper import require_session
from ...utils.authentication import ensure_org_workspace
from ...utils.launchable_client import LaunchableClient
from ...utils.session import parse_session
from ..helper import require_session


class TestResult(object):
Expand Down
5 changes: 2 additions & 3 deletions launchable/commands/record/case_event.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import datetime
import sys
from typing import Callable, Dict, Optional, Any
from typing import Any, Callable, Dict, Optional

import dateutil.parser
from dateutil.tz import tzlocal

from junitparser import Error, Failure, Skipped, TestCase, TestSuite, IntAttr # type: ignore
from junitparser import Error, Failure, IntAttr, Skipped, TestCase, TestSuite # type: ignore

from ...testpath import FilePathNormalizer, TestPath

Expand Down
12 changes: 12 additions & 0 deletions launchable/commands/subset.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@
help='subsetting by confidence from 0% to 100%',
type=PERCENTAGE,
)
@click.option(
'--goal-spec',
'goal_spec',
help='subsetting by programmatic goal definition',
type=str,
)
@click.option(
'--session',
'session',
Expand Down Expand Up @@ -185,6 +191,7 @@ def subset(
duration: Optional[DurationType],
flavor: Sequence[Tuple[str, str]],
confidence: Optional[PercentageType],
goal_spec: Optional[str],
split: bool,
no_base_path_inference: bool,
ignore_new_tests: bool,
Expand Down Expand Up @@ -431,6 +438,11 @@ def get_payload(
"type": "subset-by-confidence",
"percentage": confidence
}
elif goal_spec is not None:
payload["goal"] = {
"type": "subset-by-goal-spec",
"goal": goal_spec
}
else:
payload['useServerSideOptimizationTarget'] = True

Expand Down
1 change: 0 additions & 1 deletion launchable/test_runners/flutter.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import json
import pathlib
from pathlib import Path
from typing import Dict, Generator, List, Optional

import click
Expand Down
4 changes: 2 additions & 2 deletions launchable/test_runners/prove.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import re

import click
from junitparser import TestCase, TestSuite # type: ignore
import re

from ..testpath import TestPath
from . import launchable


TEARDOWN = "(teardown)"


Expand Down
1 change: 1 addition & 0 deletions launchable/utils/sax.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from xml.sax import make_parser
from xml.sax.handler import ContentHandler
from xml.sax.xmlreader import AttributesImpl

import click


Expand Down
33 changes: 33 additions & 0 deletions tests/commands/test_subset.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,39 @@ def test_subset_targetless(self):
payload = json.loads(gzip.decompress(responses.calls[0].request.body).decode())
self.assertTrue(payload.get('useServerSideOptimizationTarget'))

@responses.activate
@mock.patch.dict(os.environ, {"LAUNCHABLE_TOKEN": CliTestCase.launchable_token})
def test_subset_goalspec(self):
# make sure --goal-spec gets translated properly to a JSON request payload
responses.replace(
responses.POST,
"{}/intake/organizations/{}/workspaces/{}/subset".format(
get_base_url(),
self.organization,
self.workspace),
json={
"testPaths": [
[{"type": "file", "name": "test_aaa.py"}],
],
"testRunner": "file",
"rest": [],
"subsettingId": 123,
},
status=200)

result = self.cli(
"subset",
"--session",
self.session,
"--goal-spec",
"foo(),bar(zot=3%)",
"file",
input="test_aaa.py")
self.assert_success(result)

payload = json.loads(gzip.decompress(responses.calls[0].request.body).decode())
self.assertEqual(payload.get('goal').get('goal'), "foo(),bar(zot=3%)")

@responses.activate
@mock.patch.dict(os.environ, {"LAUNCHABLE_TOKEN": CliTestCase.launchable_token})
def test_subset_ignore_flaky_tests_above(self):
Expand Down
2 changes: 1 addition & 1 deletion tests/data/cucumber/report/result.json
Original file line number Diff line number Diff line change
Expand Up @@ -1989,4 +1989,4 @@
}
]
}
]
]
2 changes: 1 addition & 1 deletion tests/data/flutter/record_test_result.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,4 @@
"noBuild": false,
"flavors": [],
"testSuite": ""
}
}
2 changes: 1 addition & 1 deletion tests/data/playwright/record_test_result.json
Original file line number Diff line number Diff line change
Expand Up @@ -1680,4 +1680,4 @@
"noBuild": false,
"flavors": [],
"testSuite": ""
}
}
2 changes: 1 addition & 1 deletion tests/data/playwright/record_test_result_with_json.json
Original file line number Diff line number Diff line change
Expand Up @@ -2406,4 +2406,4 @@
"noBuild": false,
"flavors": [],
"testSuite": ""
}
}
2 changes: 1 addition & 1 deletion tests/data/playwright/report.json
Original file line number Diff line number Diff line change
Expand Up @@ -3615,4 +3615,4 @@
"unexpected": 3,
"flaky": 6
}
}
}
2 changes: 1 addition & 1 deletion tests/data/playwright/report.xml
Original file line number Diff line number Diff line change
Expand Up @@ -578,4 +578,4 @@ Retry count: [33m3[39m
</system-out>
</testcase>
</testsuite>
</testsuites>
</testsuites>