Skip to content

Commit

Permalink
Merge pull request #1 from nadeeshaan/kUpRetry
Browse files Browse the repository at this point in the history
Fix failing language server tests
  • Loading branch information
kalaiyarasiganeshalingam authored Nov 7, 2019
2 parents eac7d98 + 0f1b50c commit 2f0eaee
Show file tree
Hide file tree
Showing 349 changed files with 36,280 additions and 35,727 deletions.
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
name: "Run Build + tests (without integration) - Linux"
script:
- while sleep 9m; do echo "=====[ $SECONDS seconds still running ]====="; done &
- ./gradlew build -x :jballerina-integration-test:test -x createJavadoc --stacktrace -scan --console=plain --no-daemon
- ./gradlew clean build --no-build-cache -x :jballerina-integration-test:test -x createJavadoc --stacktrace -scan --console=plain --no-daemon
# Killing background sleep loop
- kill %1
os: linux
Expand All @@ -75,7 +75,7 @@ jobs:
- script:
- while sleep 9m; do echo "=====[ $SECONDS seconds still running ]====="; done &
# TODO enable tests for all projects
- ./gradlew.bat build -Dorg.gradle.parallel=false -x :language-server:language-server-core:test -x :ballerina-packerina:test -x :ballerina-lang:test -x :jballerina-unit-test:test -x :jballerina-integration-test:test -x :plugin-vscode:test -x createJavadoc --stacktrace -scan --console=plain --no-daemon
- ./gradlew.bat clean build --no-build-cache -Dorg.gradle.parallel=false -x :language-server:language-server-core:test -x :ballerina-packerina:test -x :ballerina-lang:test -x :ballerina-http:test -x :ballerina-file:test -x :ballerina-task:test -x :ballerina-socket:test -x :jballerina-unit-test:test -x :jballerina-integration-test:test -x :plugin-vscode:test -x createJavadoc --stacktrace -scan --console=plain --no-daemon
# Killing background sleep loop
- kill %1
name: "Tests - windows"
Expand All @@ -87,7 +87,7 @@ jobs:
- export JAVA_HOME="c:\\java8"
- script:
- while sleep 9m; do echo "=====[ $SECONDS seconds still running ]====="; done &
- ./gradlew :jballerina-integration-test:test -x createJavadoc --stacktrace -scan --console=plain --no-daemon
- ./gradlew clean -no-build-cache :jballerina-integration-test:test -x createJavadoc --stacktrace -scan --console=plain --no-daemon
# Killing background sleep loop
- kill %1
os: linux
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class ConfigProcessor {
* (environment vars, etcd or something similar), 3. ballerina.conf file
*
* @param runtimeParams The -B params passed to the BVM as CLI parameters
* @param userProvidedConfigFile The config file provided through the --config CLI parameter
* @param userProvidedConfigFile The config file provided through the --b7a.config.file property
* @param ballerinaConfDefaultPath The default config file (ballerina.conf) located at the source root
* @return The parsed and resolved set of configurations
* @throws IOException Thrown if there was an error while attempting to process the config file
Expand Down
4 changes: 4 additions & 0 deletions bvm/ballerina-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,17 @@ dependencies {
implementation 'io.opentracing:opentracing-util'
implementation 'org.awaitility:awaitility'
implementation 'com.zaxxer:HikariCP'
implementation 'org.slf4j:slf4j-jdk14'
}

description = 'Ballerina - Core'

configurations {
implementation {
exclude group: 'org.apache.servicemix.bundles', module: 'org.apache.servicemix.bundles.commons-beanutils'
exclude group: 'org.ops4j.pax.logging', module: 'pax-logging-api'
exclude group: 'org.ops4j.pax.logging', module: 'pax-logging-log4j2'
exclude group: 'org.slf4j', module: 'slf4j-log4j12'
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,15 @@ public static void processServiceAnnotations(MapValue globalAnnotMap, BServiceTy
String annotationKey = bType.getAnnotationKey();
if (globalAnnotMap.containsKey(annotationKey)) {
bType.setAnnotations((MapValue<String, Object>)
((FPValue) globalAnnotMap.get(annotationKey)).apply(new Object[]{strand}));
((FPValue) globalAnnotMap.get(annotationKey)).call(new Object[]{strand}));
}

for (AttachedFunction attachedFunction : bType.getAttachedFunctions()) {
annotationKey = attachedFunction.getAnnotationKey();
if (globalAnnotMap.containsKey(annotationKey)) {
attachedFunction.setAnnotations((MapValue<String, Object>)
((FPValue) globalAnnotMap.get(annotationKey))
.apply(new Object[]{strand}));
.call(new Object[]{strand}));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Semaphore;
import java.util.function.Consumer;
import java.util.function.Function;

/**
* External API to be used by the interop users to control Ballerina runtime behavior.
Expand Down Expand Up @@ -55,18 +55,18 @@ public static BRuntime getCurrentRuntime() {
}

public void invokeMethodAsync(ObjectValue object, String methodName, Object... args) {
Consumer func = o -> object.call((Strand) (((Object[]) o)[0]), methodName, args);
Function<?, ?> func = o -> object.call((Strand) (((Object[]) o)[0]), methodName, args);
scheduler.schedule(new Object[1], func, null, null);
}

public void invokeMethodAsync(ObjectValue object, String methodName,
CallableUnitCallback callback, Object... args) {
Consumer func = o -> object.call((Strand) (((Object[]) o)[0]), methodName, args);
Function<?, ?> func = o -> object.call((Strand) (((Object[]) o)[0]), methodName, args);
scheduler.schedule(new Object[1], func, null, callback);
}

public void invokeMethodSync(ObjectValue object, String methodName, Object... args) {
Consumer func = o -> object.call((Strand) (((Object[]) o)[0]), methodName, args);
Function<?, ?> func = o -> object.call((Strand) (((Object[]) o)[0]), methodName, args);
Semaphore semaphore = new Semaphore(0);
final ErrorValue[] errorValue = new ErrorValue[1];
scheduler.schedule(new Object[1], func, null, new CallableUnitCallback() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -967,7 +967,10 @@ static boolean checkIsLikeType(Object sourceValue, BType targetType, List<TypeVa
List<BType> compatibleTypesWithNumConversion = new ArrayList<>();
List<BType> compatibleTypesWithoutNumConversion = new ArrayList<>();
for (BType type : ((BUnionType) targetType).getMemberTypes()) {
if (checkIsLikeType(sourceValue, type, unresolvedValues, false)) {
List<TypeValuePair> tempList = new ArrayList<>(unresolvedValues.size());
tempList.addAll(unresolvedValues);

if (checkIsLikeType(sourceValue, type, tempList, false)) {
compatibleTypesWithoutNumConversion.add(type);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,9 @@ public FutureValue scheduleFunction(Object[] params, FPValue<?, ?> fp, Strand pa
return schedule(params, fp.getFunction(), parent, null, null, returnType);
}

@Deprecated
public FutureValue scheduleConsumer(Object[] params, FPValue<?, ?> fp, Strand parent) {
return schedule(params, fp.getConsumer(), parent, null);
return schedule(params, fp.getFunction(), parent, (CallableUnitCallback) null);
}

/**
Expand All @@ -126,6 +127,20 @@ public FutureValue schedule(Object[] params, Function function, Strand parent, C
return schedule(params, function, parent, future);
}

/**
* Add a task to the runnable list, which will eventually be executed by the Scheduler.
*
* @param params - parameters to be passed to the function
* @param function - function to be executed
* @param parent - parent strand that makes the request to schedule another
* @param callback - to notify any listener when ever the execution of the given function is finished
* @return - Reference to the scheduled task
*/
public FutureValue schedule(Object[] params, Function function, Strand parent, CallableUnitCallback callback) {
FutureValue future = createFuture(parent, callback, null, BTypes.typeNull);
return schedule(params, function, parent, future);
}

private FutureValue schedule(Object[] params, Function function, Strand parent, FutureValue future) {
params[0] = future.strand;
SchedulerItem item = new SchedulerItem(function, params, future);
Expand All @@ -144,6 +159,7 @@ private FutureValue schedule(Object[] params, Function function, Strand parent,
* @param callback - to notify any listener when ever the execution of the given function is finished
* @return - Reference to the scheduled task
*/
@Deprecated
public FutureValue schedule(Object[] params, Consumer consumer, Strand parent, CallableUnitCallback callback) {
FutureValue future = createFuture(parent, callback, null, BTypes.typeNull);
params[0] = future.strand;
Expand Down Expand Up @@ -380,7 +396,6 @@ public void poison() {
*/
class SchedulerItem {
private Function function;
private Consumer consumer;
private Object[] params;
final FutureValue future;
boolean parked;
Expand All @@ -393,9 +408,13 @@ public SchedulerItem(Function function, Object[] params, FutureValue future) {
this.params = params;
}

@Deprecated
public SchedulerItem(Consumer consumer, Object[] params, FutureValue future) {
this.future = future;
this.consumer = consumer;
this.function = val -> {
consumer.accept(val);
return null;
};
this.params = params;
}

Expand All @@ -404,12 +423,7 @@ private SchedulerItem() {
}

public Object execute() {
if (this.consumer != null) {
this.consumer.accept(this.params);
return null;
} else {
return this.function.apply(this.params);
}
return this.function.apply(this.params);
}

public boolean isYielded() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class DefaultStreamSubscription extends StreamSubscription {

public void execute(Object[] fpParams) {
//Cannot use scheduler, as the order of events should be preserved
functionPointer.accept(fpParams);
functionPointer.call(fpParams);
}

public StreamValue getStream() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ private void invokeCommittedFunction(Strand strand, String transactionId, String
FPValue fp = committedFuncRegistry.get(transactionBlockId);
Object[] args = { strand, (transactionId + ":" + transactionBlockId), true };
if (fp != null) {
strand.scheduler.schedule(args, fp.getConsumer(), strand, null);
strand.scheduler.schedule(args, fp.getFunction(), strand, null);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,32 +42,42 @@ public class FPValue<T, R> implements RefValue {

final BType type;
Function<T, R> function;
Consumer<T> consumer;

public FPValue(Function<T, R> function, BType type) {
this.function = function;
this.type = type;
}

public R call(T t) {
return this.function.apply(t);
}

@Deprecated
public FPValue(Consumer<T> consumer, BType type) {
this.consumer = consumer;
this.function = val -> {
consumer.accept(val);
return null;
};
this.type = type;
}

@Deprecated
public R apply(T t) {
return this.function.apply(t);
}

@Deprecated
public void accept(T t) {
this.consumer.accept(t);
this.function.apply(t);
}

public Function<T, R> getFunction() {
return this.function;
}

@Deprecated
public Consumer<T> getConsumer() {
return this.consumer;
return val -> this.function.apply(val);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ public Object performRemoveOperation(Strand strand, FPValue<Object, Boolean> fun
int deletedCount = 0;
while (this.hasNext()) {
MapValueImpl<String, Object> row = this.getNext();
if (func.apply(new Object[] { strand, row, true })) {
if (func.call(new Object[] { strand, row, true })) {
tableProvider.deleteData(this.tableName, row);
++deletedCount;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,10 @@
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Optional;

import static org.wso2.ballerinalang.compiler.util.ProjectDirConstants.BALLERINA_HOME;
Expand All @@ -68,6 +70,7 @@ public class BuildContext extends HashMap<BuildContextField, Object> {
private SourceType srcType;
private transient PrintStream out;
private transient PrintStream err;
public transient Map<PackageID, HashSet<Path>> moduleDependencyPathMap = new HashMap<>();

/**
* Create a build context with context fields.
Expand Down Expand Up @@ -270,11 +273,13 @@ public Path getHomeRepoDir() {
}

public Path getBirCacheFromHome() {
return RepoUtils.createAndGetHomeReposPath().resolve(ProjectDirConstants.BIR_CACHE_DIR_NAME);
return RepoUtils.createAndGetHomeReposPath().resolve(ProjectDirConstants.BIR_CACHE_DIR_NAME + "-" +
RepoUtils.getBallerinaVersion());
}

public Path getJarCacheFromHome() {
return RepoUtils.createAndGetHomeReposPath().resolve(ProjectDirConstants.JAR_CACHE_DIR_NAME);
return RepoUtils.createAndGetHomeReposPath().resolve(ProjectDirConstants.JAR_CACHE_DIR_NAME + "-" +
RepoUtils.getBallerinaVersion());
}

public Path getBaloCacheFromHome() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
import static org.ballerinalang.compiler.CompilerOptionName.EXPERIMENTAL_FEATURES_ENABLED;
import static org.ballerinalang.compiler.CompilerOptionName.LOCK_ENABLED;
import static org.ballerinalang.compiler.CompilerOptionName.OFFLINE;
import static org.ballerinalang.compiler.CompilerOptionName.PRESERVE_WHITESPACE;
import static org.ballerinalang.compiler.CompilerOptionName.PROJECT_DIR;
import static org.ballerinalang.compiler.CompilerOptionName.SKIP_TESTS;
import static org.ballerinalang.compiler.CompilerOptionName.TEST_ENABLED;
Expand Down Expand Up @@ -149,11 +150,8 @@ public BuildCommand(Path userDir, PrintStream outStream, PrintStream errStream,
@CommandLine.Option(names = "--experimental", description = "Enable experimental language features.")
private boolean experimentalFlag;

@CommandLine.Option(names = {"--config"}, description = "Path to the configuration file when running tests.")
private String configFilePath;

private static final String buildCmd = "ballerina build [-o <output>] [--sourceroot] [--offline] [--skip-tests]\n" +
" [--skip-lock] {<ballerina-file | module-name> | -a | --all}";
" [--skip-lock] {<ballerina-file | module-name> | -a | --all} [--] [(--key=value)...]";

public void execute() {
if (this.helpFlag) {
Expand Down Expand Up @@ -362,6 +360,7 @@ public void execute() {
options.put(SKIP_TESTS, Boolean.toString(this.skipTests));
options.put(TEST_ENABLED, "true");
options.put(EXPERIMENTAL_FEATURES_ENABLED, Boolean.toString(this.experimentalFlag));
options.put(PRESERVE_WHITESPACE, "true");
// create builder context
BuildContext buildContext = new BuildContext(this.sourceRootPath, targetPath, sourcePath, compilerContext);
buildContext.setOut(outStream);
Expand All @@ -380,11 +379,11 @@ public void execute() {
.addTask(new CreateBaloTask(), isSingleFileBuild) // create the balos for modules(projects only)
.addTask(new CreateBirTask()) // create the bir
.addTask(new CopyNativeLibTask(skipCopyLibsFromDist)) // copy the native libs(projects only)
.addTask(new CreateJarTask(this.dumpBIR)) // create the jar
.addTask(new CreateJarTask(this.dumpBIR, skipCopyLibsFromDist)) // create the jar
.addTask(new CopyModuleJarTask(skipCopyLibsFromDist))
.addTask(new RunTestsTask(), this.skipTests || isSingleFileBuild) // run tests
// (projects only)
.addTask(new CreateExecutableTask(skipCopyLibsFromDist), this.compile) // create the executable.jar
.addTask(new CreateExecutableTask(), this.compile) // create the executable.jar
// file
.addTask(new CopyExecutableTask(outputPath), !isSingleFileBuild) // copy executable
.addTask(new PrintExecutablePathTask(), this.compile) // print the location of the executable
Expand Down Expand Up @@ -423,7 +422,7 @@ public void printLongDesc(StringBuilder out) {
@Override
public void printUsage(StringBuilder out) {
out.append(" ballerina build [-o <output-file>] [--offline] [--skip-tests] [--skip-lock] " +
"{<ballerina-file | module-name> | -a | --all} \n");
"{<ballerina-file | module-name> | -a | --all} [--] [(--key=value)...]\n");
}

@Override
Expand Down
Loading

0 comments on commit 2f0eaee

Please sign in to comment.